結果

問題 No.2509 Beam Shateki
ユーザー miya145592miya145592
提出日時 2023-10-21 00:43:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,170 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 77,884 KB
最終ジャッジ日時 2023-10-21 00:43:34
合計ジャッジ時間 20,894 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,544 KB
testcase_01 AC 40 ms
53,544 KB
testcase_02 AC 39 ms
53,544 KB
testcase_03 AC 190 ms
77,252 KB
testcase_04 AC 195 ms
77,252 KB
testcase_05 AC 191 ms
77,248 KB
testcase_06 AC 211 ms
77,252 KB
testcase_07 AC 192 ms
77,252 KB
testcase_08 AC 191 ms
77,252 KB
testcase_09 AC 191 ms
77,248 KB
testcase_10 AC 195 ms
77,252 KB
testcase_11 AC 194 ms
77,252 KB
testcase_12 AC 192 ms
77,252 KB
testcase_13 AC 510 ms
77,348 KB
testcase_14 AC 531 ms
77,348 KB
testcase_15 AC 505 ms
77,380 KB
testcase_16 AC 505 ms
77,348 KB
testcase_17 AC 508 ms
77,348 KB
testcase_18 AC 508 ms
77,348 KB
testcase_19 AC 511 ms
77,348 KB
testcase_20 AC 503 ms
77,348 KB
testcase_21 WA -
testcase_22 AC 503 ms
77,348 KB
testcase_23 AC 514 ms
77,348 KB
testcase_24 AC 510 ms
77,348 KB
testcase_25 AC 511 ms
77,348 KB
testcase_26 AC 526 ms
77,348 KB
testcase_27 AC 512 ms
77,348 KB
testcase_28 AC 537 ms
77,348 KB
testcase_29 AC 509 ms
77,348 KB
testcase_30 AC 506 ms
77,348 KB
testcase_31 WA -
testcase_32 AC 508 ms
77,348 KB
testcase_33 AC 132 ms
76,616 KB
testcase_34 AC 268 ms
77,332 KB
testcase_35 AC 341 ms
77,356 KB
testcase_36 AC 168 ms
77,276 KB
testcase_37 AC 98 ms
76,052 KB
testcase_38 AC 194 ms
77,256 KB
testcase_39 AC 170 ms
77,300 KB
testcase_40 AC 296 ms
77,264 KB
testcase_41 AC 76 ms
73,120 KB
testcase_42 AC 177 ms
77,212 KB
testcase_43 AC 365 ms
77,508 KB
testcase_44 AC 426 ms
77,380 KB
testcase_45 AC 170 ms
77,232 KB
testcase_46 AC 181 ms
77,168 KB
testcase_47 AC 422 ms
77,884 KB
testcase_48 AC 232 ms
77,860 KB
testcase_49 AC 271 ms
77,416 KB
testcase_50 AC 295 ms
77,876 KB
testcase_51 AC 115 ms
75,972 KB
testcase_52 AC 224 ms
77,460 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 51 ms
62,160 KB
testcase_56 AC 51 ms
62,160 KB
testcase_57 AC 52 ms
62,160 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = 0
for x in range(H+W+4):
    if 0<=x<=H+1:
        dir = [(0, 1), (1, 1), (-1, 1)]
    else:
        dir = [(1, 0), (1, 1), (1, -1)]
    for dx, dy in dir:
        sco = 0
        S = set()
        if dx==0 or dy==0:
            if 0<=x<=H+1:
                nx = x
                ny = 0
            else:
                nx = 0
                ny = x-(H+2)
            nx+=dx
            ny+=dy
            while 1<=nx<=H and 1<=ny<=W:
                sco += A[nx-1][ny-1]
                S.add((nx, ny))
                nx+=dx
                ny+=dy
        else:
            nx = x
            ny = 0
            nx+=dx
            ny+=dy
            while 1<=ny<=W:
                if 1<=nx<=H and 1<=ny<=W:
                    sco += A[nx-1][ny-1]
                    S.add((nx, ny))
                nx+=dx
                ny+=dy


        for x2 in range(x, H+W+4):
            if 0<=x2<=H+1:
                dir2 = [(0, 1), (1, 1), (-1, 1)]
            else:
                dir2 = [(1, 0), (1, 1), (1, -1)]
            for dx2, dy2 in dir2:
                sco2 = 0
                if dx2==0 or dy2==0:
                    if 0<=x2<=H+1:
                        nx2 = x2
                        ny2 = 0
                    else:
                        nx2 = 0
                        ny2 = x2-(H+2)
                    nx2+=dx2
                    ny2+=dy2
                    while 1<=nx2<=H and 1<=ny2<=W:
                        if (nx2, ny2) not in S:
                            sco2 += A[nx2-1][ny2-1]
                        nx2+=dx2
                        ny2+=dy2
                else:
                    nx2 = x2
                    ny2 = 0
                    nx2+=dx2
                    ny2+=dy2
                    while 1<=ny2<=W:
                        if 1<=nx2<=H and 1<=ny2<=W:
                            if (nx2, ny2) not in S:
                                sco2 += A[nx2-1][ny2-1]
                        nx2+=dx2
                        ny2+=dy2


                ans = max(ans, sco+sco2)
print(ans)
0