結果

問題 No.2509 Beam Shateki
ユーザー ntudantuda
提出日時 2023-10-28 19:13:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,140 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 81,720 KB
最終ジャッジ日時 2023-10-28 19:14:08
合計ジャッジ時間 11,874 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
80,312 KB
testcase_01 AC 88 ms
75,964 KB
testcase_02 AC 67 ms
70,468 KB
testcase_03 AC 734 ms
77,688 KB
testcase_04 AC 751 ms
77,688 KB
testcase_05 AC 731 ms
77,688 KB
testcase_06 AC 722 ms
77,688 KB
testcase_07 AC 737 ms
77,684 KB
testcase_08 AC 740 ms
77,688 KB
testcase_09 AC 750 ms
77,684 KB
testcase_10 AC 730 ms
77,688 KB
testcase_11 AC 723 ms
77,688 KB
testcase_12 AC 734 ms
77,684 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
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)

for i in range(N-1):
    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
    for j in range(i + 1, N):
        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
        ans = max(ans, cnt1 + cnt2)
        #print(i, HWC(i), D[i % 9], j, HWC(j), D[j % 9], cnt1, cnt2)
print(ans)
0