結果
問題 |
No.2509 Beam Shateki
|
ユーザー |
|
提出日時 | 2023-10-20 22:00:06 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,195 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 84,376 KB |
最終ジャッジ日時 | 2024-09-20 18:55:12 |
合計ジャッジ時間 | 11,725 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 TLE * 1 -- * 50 |
ソースコード
import sys input = sys.stdin.readline h,w = map(int,input().split()) grid = [] for i in range(h): grid.append(list(map(int,input().split()))) ans = 0 dxy = [[[1,-1],[1,0],[1,1]],[[-1,-1],[-1,0],[-1,1]],[[-1,1],[0,1],[1,1]],[[-1,-1],[0,-1],[1,-1]]] s = set() for j in range(w+2): s.add((0,j,0)) s.add((h,j,1)) for j in range(h+2): s.add((j,0,2)) s.add((j,w,3)) for x,y,e in s: for dx,dy in dxy[e]: temp = 1 cnt = 0 se = set() while 1 <= x+dx*temp <= h and 1 <= y+dy*temp <= w: cnt += grid[x+dx*temp-1][y+dy*temp-1] se.add((x+dx*temp-1,y+dy*temp-1)) temp += 1 if temp == 1: continue for u,v,o in s: if x == u and y == v: continue for dx,dy in dxy[o]: c = 0 temp = 1 while 1 <= u+dx*temp <= h and 1 <= v+dy*temp <= w: if (u+dx*temp-1,v+dy*temp-1) in se: temp += 1 continue c += grid[u+dx*temp-1][v+dy*temp-1] temp += 1 ans = max(ans,cnt+c) print(ans)