結果
問題 | No.2509 Beam Shateki |
ユーザー | ntuda |
提出日時 | 2023-10-29 21:10:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,709 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 81,872 KB |
実行使用メモリ | 83,276 KB |
最終ジャッジ日時 | 2023-10-29 21:10:34 |
合計ジャッジ時間 | 14,718 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 136 ms
76,856 KB |
testcase_01 | AC | 120 ms
76,584 KB |
testcase_02 | AC | 72 ms
73,208 KB |
testcase_03 | AC | 911 ms
78,252 KB |
testcase_04 | AC | 939 ms
78,252 KB |
testcase_05 | AC | 938 ms
78,252 KB |
testcase_06 | AC | 930 ms
78,252 KB |
testcase_07 | AC | 912 ms
78,252 KB |
testcase_08 | AC | 952 ms
78,248 KB |
testcase_09 | AC | 940 ms
78,252 KB |
testcase_10 | AC | 909 ms
78,252 KB |
testcase_11 | AC | 933 ms
78,252 KB |
testcase_12 | AC | 938 ms
78,252 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
ソースコード
H, W = map(int, input().split()) A = [[0] * (W + 2)] A += [[0] + list(map(int, input().split())) + [0] for _ in range(H)] A += [[0] * (W + 2)] H += 2 W += 2 N = (H + W) * 9 * 2 D = [] for i in range(-1, 2): for j in range(-1, 2): D.append((i, j)) dic = {} for i, (x, y) in enumerate(D): dic[(-x, -y)] = i ans = 0 def HWC(x): if x < H * 9: return (x // 9, 0) x -= H * 9 if x < H * 9: return (x // 9, W - 1) x -= H * 9 if x < W * 9: return (0, x // 9) x -= W * 9 return (H - 1, x // 9) Q = set() for i in range(N - 1): if i in Q: continue x, y = HWC(i) cnt1 = 0 P = set() dx, dy = D[i % 9] x += dx y += dy while 0 <= x < H and 0 <= y < W and A[x][y] > 0: cnt1 += A[x][y] P.add((x, y)) x += dx y += dy if y == W - 1: Q.add((H + y) * 9 + dic[(dx, dy)]) elif x == 0: Q.add((2 * H + x) * 9 + dic[(dx, dy)]) elif x == H - 1: Q.add((2 * H + W + x) * 9 + dic[(dx, dy)]) for j in range(i + 1, N): if j in Q: continue x, y = HWC(j) cnt2 = 0 dx, dy = D[j % 9] x += dx y += dy while 0 <= x < H and 0 <= y < W and A[x][y] > 0: if (x, y) not in P: cnt2 += A[x][y] x += dx y += dy if y == W - 1: Q.add((H + y) * 9 + dic[(dx, dy)]) elif x == 0: Q.add((2 * H + x) * 9 + dic[(dx, dy)]) elif x == H - 1: Q.add((2 * H + W + x) * 9 + dic[(dx, dy)]) ans = max(ans, cnt1 + cnt2) # print(i, HWC(i), D[i % 9], j, HWC(j), D[j % 9], cnt1, cnt2) print(ans)