Skip to content

Commit

Permalink
Merge pull request #178 from AlgoLeadMe/11-H0ngJu
Browse files Browse the repository at this point in the history
11-H0ngJu
  • Loading branch information
MunbinLee authored May 3, 2024
2 parents ed75d21 + 8808492 commit 3fe0703
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
5 changes: 3 additions & 2 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
| 5μ°¨μ‹œ | 2024.03.16 | κ΅¬ν˜„ | [μš”μ„Έν‘ΈμŠ€ 문제](https://www.acmicpc.net/problem/1158) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/161 |
| 6μ°¨μ‹œ | 2024.03.19 | μŠ€νƒ | [였큰수](https://www.acmicpc.net/problem/17298) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/164 |
| 7μ°¨μ‹œ | 2024.03.22 | DP | [1,2,3 λ”ν•˜κΈ°](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/166 |
| 8μ°¨μ‹œ | 2024.03.16 | DP | [μ‰¬μš΄ 계단 수](https://www.acmicpc.net/problem/10844) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/170 |
| 9μ°¨μ‹œ | 2024.03.22 | DP | [RGB거리 2](https://www.acmicpc.net/problem/17404) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/172 |
| 8μ°¨μ‹œ | 2024.03.16 | DP | [μ‰¬μš΄ 계단 수](https://www.acmicpc.net/problem/10844) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/170 |
| 9μ°¨μ‹œ | 2024.03.22 | DP | [RGB거리 2](https://www.acmicpc.net/problem/17404) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/172 |
| 10μ°¨μ‹œ | 2024.04.03 | BFS | [μˆ¨λ°”κΌ­μ§ˆ 4](https://www.acmicpc.net/problem/13913) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/177 |
| 11μ°¨μ‹œ | 2024.04.07 | κ΅¬ν˜„ | [사탕 κ²Œμž„](https://www.acmicpc.net/problem/9095) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/178 |

---
44 changes: 44 additions & 0 deletions H0ngJu/κ΅¬ν˜„/사탕 κ²Œμž„.py
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)

0 comments on commit 3fe0703

Please sign in to comment.