結果
| 問題 | No.2509 Beam Shateki | 
| コンテスト | |
| ユーザー |  ntuda | 
| 提出日時 | 2023-10-28 18:48:11 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,185 bytes | 
| コンパイル時間 | 263 ms | 
| コンパイル使用メモリ | 82,156 KB | 
| 実行使用メモリ | 77,760 KB | 
| 最終ジャッジ日時 | 2024-09-25 16:32:49 | 
| 合計ジャッジ時間 | 20,731 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 57 WA * 4 | 
ソースコード
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 j < 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)
            
            
            
        