結果

問題 No.2509 Beam Shateki
コンテスト
ユーザー flippergo
提出日時 2026-06-19 15:56:11
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 2,008 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 401 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 88,704 KB
最終ジャッジ日時 2026-06-19 15:56:29
合計ジャッジ時間 4,858 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 60
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

H,W = map(int,input().split())
A = [[0 for _ in range(W+2)]]
for _ in range(H):
    a = [0]+list(map(int,input().split()))
    A.append(a)
C = {}
for i in range(1,H+1):
    for di in [-1,0,1]:
        for dj in [-1,0,1]:
            if di==dj==0:continue
            cnt = A[i][1]
            y = i
            x = 1
            trace = [(i,1)]
            while True:
                if y+di<1 or y+di>H or x+dj<1 or x+dj>W:break
                y += di
                x += dj
                cnt += A[y][x]
                trace.append((y,x))
            C[tuple(trace)]=cnt
    for di in [-1,0,1]:
        for dj in [-1,0,1]:
            if di==dj==0:continue
            cnt = A[i][W]
            y = i
            x = W
            trace = [(y,x)]
            while True:
                if y+di<1 or y+di>H or x+dj<1 or x+dj>W:break
                y += di
                x += dj
                cnt += A[y][x]
                trace.append((y,x))
            C[tuple(trace)] = cnt
for j in range(2,W):
    for di in [-1,0,1]:
        for dj in [-1,0,1]:
            if di==dj==0:continue
            cnt = A[1][j]
            y = 1
            x = j
            trace = [(y,x)]
            while True:
                if y+di<1 or y+di>H or x+dj<1 or x+dj>W:break
                y += di
                x += dj
                cnt += A[y][x]
                trace.append((y,x))
            C[tuple(trace)] = cnt
    for di in [-1,0,1]:
        for dj in [-1,0,1]:
            if di==dj==0:continue
            cnt = A[H][j]
            y = H
            x = j
            trace = [(y,x)]
            while True:
                if y+di<1 or y+di>H or x+dj<1 or x+dj>W:break
                y += di
                x += dj
                cnt += A[y][x]
                trace.append((y,x))
            C[tuple(trace)] = cnt
ans = 0
for a in C:
    for b in C:
        cnt = C[a]
        for y,x in b:
            if (y,x) not in a:
                cnt += A[y][x]
        ans = max(ans,cnt)
print(ans)
0