結果
| 問題 |
No.2509 Beam Shateki
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-20 21:52:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,150 bytes |
| コンパイル時間 | 453 ms |
| コンパイル使用メモリ | 82,360 KB |
| 実行使用メモリ | 83,556 KB |
| 最終ジャッジ日時 | 2024-09-20 18:31:09 |
| 合計ジャッジ時間 | 8,789 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 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],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
s = set()
for i in [0,h]:
for j in range(w+2):
s.add((i,j))
for i in [0,w]:
for j in range(h+2):
s.add((j,i))
for x,y in s:
for dx,dy in dxy:
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:
break
for u,v in s:
if x == u and y == v:
continue
for dx,dy in dxy:
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)