結果

問題 No.2509 Beam Shateki
ユーザー miya145592miya145592
提出日時 2023-10-21 01:02:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,202 ms / 2,000 ms
コード長 2,281 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,808 KB
最終ジャッジ日時 2024-09-21 01:52:07
合計ジャッジ時間 36,606 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
60,800 KB
testcase_01 AC 46 ms
58,496 KB
testcase_02 AC 39 ms
52,736 KB
testcase_03 AC 265 ms
76,936 KB
testcase_04 AC 272 ms
77,020 KB
testcase_05 AC 263 ms
77,144 KB
testcase_06 AC 269 ms
77,028 KB
testcase_07 AC 264 ms
77,148 KB
testcase_08 AC 265 ms
77,280 KB
testcase_09 AC 263 ms
77,028 KB
testcase_10 AC 255 ms
77,016 KB
testcase_11 AC 258 ms
77,020 KB
testcase_12 AC 254 ms
77,016 KB
testcase_13 AC 1,155 ms
77,300 KB
testcase_14 AC 1,165 ms
77,428 KB
testcase_15 AC 1,202 ms
77,544 KB
testcase_16 AC 1,179 ms
77,296 KB
testcase_17 AC 1,190 ms
77,292 KB
testcase_18 AC 1,194 ms
77,296 KB
testcase_19 AC 1,185 ms
77,420 KB
testcase_20 AC 1,201 ms
77,296 KB
testcase_21 AC 1,170 ms
77,288 KB
testcase_22 AC 1,171 ms
77,292 KB
testcase_23 AC 1,168 ms
77,292 KB
testcase_24 AC 1,155 ms
77,424 KB
testcase_25 AC 1,153 ms
77,808 KB
testcase_26 AC 1,165 ms
77,544 KB
testcase_27 AC 1,175 ms
77,292 KB
testcase_28 AC 1,185 ms
77,424 KB
testcase_29 AC 1,181 ms
77,292 KB
testcase_30 AC 1,169 ms
77,424 KB
testcase_31 AC 1,181 ms
77,288 KB
testcase_32 AC 1,162 ms
77,292 KB
testcase_33 AC 141 ms
77,100 KB
testcase_34 AC 376 ms
77,380 KB
testcase_35 AC 631 ms
77,484 KB
testcase_36 AC 241 ms
77,612 KB
testcase_37 AC 120 ms
76,824 KB
testcase_38 AC 237 ms
77,020 KB
testcase_39 AC 234 ms
77,580 KB
testcase_40 AC 444 ms
77,100 KB
testcase_41 AC 94 ms
76,544 KB
testcase_42 AC 293 ms
77,196 KB
testcase_43 AC 770 ms
77,288 KB
testcase_44 AC 941 ms
77,368 KB
testcase_45 AC 233 ms
77,016 KB
testcase_46 AC 328 ms
77,028 KB
testcase_47 AC 894 ms
77,228 KB
testcase_48 AC 325 ms
77,476 KB
testcase_49 AC 501 ms
76,964 KB
testcase_50 AC 553 ms
77,380 KB
testcase_51 AC 138 ms
76,904 KB
testcase_52 AC 409 ms
77,512 KB
testcase_53 AC 62 ms
65,408 KB
testcase_54 AC 63 ms
65,536 KB
testcase_55 AC 70 ms
67,840 KB
testcase_56 AC 69 ms
68,224 KB
testcase_57 AC 70 ms
67,968 KB
testcase_58 AC 69 ms
68,224 KB
testcase_59 AC 66 ms
68,096 KB
testcase_60 AC 68 ms
67,712 KB
testcase_61 AC 65 ms
68,224 KB
testcase_62 AC 65 ms
68,352 KB
testcase_63 AC 67 ms
67,712 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