結果

問題 No.2509 Beam Shateki
ユーザー ntudantuda
提出日時 2023-10-28 18:48:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,185 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 76,712 KB
最終ジャッジ日時 2023-10-28 18:48:35
合計ジャッジ時間 22,055 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,576 KB
testcase_01 AC 38 ms
53,576 KB
testcase_02 AC 37 ms
53,576 KB
testcase_03 AC 160 ms
76,252 KB
testcase_04 AC 163 ms
76,392 KB
testcase_05 AC 164 ms
76,388 KB
testcase_06 AC 165 ms
76,392 KB
testcase_07 AC 165 ms
76,392 KB
testcase_08 AC 164 ms
76,252 KB
testcase_09 AC 163 ms
76,252 KB
testcase_10 AC 165 ms
76,392 KB
testcase_11 AC 164 ms
76,392 KB
testcase_12 AC 162 ms
76,252 KB
testcase_13 AC 652 ms
76,712 KB
testcase_14 AC 683 ms
76,708 KB
testcase_15 AC 654 ms
76,708 KB
testcase_16 AC 677 ms
76,708 KB
testcase_17 AC 667 ms
76,408 KB
testcase_18 AC 653 ms
76,708 KB
testcase_19 AC 683 ms
76,508 KB
testcase_20 AC 658 ms
76,400 KB
testcase_21 AC 683 ms
76,400 KB
testcase_22 AC 656 ms
76,520 KB
testcase_23 AC 678 ms
76,708 KB
testcase_24 AC 652 ms
76,712 KB
testcase_25 AC 680 ms
76,500 KB
testcase_26 AC 657 ms
76,712 KB
testcase_27 AC 680 ms
76,708 KB
testcase_28 AC 654 ms
76,708 KB
testcase_29 AC 682 ms
76,488 KB
testcase_30 AC 649 ms
76,712 KB
testcase_31 WA -
testcase_32 AC 661 ms
76,492 KB
testcase_33 AC 98 ms
75,904 KB
testcase_34 AC 220 ms
76,300 KB
testcase_35 AC 364 ms
76,300 KB
testcase_36 AC 137 ms
76,388 KB
testcase_37 AC 62 ms
68,668 KB
testcase_38 AC 154 ms
76,228 KB
testcase_39 AC 156 ms
76,352 KB
testcase_40 AC 239 ms
76,216 KB
testcase_41 AC 53 ms
64,296 KB
testcase_42 AC 152 ms
76,200 KB
testcase_43 AC 435 ms
76,572 KB
testcase_44 AC 525 ms
76,484 KB
testcase_45 AC 131 ms
76,184 KB
testcase_46 AC 166 ms
76,208 KB
testcase_47 AC 494 ms
76,304 KB
testcase_48 AC 194 ms
76,424 KB
testcase_49 AC 270 ms
76,316 KB
testcase_50 AC 309 ms
76,524 KB
testcase_51 AC 81 ms
74,996 KB
testcase_52 AC 227 ms
76,464 KB
testcase_53 AC 45 ms
59,820 KB
testcase_54 AC 45 ms
59,820 KB
testcase_55 AC 53 ms
64,332 KB
testcase_56 AC 52 ms
64,332 KB
testcase_57 AC 52 ms
64,332 KB
testcase_58 WA -
testcase_59 AC 53 ms
64,332 KB
testcase_60 WA -
testcase_61 AC 52 ms
64,332 KB
testcase_62 AC 52 ms
64,332 KB
testcase_63 WA -
権限があれば一括ダウンロードができます

ソースコード

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) * 3
D = [[-1, 1], [0, 1], [1, 1], [1, -1], [1, 0], [1, 1]]
ans = 0
for i in range(N - 1):
    if i < H * 3:
        HW = 0
    else:
        HW = 1
    if HW == 0:
        x = i // 3
        y = 0
    else:
        y = (i - H * 3) // 3
        x = 0
    cnt1 = 0
    P = set()
    dx, dy = D[3 * HW + i % 3]
    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):
        if j < H * 3:
            HW = 0
        else:
            HW = 1
        if HW == 0:
            x = j // 3
            y = 0
        else:
            y = (j - H * 3) // 3
            x = 0
        cnt2 = 0
        dx, dy = D[3 * HW + j % 3]
        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,j,cnt1,cnt2)
print(ans)
0