結果

問題 No.2509 Beam Shateki
ユーザー navel_tosnavel_tos
提出日時 2023-10-20 21:48:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 690 ms / 2,000 ms
コード長 1,289 bytes
コンパイル時間 1,245 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 76,628 KB
最終ジャッジ日時 2023-10-20 21:49:18
合計ジャッジ時間 22,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
55,392 KB
testcase_01 AC 44 ms
55,392 KB
testcase_02 AC 43 ms
55,392 KB
testcase_03 AC 175 ms
76,376 KB
testcase_04 AC 172 ms
76,376 KB
testcase_05 AC 171 ms
76,376 KB
testcase_06 AC 172 ms
76,376 KB
testcase_07 AC 177 ms
76,372 KB
testcase_08 AC 181 ms
76,376 KB
testcase_09 AC 170 ms
76,376 KB
testcase_10 AC 171 ms
76,376 KB
testcase_11 AC 172 ms
76,372 KB
testcase_12 AC 169 ms
76,372 KB
testcase_13 AC 689 ms
76,428 KB
testcase_14 AC 665 ms
76,436 KB
testcase_15 AC 688 ms
76,428 KB
testcase_16 AC 668 ms
76,440 KB
testcase_17 AC 665 ms
76,428 KB
testcase_18 AC 690 ms
76,428 KB
testcase_19 AC 665 ms
76,424 KB
testcase_20 AC 688 ms
76,444 KB
testcase_21 AC 660 ms
76,440 KB
testcase_22 AC 690 ms
76,440 KB
testcase_23 AC 665 ms
76,444 KB
testcase_24 AC 687 ms
76,444 KB
testcase_25 AC 662 ms
76,440 KB
testcase_26 AC 687 ms
76,428 KB
testcase_27 AC 663 ms
76,436 KB
testcase_28 AC 685 ms
76,440 KB
testcase_29 AC 662 ms
76,428 KB
testcase_30 AC 688 ms
76,428 KB
testcase_31 AC 687 ms
76,440 KB
testcase_32 AC 658 ms
76,428 KB
testcase_33 AC 104 ms
75,964 KB
testcase_34 AC 232 ms
76,380 KB
testcase_35 AC 398 ms
76,460 KB
testcase_36 AC 157 ms
76,244 KB
testcase_37 AC 78 ms
74,032 KB
testcase_38 AC 154 ms
76,276 KB
testcase_39 AC 150 ms
76,220 KB
testcase_40 AC 257 ms
76,468 KB
testcase_41 AC 76 ms
72,932 KB
testcase_42 AC 184 ms
76,196 KB
testcase_43 AC 443 ms
76,360 KB
testcase_44 AC 508 ms
76,376 KB
testcase_45 AC 153 ms
76,228 KB
testcase_46 AC 197 ms
76,248 KB
testcase_47 AC 499 ms
76,512 KB
testcase_48 AC 204 ms
76,428 KB
testcase_49 AC 317 ms
76,408 KB
testcase_50 AC 325 ms
76,628 KB
testcase_51 AC 96 ms
76,020 KB
testcase_52 AC 249 ms
76,324 KB
testcase_53 AC 52 ms
61,696 KB
testcase_54 AC 50 ms
61,696 KB
testcase_55 AC 54 ms
64,064 KB
testcase_56 AC 53 ms
64,064 KB
testcase_57 AC 57 ms
64,064 KB
testcase_58 AC 56 ms
64,064 KB
testcase_59 AC 53 ms
64,064 KB
testcase_60 AC 53 ms
64,064 KB
testcase_61 AC 53 ms
64,064 KB
testcase_62 AC 54 ms
64,064 KB
testcase_63 AC 53 ms
64,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder409B

from collections import deque as dq

#入力受取
H,W=map(int,input().split())
A=[[0]*(W+3)]+[[0]+list(map(int,input().split()))+[0]*2 for _ in range(H)]+[[0]*(W+3)]*2

#biimは4方向(テンキー1236方向)にのみ撃てればOK 撃つべき位置を列挙
check=[(h,w) for h in range(H+2) for w in range(W+2) if h in set([0,H+1]) or w in set([0,W+1])]
way=[(-1,-1),(0,-1),(1,-1),(1,0)]

#実際に撃ってみる 処理は「0のマスに侵入したら終了」
ans=0
for i in range(len(check)):  #初発
    sx,sy=check[i]
    for x in range(4):  #方向
        visited=set(); cnt=0; wx,wy=way[x]; nx,ny=sx,sy
        while 1:
            nx,ny=nx+wx,ny+wy
            if A[nx][ny]==0: break
            visited.add((nx,ny)); cnt+=A[nx][ny]
        #変な方向にbiimしていたら打ち切り
        if len(visited)==0: continue

        for j in range(i,len(check)):  #次発
            tx,ty=check[j]
            for y in range(4):
                xx,xy=way[y]; mx,my=tx,ty; cnt2=0
                while 1:
                    mx,my=mx+xx,my+xy
                    if A[mx][my]==0: break
                    if (mx,my) in visited: continue
                    cnt2+=A[mx][my]
                #答えを更新
                ans=max(ans,cnt+cnt2)
print(ans)
0