結果

問題 No.2509 Beam Shateki
ユーザー nikoro256nikoro256
提出日時 2023-10-20 23:41:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,382 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 335,096 KB
最終ジャッジ日時 2023-10-20 23:42:13
合計ジャッジ時間 39,699 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
A=[]
A.append([0]*(H+2))
for i in range(H):
    A.append([0]+list(map(int,input().split()))+[0])
A.append([0]*(H+2))
starts=[]
for i in range(H+1):
    for j in range(W+1):
        for dx in range(-1,2):
            for dy in range(-1,2):
                if i==H+1 or i==0 or j==0 or j==W+1:
                    if 1<=i+dx<=H and  1<=j+dy<=W:
                        starts.append([i,j,dx,dy])
pos_to_ans={}
for i,j,dx,dy in starts:
    ans=0
    i2,j2=i,j
    while 1<=i2+dx<=H and 1<=j2+dy<=W:
        i2+=dx
        j2+=dy
        ans+=A[i2][j2]
    pos_to_ans[(i,j,dx,dy)]=ans
dic={}
Set=set()
for i in range(1,H):
    for j in range(1,W):
        last=[]
        for dx in range(-1,2):
            for dy in range(-1,2):
                if dx==dy==0:
                    continue
                i2,j2=i,j
                while 1<=i2<=H and 1<=j2<=W:
                    i2+=dx
                    j2+=dy
                last.append((i2,j2,dx,dy))
        for x1,y1,dx1,dy1 in last:
            for x2,y2,dx2,dy2 in last:
                dic[(x1,y1,dx1,dy1,x2,y2,dx2,dy2)]=A[i][j]
print(dic)
ans=0
for i,j,dx,dy in starts:
    for i2,j2,dx2,dy2 in starts:
        ans_d=pos_to_ans[(i,j,dx,dy)]+pos_to_ans[(i2,j2,dx2,dy2)]
        ge=dic.get((i,j,dx,dy,i2,j2,dx2,dy2))
        if ge!=None:
            ans_d-=ge
        ans=max(ans,ans_d)
print(ans)
0