We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 888497e commit 5a25306Copy full SHA for 5a25306
1 file changed
최어진/8주차/260216.py
@@ -0,0 +1,40 @@
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)
0 commit comments