結果
問題 | No.1190 Points |
ユーザー | titia |
提出日時 | 2020-08-22 15:56:02 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 940 ms / 2,000 ms |
コード長 | 1,211 bytes |
コンパイル時間 | 107 ms |
コンパイル使用メモリ | 10,832 KB |
実行使用メモリ | 46,420 KB |
最終ジャッジ日時 | 2023-08-05 12:59:02 |
合計ジャッジ時間 | 15,668 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
8,664 KB |
testcase_01 | AC | 18 ms
8,652 KB |
testcase_02 | AC | 19 ms
8,840 KB |
testcase_03 | AC | 427 ms
26,572 KB |
testcase_04 | AC | 378 ms
23,272 KB |
testcase_05 | AC | 332 ms
26,348 KB |
testcase_06 | AC | 532 ms
26,968 KB |
testcase_07 | AC | 576 ms
34,612 KB |
testcase_08 | AC | 788 ms
46,420 KB |
testcase_09 | AC | 846 ms
36,932 KB |
testcase_10 | AC | 746 ms
40,036 KB |
testcase_11 | AC | 610 ms
28,964 KB |
testcase_12 | AC | 813 ms
37,296 KB |
testcase_13 | AC | 577 ms
25,576 KB |
testcase_14 | AC | 104 ms
18,452 KB |
testcase_15 | AC | 935 ms
36,672 KB |
testcase_16 | AC | 92 ms
12,032 KB |
testcase_17 | AC | 815 ms
34,552 KB |
testcase_18 | AC | 538 ms
19,948 KB |
testcase_19 | AC | 118 ms
20,120 KB |
testcase_20 | AC | 592 ms
23,392 KB |
testcase_21 | AC | 193 ms
17,072 KB |
testcase_22 | AC | 171 ms
22,912 KB |
testcase_23 | AC | 940 ms
37,400 KB |
testcase_24 | AC | 933 ms
37,264 KB |
testcase_25 | AC | 595 ms
28,188 KB |
testcase_26 | AC | 281 ms
28,136 KB |
testcase_27 | AC | 618 ms
28,180 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)))