Submission #1481402


Source Code Expand

#!/usr/bin/python
import functools
class SAComp:
	def __init__(self,h,g):
		self.h=h
		self.g=g
	def cmp(self,a,b):
		if a==b: return 0
		if self.g[a]!=self.g[b]: return self.g[a]-self.g[b]
		return self.g[a+self.h]-self.g[b+self.h]

def buildSA(t):
	n=len(t)
	g=list(map(ord,t))
	b=[0]*n
	suff=list(range(n))
	comp=SAComp(0,g)
	suff.sort(key=functools.cmp_to_key(comp.cmp))
	h=1
	while b[n-1]!=n-1:
		comp=SAComp(h,g)
		suff.sort(key=functools.cmp_to_key(comp.cmp))
		for i in range(n-1):
			b[i+1]=b[i]+(comp.cmp(suff[i],suff[i+1])<0)
		for i in range(n):
			g[suff[i]]=b[i]
		h<<=1
	return suff

def buildLCP(t,suff):
	n=len(t)
	rank=[0]*n
	lcp=[0]*n
	for i in range(n):
		rank[suff[i]]=i
	h=0
	for i in range(n-1):
		j=suff[rank[i]-1]
		if h>0: h-=1
		while j+h<n and i+h<n and t[j+h]==t[i+h]:
			h+=1
		lcp[rank[i]-1]=h
	return lcp

def solve(s):
	s+='$'
	suff=buildSA(s)
	lcp=buildLCP(s,suff)
	return len(s)-1-max(lcp)

import sys;print(solve(sys.stdin.readline().strip()))

Submission Info

Submission Time
Task G - Exam
User leafmoon
Language PyPy2 (5.6.0)
Score 60
Code Size 1029 Byte
Status TLE
Exec Time 2113 ms
Memory 141304 KB

Judge Result

Set Name Subtask1 Subtask2 All
Score / Max Score 30 / 30 30 / 30 0 / 140
Status
AC × 51
AC × 46
AC × 121
TLE × 22
Set Name Test Cases
Subtask1 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_small_000.txt, 00_small_001.txt, 00_small_002.txt, 00_small_003.txt, 00_small_004.txt, 00_small_005.txt, 00_small_006.txt, 00_small_007.txt, 00_small_008.txt, 00_small_009.txt, 00_small_010.txt, 00_small_011.txt, 00_small_012.txt, 00_small_013.txt, 00_small_014.txt, 00_small_015.txt, 00_small_016.txt, 00_small_017.txt, 00_small_018.txt, 00_small_019.txt, 00_small_020.txt, 00_small_021.txt, 00_small_022.txt, 00_small_023.txt, 00_small_024.txt, 00_small_025.txt, 00_small_078.txt, 00_small_079.txt, 00_small_080.txt, 00_small_081.txt, 00_small_082.txt, 00_small_083.txt, 00_small_084.txt, 00_small_085.txt, 00_small_086.txt, 00_small_087.txt, 00_small_108.txt, 00_small_109.txt, 00_small_110.txt, 00_small_111.txt, 00_small_112.txt, 00_small_113.txt, 00_small_114.txt, 00_small_115.txt, 00_small_116.txt, 00_small_117.txt, 00_teuchi_00.txt
Subtask2 10_medium_026.txt, 10_medium_027.txt, 10_medium_028.txt, 10_medium_029.txt, 10_medium_030.txt, 10_medium_031.txt, 10_medium_032.txt, 10_medium_033.txt, 10_medium_034.txt, 10_medium_035.txt, 10_medium_036.txt, 10_medium_037.txt, 10_medium_038.txt, 10_medium_039.txt, 10_medium_040.txt, 10_medium_041.txt, 10_medium_042.txt, 10_medium_043.txt, 10_medium_044.txt, 10_medium_045.txt, 10_medium_046.txt, 10_medium_047.txt, 10_medium_048.txt, 10_medium_049.txt, 10_medium_050.txt, 10_medium_051.txt, 10_medium_088.txt, 10_medium_089.txt, 10_medium_090.txt, 10_medium_091.txt, 10_medium_092.txt, 10_medium_093.txt, 10_medium_094.txt, 10_medium_095.txt, 10_medium_096.txt, 10_medium_097.txt, 10_medium_118.txt, 10_medium_119.txt, 10_medium_120.txt, 10_medium_121.txt, 10_medium_122.txt, 10_medium_123.txt, 10_medium_124.txt, 10_medium_125.txt, 10_medium_126.txt, 10_medium_127.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_small_000.txt, 00_small_001.txt, 00_small_002.txt, 00_small_003.txt, 00_small_004.txt, 00_small_005.txt, 00_small_006.txt, 00_small_007.txt, 00_small_008.txt, 00_small_009.txt, 00_small_010.txt, 00_small_011.txt, 00_small_012.txt, 00_small_013.txt, 00_small_014.txt, 00_small_015.txt, 00_small_016.txt, 00_small_017.txt, 00_small_018.txt, 00_small_019.txt, 00_small_020.txt, 00_small_021.txt, 00_small_022.txt, 00_small_023.txt, 00_small_024.txt, 00_small_025.txt, 00_small_078.txt, 00_small_079.txt, 00_small_080.txt, 00_small_081.txt, 00_small_082.txt, 00_small_083.txt, 00_small_084.txt, 00_small_085.txt, 00_small_086.txt, 00_small_087.txt, 00_small_108.txt, 00_small_109.txt, 00_small_110.txt, 00_small_111.txt, 00_small_112.txt, 00_small_113.txt, 00_small_114.txt, 00_small_115.txt, 00_small_116.txt, 00_small_117.txt, 00_teuchi_00.txt, 10_medium_026.txt, 10_medium_027.txt, 10_medium_028.txt, 10_medium_029.txt, 10_medium_030.txt, 10_medium_031.txt, 10_medium_032.txt, 10_medium_033.txt, 10_medium_034.txt, 10_medium_035.txt, 10_medium_036.txt, 10_medium_037.txt, 10_medium_038.txt, 10_medium_039.txt, 10_medium_040.txt, 10_medium_041.txt, 10_medium_042.txt, 10_medium_043.txt, 10_medium_044.txt, 10_medium_045.txt, 10_medium_046.txt, 10_medium_047.txt, 10_medium_048.txt, 10_medium_049.txt, 10_medium_050.txt, 10_medium_051.txt, 10_medium_088.txt, 10_medium_089.txt, 10_medium_090.txt, 10_medium_091.txt, 10_medium_092.txt, 10_medium_093.txt, 10_medium_094.txt, 10_medium_095.txt, 10_medium_096.txt, 10_medium_097.txt, 10_medium_118.txt, 10_medium_119.txt, 10_medium_120.txt, 10_medium_121.txt, 10_medium_122.txt, 10_medium_123.txt, 10_medium_124.txt, 10_medium_125.txt, 10_medium_126.txt, 10_medium_127.txt, 20_large_052.txt, 20_large_053.txt, 20_large_054.txt, 20_large_055.txt, 20_large_056.txt, 20_large_057.txt, 20_large_058.txt, 20_large_059.txt, 20_large_060.txt, 20_large_061.txt, 20_large_062.txt, 20_large_063.txt, 20_large_064.txt, 20_large_065.txt, 20_large_066.txt, 20_large_067.txt, 20_large_068.txt, 20_large_069.txt, 20_large_070.txt, 20_large_071.txt, 20_large_072.txt, 20_large_073.txt, 20_large_074.txt, 20_large_075.txt, 20_large_076.txt, 20_large_077.txt, 20_large_098.txt, 20_large_099.txt, 20_large_100.txt, 20_large_101.txt, 20_large_102.txt, 20_large_103.txt, 20_large_104.txt, 20_large_105.txt, 20_large_106.txt, 20_large_107.txt, 20_large_128.txt, 20_large_129.txt, 20_large_130.txt, 20_large_131.txt, 20_large_132.txt, 20_large_133.txt, 20_large_134.txt, 20_large_135.txt, 20_large_136.txt, 20_large_137.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 43 ms 27500 KB
00_sample_01.txt AC 35 ms 27628 KB
00_sample_02.txt AC 35 ms 28652 KB
00_sample_03.txt AC 37 ms 29164 KB
00_small_000.txt AC 37 ms 27500 KB
00_small_001.txt AC 37 ms 27884 KB
00_small_002.txt AC 37 ms 28012 KB
00_small_003.txt AC 37 ms 28524 KB
00_small_004.txt AC 36 ms 27244 KB
00_small_005.txt AC 36 ms 28012 KB
00_small_006.txt AC 36 ms 27244 KB
00_small_007.txt AC 36 ms 29164 KB
00_small_008.txt AC 36 ms 29164 KB
00_small_009.txt AC 35 ms 28396 KB
00_small_010.txt AC 36 ms 28652 KB
00_small_011.txt AC 36 ms 27628 KB
00_small_012.txt AC 36 ms 27372 KB
00_small_013.txt AC 36 ms 27244 KB
00_small_014.txt AC 36 ms 28652 KB
00_small_015.txt AC 36 ms 27372 KB
00_small_016.txt AC 36 ms 28652 KB
00_small_017.txt AC 36 ms 27628 KB
00_small_018.txt AC 36 ms 27756 KB
00_small_019.txt AC 36 ms 27756 KB
00_small_020.txt AC 36 ms 27628 KB
00_small_021.txt AC 36 ms 28396 KB
00_small_022.txt AC 36 ms 27244 KB
00_small_023.txt AC 36 ms 28908 KB
00_small_024.txt AC 36 ms 27884 KB
00_small_025.txt AC 36 ms 27500 KB
00_small_078.txt AC 37 ms 27884 KB
00_small_079.txt AC 41 ms 28780 KB
00_small_080.txt AC 37 ms 28012 KB
00_small_081.txt AC 37 ms 28652 KB
00_small_082.txt AC 37 ms 29164 KB
00_small_083.txt AC 37 ms 27884 KB
00_small_084.txt AC 37 ms 29292 KB
00_small_085.txt AC 36 ms 27372 KB
00_small_086.txt AC 37 ms 27756 KB
00_small_087.txt AC 37 ms 29164 KB
00_small_108.txt AC 43 ms 28908 KB
00_small_109.txt AC 39 ms 29420 KB
00_small_110.txt AC 39 ms 29676 KB
00_small_111.txt AC 37 ms 28780 KB
00_small_112.txt AC 39 ms 28908 KB
00_small_113.txt AC 37 ms 28524 KB
00_small_114.txt AC 39 ms 29548 KB
00_small_115.txt AC 39 ms 29676 KB
00_small_116.txt AC 39 ms 29292 KB
00_small_117.txt AC 38 ms 29036 KB
00_teuchi_00.txt AC 35 ms 27244 KB
10_medium_026.txt AC 100 ms 33772 KB
10_medium_027.txt AC 91 ms 33388 KB
10_medium_028.txt AC 85 ms 33004 KB
10_medium_029.txt AC 87 ms 33516 KB
10_medium_030.txt AC 85 ms 33132 KB
10_medium_031.txt AC 83 ms 33260 KB
10_medium_032.txt AC 80 ms 33260 KB
10_medium_033.txt AC 77 ms 32748 KB
10_medium_034.txt AC 77 ms 32748 KB
10_medium_035.txt AC 76 ms 33260 KB
10_medium_036.txt AC 78 ms 33260 KB
10_medium_037.txt AC 81 ms 33260 KB
10_medium_038.txt AC 81 ms 33516 KB
10_medium_039.txt AC 74 ms 33132 KB
10_medium_040.txt AC 82 ms 33132 KB
10_medium_041.txt AC 76 ms 33132 KB
10_medium_042.txt AC 73 ms 32748 KB
10_medium_043.txt AC 78 ms 33132 KB
10_medium_044.txt AC 76 ms 33132 KB
10_medium_045.txt AC 76 ms 33132 KB
10_medium_046.txt AC 73 ms 33132 KB
10_medium_047.txt AC 73 ms 32876 KB
10_medium_048.txt AC 74 ms 32748 KB
10_medium_049.txt AC 73 ms 33132 KB
10_medium_050.txt AC 71 ms 32748 KB
10_medium_051.txt AC 75 ms 33132 KB
10_medium_088.txt AC 105 ms 33516 KB
10_medium_089.txt AC 112 ms 33132 KB
10_medium_090.txt AC 108 ms 34028 KB
10_medium_091.txt AC 106 ms 33388 KB
10_medium_092.txt AC 106 ms 33644 KB
10_medium_093.txt AC 107 ms 33132 KB
10_medium_094.txt AC 105 ms 33516 KB
10_medium_095.txt AC 101 ms 33772 KB
10_medium_096.txt AC 106 ms 33644 KB
10_medium_097.txt AC 106 ms 33388 KB
10_medium_118.txt AC 115 ms 33644 KB
10_medium_119.txt AC 120 ms 33900 KB
10_medium_120.txt AC 113 ms 33772 KB
10_medium_121.txt AC 115 ms 33772 KB
10_medium_122.txt AC 115 ms 33388 KB
10_medium_123.txt AC 116 ms 33388 KB
10_medium_124.txt AC 117 ms 33388 KB
10_medium_125.txt AC 118 ms 33644 KB
10_medium_126.txt AC 115 ms 33388 KB
10_medium_127.txt AC 115 ms 33388 KB
20_large_052.txt TLE 2056 ms 140188 KB
20_large_053.txt TLE 2108 ms 140700 KB
20_large_054.txt AC 1458 ms 101148 KB
20_large_055.txt AC 1303 ms 90652 KB
20_large_056.txt AC 1319 ms 90364 KB
20_large_057.txt AC 1264 ms 90140 KB
20_large_058.txt AC 1262 ms 90140 KB
20_large_059.txt AC 1131 ms 79644 KB
20_large_060.txt AC 1283 ms 90268 KB
20_large_061.txt AC 1271 ms 90908 KB
20_large_062.txt AC 1249 ms 90368 KB
20_large_063.txt AC 1268 ms 90268 KB
20_large_064.txt AC 1249 ms 90780 KB
20_large_065.txt AC 1265 ms 90396 KB
20_large_066.txt AC 1245 ms 91420 KB
20_large_067.txt AC 1141 ms 80668 KB
20_large_068.txt AC 1240 ms 90620 KB
20_large_069.txt AC 1266 ms 90524 KB
20_large_070.txt AC 1146 ms 80284 KB
20_large_071.txt AC 1246 ms 90908 KB
20_large_072.txt AC 1115 ms 80156 KB
20_large_073.txt AC 1127 ms 80796 KB
20_large_074.txt AC 1230 ms 91004 KB
20_large_075.txt AC 1119 ms 80284 KB
20_large_076.txt AC 1109 ms 79644 KB
20_large_077.txt AC 1113 ms 79644 KB
20_large_098.txt TLE 2108 ms 141212 KB
20_large_099.txt TLE 2108 ms 139892 KB
20_large_100.txt TLE 2109 ms 141084 KB
20_large_101.txt TLE 2108 ms 140572 KB
20_large_102.txt TLE 2108 ms 140444 KB
20_large_103.txt TLE 2108 ms 140956 KB
20_large_104.txt TLE 2108 ms 140956 KB
20_large_105.txt TLE 2108 ms 140188 KB
20_large_106.txt TLE 2109 ms 141212 KB
20_large_107.txt TLE 2108 ms 139804 KB
20_large_128.txt TLE 2113 ms 141304 KB
20_large_129.txt TLE 2109 ms 140316 KB
20_large_130.txt TLE 2113 ms 140188 KB
20_large_131.txt TLE 2109 ms 140828 KB
20_large_132.txt TLE 2109 ms 140612 KB
20_large_133.txt TLE 2109 ms 141084 KB
20_large_134.txt TLE 2109 ms 140828 KB
20_large_135.txt TLE 2109 ms 140444 KB
20_large_136.txt TLE 2109 ms 141084 KB
20_large_137.txt TLE 2109 ms 140152 KB