Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 committed Dec 17, 2023
1 parent 650e372 commit 105a407
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Final Round/programming_paths_part_1.py3
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ G = [
]
R, C = len(G), len(G[0])
MAX_K = 10000
DEPTHS, _ = bfs(G)
DEPTHS, CNTS = bfs(G)
assert(all(CNTS[r][c] == 1 for candidates in DEPTHS for r, c in candidates))
for K in range(MAX_K+1):
check(generate(K), K)
for case in range(int(input())):
Expand Down
2 changes: 1 addition & 1 deletion Final Round/programming_paths_part_2.py3
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def programming_paths_part_2():

def precompute():
depths, cnts = bfs(G)
assert(all(cnts[r][c] == 1 for candidates in depths for r, c in candidates))
dp = {(0, 0):None}
q = [(0, 0)]
d = 0
Expand All @@ -91,7 +92,6 @@ def precompute():
new_q.append((A, B))
for p in range(1, min(len(depths[d]), 2)+1):
idxs = depths[d][:p]
assert(sum(cnts[r][c] for r, c in idxs)%2 == p%2)
new_A_B = op(A, B, d%2, p%2)
if not (0 <= new_A_B[0] <= MAX_K and 0 <= new_A_B[1] <= MAX_K and new_A_B not in dp):
continue
Expand Down
2 changes: 1 addition & 1 deletion Final Round/programming_paths_part_2_2.py3
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def programming_paths_part_2():

def precompute():
depths, cnts = bfs(G)
assert(all(cnts[r][c] >= 1 for candidates in depths for r, c in candidates))
dp = {(0, 0):None}
q = [(0, 0)]
d = 0
Expand All @@ -95,7 +96,6 @@ def precompute():
if p != 2:
continue
idxs = depths[d][:p]
assert(sum(cnts[r][c] for r, c in idxs)%2 == p%2)
new_A_B = op(A, B, d%2, p%2)
if not (0 <= new_A_B[0] <= MAX_K and 0 <= new_A_B[1] <= MAX_K and new_A_B not in dp):
continue
Expand Down

0 comments on commit 105a407

Please sign in to comment.