Skip to content

Commit a182be5

Browse files
committed
Python Algorithm
1 parent 7455b62 commit a182be5

File tree

3 files changed

+95
-31
lines changed

3 files changed

+95
-31
lines changed

.idea/workspace.xml

+31-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BOJ_Python/2868.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
input = lambda :sys.stdin.readline().rstrip()
3+
4+
r, b = map(int, input().split())
5+
6+
for i in range(3, 2000):
7+
for j in range(3, i + 1):
8+
tmp = (i * 2) + (j - 2) * 2
9+
if r == tmp and b == (i * j) - tmp:
10+
print(i, j)

BOJ_Python/3085.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import sys
2+
input = lambda :sys.stdin.readline().rstrip()
3+
4+
n = int(input())
5+
arr = [list(map(str, input())) for _ in range(n)]
6+
res = 0
7+
8+
9+
def check(arr):
10+
cnt = 0
11+
12+
for i in range(n):
13+
cnt_row, cnt_col = 1, 1
14+
for j in range(n - 1):
15+
if arr[i][j] == arr[i][j + 1]:
16+
cnt_row += 1
17+
else:
18+
cnt = max(cnt, cnt_row)
19+
cnt_row = 1
20+
21+
if arr[j][i] == arr[j + 1][i]:
22+
cnt_col += 1
23+
else:
24+
cnt = max(cnt, cnt_col)
25+
cnt_col = 1
26+
cnt = max(cnt, cnt_col, cnt_row)
27+
return cnt
28+
29+
30+
for i in range(n):
31+
for j in range(n - 1):
32+
if arr[i][j] != arr[i][j + 1]: # row
33+
tmp = arr[i][j]
34+
arr[i][j] = arr[i][j + 1]
35+
arr[i][j + 1] = tmp
36+
37+
res = max(res, check(arr))
38+
39+
tmp = arr[i][j]
40+
arr[i][j] = arr[i][j + 1]
41+
arr[i][j + 1] = tmp
42+
43+
if arr[j][i] != arr[j + 1][i]: # col
44+
tmp = arr[j][i]
45+
arr[j][i] = arr[j + 1][i]
46+
arr[j + 1][i] = tmp
47+
48+
res = max(res, check(arr))
49+
50+
tmp = arr[j][i]
51+
arr[j][i] = arr[j + 1][i]
52+
arr[j + 1][i] = tmp
53+
54+
print(res)

0 commit comments

Comments
 (0)