結果
問題 | No.2328 Build Walls |
ユーザー | katonyonko |
提出日時 | 2023-05-28 15:33:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,445 bytes |
コンパイル時間 | 786 ms |
コンパイル使用メモリ | 86,896 KB |
実行使用メモリ | 97,576 KB |
最終ジャッジ日時 | 2023-08-27 12:25:25 |
合計ジャッジ時間 | 8,964 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,072 KB |
testcase_01 | AC | 73 ms
71,080 KB |
testcase_02 | AC | 72 ms
71,184 KB |
testcase_03 | AC | 76 ms
71,112 KB |
testcase_04 | AC | 70 ms
70,932 KB |
testcase_05 | AC | 71 ms
70,832 KB |
testcase_06 | AC | 71 ms
71,308 KB |
testcase_07 | AC | 73 ms
71,120 KB |
testcase_08 | AC | 71 ms
71,236 KB |
testcase_09 | AC | 72 ms
71,312 KB |
testcase_10 | AC | 70 ms
71,264 KB |
testcase_11 | AC | 71 ms
71,084 KB |
testcase_12 | AC | 72 ms
71,256 KB |
testcase_13 | AC | 182 ms
82,988 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 97 ms
77,564 KB |
testcase_20 | WA | - |
testcase_21 | AC | 140 ms
82,764 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 174 ms
87,836 KB |
testcase_29 | WA | - |
testcase_30 | AC | 248 ms
87,996 KB |
testcase_31 | AC | 240 ms
88,148 KB |
testcase_32 | WA | - |
testcase_33 | AC | 318 ms
97,576 KB |
testcase_34 | AC | 247 ms
88,280 KB |
testcase_35 | AC | 336 ms
95,788 KB |
testcase_36 | WA | - |
ソースコード
import io import sys _INPUT = """\ 6 5 4 2 5 7 11 1 6 9 10 3 4 8 12 5 4 2 5 -1 11 -1 6 9 10 3 -1 8 12 5 4 2 5 -1 11 -1 -1 -1 10 3 -1 8 12 """ def solve(test): inf=10**20 H,W=map(int,input().split()) A=[list(map(int,input().split())) for _ in range(H-2)] dp=[inf]*((H-2)*W) def idx(i,j): return i*W+j for i in range(H-2): if A[i][0]!=-1: dp[idx(i,0)]=A[i][0] for j in range(W-1): for i in range(H-2): if A[i][j+1]!=-1: for k,l in [(i-1,j),(i,j),(i+1,j)]: if 0<=k<H-2: dp[idx(i,j+1)]=min(dp[idx(i,j+1)],dp[idx(k,l)]+A[i][j+1]) ans=min([dp[idx(i,W-1)] for i in range(H-2)]) if ans==inf: ans=-1 if test==0: print(ans) else: return None def random_input(): from random import randint,shuffle N=randint(1,10) M=randint(1,N) A=list(range(1,M+1))+[randint(1,M) for _ in range(N-M)] shuffle(A) return (" ".join(map(str, [N,M]))+"\n"+" ".join(map(str, A))+"\n")*3 def simple_solve(): return [] def main(test): if test==0: solve(0) elif test==1: sys.stdin = io.StringIO(_INPUT) case_no=int(input()) for _ in range(case_no): solve(0) else: for i in range(1000): sys.stdin = io.StringIO(random_input()) x=solve(1) y=simple_solve() if x!=y: print(i,x,y) print(*[line for line in sys.stdin],sep='') break #0:提出用、1:与えられたテスト用、2:ストレステスト用 main(0)