結果
| 問題 |
No.2509 Beam Shateki
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2023-10-28 16:59:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,185 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 77,312 KB |
| 最終ジャッジ日時 | 2024-09-25 16:31:40 |
| 合計ジャッジ時間 | 16,999 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 WA * 11 |
ソースコード
H, W = map(int, input().split())
A = [[0] * (W + 2)]
A += [[0] + list(map(int, input().split())) + [0] for _ in range(H)]
A += [[0] * (W + 2)]
H += 2
W += 2
N = (H + W) * 3
D = [[-1, 1], [0, 1], [1, 1], [1, -1], [1, 0], [1, 1]]
ans = 0
for i in range(N - 1):
if i < H * 3:
HW = 0
else:
HW = 1
if HW == 0:
x = i // 3
y = 0
else:
y = (i - H * 3) // 3
x = 0
cnt1 = 0
P = set()
dx, dy = D[3 * HW + i % 3]
x += dx
y += dy
while 0 <= x < H and 0 <= y < W and A[x][y] > 0:
cnt1 += A[x][y]
P.add((x, y))
x += dx
y += dy
for j in range(i + 1, N):
if i < H * 3:
HW = 0
else:
HW = 1
if HW == 0:
x = j // 3
y = 0
else:
y = (j - H * 3) // 3
x = 0
cnt2 = 0
dx, dy = D[3 * HW + j % 3]
x += dx
y += dy
while 0 <= x < H and 0 <= y < W and A[x][y] > 0:
if (x, y) not in P:
cnt2 += A[x][y]
x += dx
y += dy
ans = max(ans, cnt1 + cnt2)
#print(i,j,cnt1,cnt2)
print(ans)
ntuda