Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 committed Oct 22, 2023
1 parent 8ad81d9 commit 99c0eac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Round 2/ready_go_part_1.py3
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ def ready_go_part_1():
q = new_q
for i, j in adj:
lookup[i][j] = False
return len(adj) == 1
return adj

R, C = list(map(int, input().split()))
A = [list(input()) for _ in range(R)]
lookup = [[A[i][j] == 'B' for j in range(C)] for i in range(R)]
return "YES" if any(bfs(i, j) for i in range(R) for j in range(C) if A[i][j] == 'W' and not lookup[i][j]) else "NO"
for i in range(R):
for j in range(C):
if not (A[i][j] == 'W' and not lookup[i][j]):
continue
adj = bfs(i, j)
if len(adj) == 1:
return "YES"
return "NO"

DIRECTIONS = ((1, 0), (0, 1), (-1, 0), (0, -1))
for case in range(int(input())):
Expand Down
12 changes: 7 additions & 5 deletions Round 2/ready_go_part_2.py3
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ def ready_go_part_2():
q = new_q
for i, j in adj:
lookup[i][j] = False
if len(adj) == 1:
i, j = adj[0]
dp[i][j] += cnt
return adj, cnt

R, C = list(map(int, input().split()))
A = [list(input()) for _ in range(R)]
dp = [[0]*C for _ in range(R)]
lookup = [[A[i][j] == 'B' for j in range(C)] for i in range(R)]
for i in range(R):
for j in range(C):
if A[i][j] == 'W' and not lookup[i][j]:
bfs(i, j)
if not (A[i][j] == 'W' and not lookup[i][j]):
continue
adj, cnt = bfs(i, j)
if len(adj) == 1:
i, j = adj[0]
dp[i][j] += cnt
return max(x for row in dp for x in row)

DIRECTIONS = ((1, 0), (0, 1), (-1, 0), (0, -1))
Expand Down

0 comments on commit 99c0eac

Please sign in to comment.