-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from AlgoLeadMe/11-H0ngJu
11-H0ngJu
- Loading branch information
Showing
2 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import sys | ||
|
||
def input(): return sys.stdin.readline().rstrip() | ||
|
||
def eat(row, col): | ||
row_cnt = 0 | ||
col_cnt = 0 | ||
tmp_col = 1 | ||
tmp_row = 1 | ||
for idx in range(N-1): | ||
# μ΄μμ λ¨Ήμ λ | ||
if data[row][idx] == data[row][idx+1]: | ||
tmp_col += 1 | ||
col_cnt = max(col_cnt, tmp_col) | ||
else: | ||
tmp_col = 1 | ||
|
||
# νμμ λ¨Ήμ λ | ||
if data[idx][col] == data[idx+1][col]: | ||
tmp_row += 1 | ||
row_cnt = max(row_cnt, tmp_row) | ||
else: | ||
tmp_row = 1 | ||
|
||
return max(row_cnt, col_cnt) | ||
|
||
|
||
N = int(input()) | ||
data = [[x for x in input()] for _ in range(N)] | ||
directions = [(0,-1), (0,1), (-1,0),(1,0)] | ||
cnt = 0 | ||
|
||
for i in range(N): | ||
for k in range(N): | ||
for dir in directions: | ||
dx, dy = dir | ||
x = i+dx | ||
y = k+dy | ||
if 0<=x<N and 0<=y<N: | ||
data[i][k], data[x][y] = data[x][y], data[i][k] | ||
cnt = max(cnt, eat(x,y)) | ||
data[i][k], data[x][y] = data[x][y], data[i][k] #λ€μ λλ리기 | ||
|
||
print(cnt) |