結果
問題 | No.2100 [Cherry Alpha C] Two-way Steps |
ユーザー | flippergo |
提出日時 | 2024-09-24 09:06:27 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,532 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 115,564 KB |
最終ジャッジ日時 | 2024-09-24 09:07:19 |
合計ジャッジ時間 | 52,263 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
11,008 KB |
testcase_01 | AC | 30 ms
11,008 KB |
testcase_02 | AC | 30 ms
11,008 KB |
testcase_03 | AC | 29 ms
11,008 KB |
testcase_04 | AC | 1,356 ms
83,976 KB |
testcase_05 | AC | 1,040 ms
69,164 KB |
testcase_06 | AC | 174 ms
24,504 KB |
testcase_07 | AC | 216 ms
27,412 KB |
testcase_08 | AC | 1,262 ms
101,012 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 935 ms
70,312 KB |
testcase_12 | WA | - |
testcase_13 | AC | 741 ms
71,188 KB |
testcase_14 | WA | - |
testcase_15 | AC | 808 ms
71,160 KB |
testcase_16 | WA | - |
testcase_17 | AC | 434 ms
61,416 KB |
testcase_18 | AC | 757 ms
72,384 KB |
testcase_19 | AC | 1,500 ms
97,120 KB |
testcase_20 | AC | 302 ms
31,120 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 1,172 ms
83,648 KB |
testcase_24 | AC | 1,671 ms
115,360 KB |
testcase_25 | AC | 1,642 ms
115,436 KB |
testcase_26 | AC | 1,632 ms
115,540 KB |
testcase_27 | AC | 1,646 ms
115,328 KB |
testcase_28 | AC | 1,630 ms
115,256 KB |
testcase_29 | AC | 1,619 ms
115,316 KB |
testcase_30 | AC | 1,634 ms
115,264 KB |
testcase_31 | AC | 1,620 ms
115,328 KB |
testcase_32 | AC | 1,680 ms
115,564 KB |
testcase_33 | AC | 1,656 ms
115,412 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 1,157 ms
42,624 KB |
testcase_40 | AC | 1,167 ms
42,624 KB |
testcase_41 | AC | 1,157 ms
42,624 KB |
testcase_42 | AC | 1,156 ms
42,624 KB |
testcase_43 | AC | 1,183 ms
42,624 KB |
testcase_44 | AC | 1,125 ms
106,116 KB |
testcase_45 | AC | 1,116 ms
106,080 KB |
testcase_46 | AC | 1,104 ms
102,992 KB |
testcase_47 | AC | 1,074 ms
99,660 KB |
ソースコード
from collections import deque N,M = map(int,input().split()) H = [0]+list(map(int,input().split())) G0 = {i:[] for i in range(1,N+1)} Indeg0 = [0]*(N+1) G1 = {i:[] for i in range(1,N+1)} Indeg1 = [0]*(N+1) for _ in range(M): a,b = map(int,input().split()) if b>a: G0[a].append((b,max(H[b]-H[a],0))) Indeg0[b] += 1 G1[b].append((a,max(H[a]-H[b],0))) Indeg1[a] += 1 else: G0[b].append((a,max(H[a]-H[b],0))) Indeg0[a] += 1 G1[a].append((b,max(H[b]-H[a],0))) Indeg1[b] += 1 INFTY = 10**15 dist0 = [[-INFTY,-INFTY] for _ in range(N+1)] que0 = deque([1]) dist0[1] = [0,0] for i in range(2,N+1): if Indeg0[i]==0: for j,_ in G0[i]: Indeg0[j] -= 1 while que0: u = que0.popleft() d0,d1 = dist0[u] for v,d in G0[u]: if d>0: dist0[v][1] = max(dist0[v][1],d0+d) else: dist0[v][0] = max(dist0[v][0],d0,d1) Indeg0[v] -= 1 if Indeg0[v]==0: que0.append(v) dist1 = [[-INFTY,-INFTY] for _ in range(N+1)] que1 = deque([N]) dist1[N] = [0,0] for i in range(1,N): if Indeg1[i]==0: for j,_ in G1[i]: Indeg1[j] -= 1 while que1: u = que1.popleft() d0,d1 = dist1[u] for v,d in G1[u]: if d>0: dist1[v][1] = max(dist1[v][1],d0+d) else: dist1[v][0] = max(dist1[v][0],d0,d1) Indeg1[v] -= 1 if Indeg1[v]==0: que1.append(v) print(max(max(dist0[N]),-1)) print(max(max(dist1[1]),-1))