結果
問題 | No.323 yuki国 |
ユーザー | rpy3cpp |
提出日時 | 2015-12-16 23:15:58 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,135 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-16 06:02:26 |
合計ジャッジ時間 | 2,584 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,880 KB |
testcase_01 | AC | 30 ms
10,752 KB |
testcase_02 | AC | 28 ms
10,880 KB |
testcase_03 | AC | 28 ms
10,880 KB |
testcase_04 | AC | 27 ms
11,008 KB |
testcase_05 | AC | 29 ms
10,752 KB |
testcase_06 | AC | 29 ms
10,880 KB |
testcase_07 | WA | - |
testcase_08 | AC | 31 ms
10,752 KB |
testcase_09 | AC | 36 ms
11,008 KB |
testcase_10 | AC | 26 ms
10,880 KB |
testcase_11 | AC | 26 ms
10,880 KB |
testcase_12 | AC | 27 ms
10,880 KB |
testcase_13 | AC | 35 ms
10,880 KB |
testcase_14 | AC | 27 ms
10,880 KB |
testcase_15 | AC | 49 ms
11,008 KB |
testcase_16 | AC | 36 ms
11,008 KB |
testcase_17 | AC | 34 ms
11,136 KB |
testcase_18 | AC | 29 ms
10,880 KB |
testcase_19 | AC | 26 ms
10,880 KB |
testcase_20 | AC | 28 ms
10,752 KB |
testcase_21 | AC | 28 ms
10,752 KB |
testcase_22 | AC | 34 ms
11,008 KB |
testcase_23 | AC | 29 ms
10,880 KB |
testcase_24 | AC | 39 ms
11,008 KB |
testcase_25 | AC | 29 ms
10,752 KB |
testcase_26 | AC | 37 ms
10,880 KB |
testcase_27 | AC | 27 ms
10,880 KB |
testcase_28 | AC | 42 ms
10,880 KB |
testcase_29 | AC | 42 ms
11,008 KB |
testcase_30 | AC | 27 ms
11,008 KB |
testcase_31 | AC | 27 ms
10,880 KB |
testcase_32 | AC | 28 ms
10,752 KB |
testcase_33 | AC | 28 ms
10,880 KB |
testcase_34 | AC | 28 ms
10,752 KB |
testcase_35 | AC | 27 ms
10,880 KB |
testcase_36 | AC | 28 ms
10,752 KB |
testcase_37 | WA | - |
ソースコード
def read_data(): H, W = map(int, input().split()) A, Si, Sj = map(int, input().split()) B, Gi, Gj = map(int, input().split()) Ms = [[c == '*' for c in input()] for i in range(H)] return H, W, A, Si, Sj, B, Gi, Gj, Ms def solve(H, W, A, Si, Sj, B, Gi, Gj, Ms): if (A - B + (Si - Gi) + (Sj - Gj)) % 2: return False lower = [[float('inf')] * W for h in range(H)] upper = [[-1] * W for h in range(H)] lower[Si][Sj] = A upper[Si][Sj] = A fs = set([(Si, Sj)]) while fs: nfs = set() for i, j in fs: m = Ms[i][j] min_snow = lower[i][j] max_snow = upper[i][j] for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]: ni = i + di nj = j + dj if ni < 0 or ni >= H or nj < 0 or nj >= W: continue if update_status(m, min_snow, max_snow, ni, nj, upper, lower, Ms): nfs.add((ni, nj)) if lower[Gi][Gj] <= B and upper[Gi][Gj] >= B: return True fs = nfs return False def update_status(m, min_snow, max_snow, ni, nj, upper, lower, Ms): n_m = Ms[ni][nj] if m != n_m: n_min_snow = min_snow + 2 * n_m - 1 if n_min_snow == 0: n_min_snow = float('inf') n_max_snow = max_snow + 2 * n_m - 1 if n_max_snow <= 0: n_max_snow = -1 elif n_m: n_min_snow = min_snow + 1 n_max_snow = float('inf') else: if min_snow == 1: n_min_snow = float('inf') elif min_snow % 2: n_min_snow = 2 else: n_min_snow = 1 n_max_snow = max_snow - 1 if n_max_snow <= 0: n_max_snow = -1 changed = False if n_min_snow < lower[ni][nj]: lower[ni][nj] = n_min_snow changed = True if n_max_snow > upper[ni][nj]: upper[ni][nj] = n_max_snow changed = True return changed H, W, A, Si, Sj, B, Gi, Gj, Ms = read_data() if solve(H, W, A, Si, Sj, B, Gi, Gj, Ms): print('Yes') else: print('No')