File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ # 백준 2866번: 문자열 잘라내기
2+
3+ import sys
4+
5+ input = sys .stdin .readline
6+
7+ # R, C <= 10^3
8+ R , C = map (int , input ().rstrip ().split ())
9+ table = [list (input ().rstrip ()) for _ in range (R )]
10+
11+ def check_duplication (start_R ): # 10^6
12+ dictionary = set ()
13+ # print(start_R)
14+
15+ for c in range (C ):
16+ string = ''
17+ for r in range (start_R , R ):
18+ string += table [r ][c ]
19+ # print(string)
20+ if string in dictionary :
21+ # print(False)
22+ return False
23+ dictionary .add (string )
24+ # print(True)
25+ # print()
26+ return True
27+
28+ answer = 0
29+ start , end = 0 , R - 1
30+ while start <= end :
31+ middle = (start + end ) // 2
32+ # print(middle)
33+
34+ if not check_duplication (middle ):
35+ end = middle - 1
36+ else :
37+ answer = max (answer , middle )
38+ start = middle + 1
39+
40+ print (answer )
You can’t perform that action at this time.
0 commit comments