結果
問題 | No.1190 Points |
ユーザー | titia |
提出日時 | 2020-08-22 15:56:02 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 781 ms / 2,000 ms |
コード長 | 1,211 bytes |
コンパイル時間 | 350 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 47,232 KB |
最終ジャッジ日時 | 2024-04-23 10:12:04 |
合計ジャッジ時間 | 13,909 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
11,008 KB |
testcase_01 | AC | 26 ms
11,008 KB |
testcase_02 | AC | 26 ms
11,008 KB |
testcase_03 | AC | 365 ms
28,416 KB |
testcase_04 | AC | 319 ms
25,472 KB |
testcase_05 | AC | 293 ms
27,648 KB |
testcase_06 | AC | 467 ms
29,184 KB |
testcase_07 | AC | 519 ms
36,096 KB |
testcase_08 | AC | 781 ms
47,232 KB |
testcase_09 | AC | 709 ms
37,632 KB |
testcase_10 | AC | 721 ms
40,704 KB |
testcase_11 | AC | 541 ms
30,336 KB |
testcase_12 | AC | 720 ms
38,016 KB |
testcase_13 | AC | 480 ms
27,008 KB |
testcase_14 | AC | 115 ms
20,608 KB |
testcase_15 | AC | 747 ms
37,760 KB |
testcase_16 | AC | 102 ms
14,592 KB |
testcase_17 | AC | 666 ms
35,712 KB |
testcase_18 | AC | 449 ms
21,504 KB |
testcase_19 | AC | 134 ms
22,144 KB |
testcase_20 | AC | 497 ms
24,960 KB |
testcase_21 | AC | 179 ms
19,456 KB |
testcase_22 | AC | 171 ms
25,216 KB |
testcase_23 | AC | 750 ms
38,272 KB |
testcase_24 | AC | 767 ms
38,400 KB |
testcase_25 | AC | 517 ms
30,336 KB |
testcase_26 | AC | 266 ms
30,208 KB |
testcase_27 | AC | 517 ms
30,208 KB |
ソースコード
import sys input = sys.stdin.readline from collections import deque N,M,P=map(int,input().split()) S,G=map(int,input().split()) E=[[] for i in range(N+1)] for i in range(M): x,y=map(int,input().split()) E[x].append(y) E[y].append(x) SE=[1<<50]*(N+1) SO=[1<<50]*(N+1) GE=[1<<50]*(N+1) GO=[1<<50]*(N+1) SE[S]=0 GE[G]=0 Q=deque([S]) while Q: x=Q.popleft() for to in E[x]: if SE[x]<1<<50 and SO[to]>SE[x]+1: SO[to]=SE[x]+1 Q.append(to) if SO[x]<1<<50 and SE[to]>SO[x]+1: SE[to]=SO[x]+1 Q.append(to) Q=deque([G]) while Q: x=Q.popleft() for to in E[x]: if GE[x]<1<<50 and GO[to]>GE[x]+1: GO[to]=GE[x]+1 Q.append(to) if GO[x]<1<<50 and GE[to]>GO[x]+1: GE[to]=GO[x]+1 Q.append(to) ANS=[] for i in range(1,N+1): if P%2==0: if SE[i]+GE[i]<=P: ANS.append(i) elif SO[i]+GO[i]<=P: ANS.append(i) else: if SE[i]+GO[i]<=P: ANS.append(i) elif SO[i]+GE[i]<=P: ANS.append(i) ANS.sort() if len(ANS)==0: print(-1) else: print(len(ANS)) print("\n".join(map(str,ANS)))