結果

問題 No.2509 Beam Shateki
ユーザー miya145592miya145592
提出日時 2023-10-21 01:02:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,306 ms / 2,000 ms
コード長 2,281 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 77,120 KB
最終ジャッジ日時 2023-10-21 01:03:48
合計ジャッジ時間 39,973 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
61,992 KB
testcase_01 AC 41 ms
59,288 KB
testcase_02 AC 36 ms
53,564 KB
testcase_03 AC 268 ms
76,716 KB
testcase_04 AC 278 ms
76,716 KB
testcase_05 AC 265 ms
76,716 KB
testcase_06 AC 265 ms
76,712 KB
testcase_07 AC 264 ms
76,716 KB
testcase_08 AC 276 ms
76,716 KB
testcase_09 AC 266 ms
76,716 KB
testcase_10 AC 266 ms
76,708 KB
testcase_11 AC 266 ms
76,716 KB
testcase_12 AC 280 ms
76,716 KB
testcase_13 AC 1,295 ms
76,988 KB
testcase_14 AC 1,280 ms
76,988 KB
testcase_15 AC 1,274 ms
76,988 KB
testcase_16 AC 1,268 ms
76,988 KB
testcase_17 AC 1,266 ms
76,988 KB
testcase_18 AC 1,274 ms
76,988 KB
testcase_19 AC 1,269 ms
76,988 KB
testcase_20 AC 1,269 ms
76,988 KB
testcase_21 AC 1,306 ms
76,988 KB
testcase_22 AC 1,268 ms
76,988 KB
testcase_23 AC 1,272 ms
76,988 KB
testcase_24 AC 1,270 ms
76,988 KB
testcase_25 AC 1,272 ms
76,988 KB
testcase_26 AC 1,273 ms
76,988 KB
testcase_27 AC 1,271 ms
76,988 KB
testcase_28 AC 1,268 ms
76,988 KB
testcase_29 AC 1,268 ms
76,988 KB
testcase_30 AC 1,274 ms
76,988 KB
testcase_31 AC 1,277 ms
76,988 KB
testcase_32 AC 1,268 ms
76,928 KB
testcase_33 AC 135 ms
77,004 KB
testcase_34 AC 402 ms
76,764 KB
testcase_35 AC 662 ms
76,872 KB
testcase_36 AC 240 ms
77,120 KB
testcase_37 AC 116 ms
76,228 KB
testcase_38 AC 252 ms
76,824 KB
testcase_39 AC 232 ms
76,792 KB
testcase_40 AC 439 ms
76,796 KB
testcase_41 AC 83 ms
75,984 KB
testcase_42 AC 292 ms
76,980 KB
testcase_43 AC 808 ms
76,864 KB
testcase_44 AC 976 ms
76,912 KB
testcase_45 AC 228 ms
76,672 KB
testcase_46 AC 328 ms
76,764 KB
testcase_47 AC 955 ms
76,872 KB
testcase_48 AC 345 ms
76,744 KB
testcase_49 AC 506 ms
76,648 KB
testcase_50 AC 583 ms
76,992 KB
testcase_51 AC 140 ms
76,780 KB
testcase_52 AC 448 ms
76,960 KB
testcase_53 AC 59 ms
66,304 KB
testcase_54 AC 56 ms
66,304 KB
testcase_55 AC 62 ms
68,392 KB
testcase_56 AC 62 ms
68,392 KB
testcase_57 AC 63 ms
68,392 KB
testcase_58 AC 62 ms
68,392 KB
testcase_59 AC 60 ms
68,392 KB
testcase_60 AC 65 ms
68,392 KB
testcase_61 AC 61 ms
68,392 KB
testcase_62 AC 60 ms
68,392 KB
testcase_63 AC 60 ms
68,392 KB
権限があれば一括ダウンロードができます

ソースコード

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 dx, dy in [(0, 1), (1, 0), (1, 1), (-1, 1)]:
    if dx==0:
        rng = range(1, H+1)
    elif dy==0:
        rng = range(1, W+1)
    else:
        rng = range(H+W+4)
    for x in rng:
        sco = 0
        S = set()
        if dx==0:
            nx = x
            ny = 0
        elif dy==0:
            nx = 0
            ny = x
        elif dx==1:
            nx = x-(W+2)
            ny = 0
        else:
            nx = x
            ny = 0
        nx+=dx
        ny+=dy
        if dx==0 or dy==0:
            while 1<=nx<=H and 1<=ny<=W:
                sco += A[nx-1][ny-1]
                S.add((nx, ny))
                nx+=dx
                ny+=dy
        else:
            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 dx2, dy2 in [(0, 1), (1, 0), (1, 1), (-1, 1)]:
            if dx2==0:
                rng2 = range(1, H+1)
            elif dy2==0:
                rng2 = range(1, W+1)
            else:
                rng2 = range(H+W+4)
            for x2 in rng2:
                sco2 = 0
                if dx2==0:
                    nx2 = x2
                    ny2 = 0
                elif dy2==0:
                    nx2 = 0
                    ny2 = x2
                elif dx2==1:
                    nx2 = x2-(W+2)
                    ny2 = 0
                else:
                    nx2 = x2
                    ny2 = 0
                nx2+=dx2
                ny2+=dy2
                if dx2==0 or dy2==0:
                    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:
                    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