結果
問題 | No.1565 Union |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2021-06-26 14:51:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 440 bytes |
コンパイル時間 | 1,432 ms |
コンパイル使用メモリ | 87,096 KB |
実行使用メモリ | 102,672 KB |
最終ジャッジ日時 | 2023-09-07 16:45:40 |
合計ジャッジ時間 | 10,533 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 89 ms
71,544 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 92 ms
71,648 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 88 ms
71,732 KB |
testcase_09 | WA | - |
testcase_10 | AC | 234 ms
86,576 KB |
testcase_11 | AC | 333 ms
95,280 KB |
testcase_12 | AC | 302 ms
88,232 KB |
testcase_13 | AC | 178 ms
82,484 KB |
testcase_14 | AC | 391 ms
92,600 KB |
testcase_15 | WA | - |
testcase_16 | AC | 429 ms
100,552 KB |
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 | - |
ソースコード
from collections import deque n,m = map(int,input().split()) e = [[] for i in range(n)] for _ in range(m): a,b = [int(x)-1 for x in input().split()] e[a].append(b) e[b].append(a) dis = [n+1]*n dis[0] = 0 q = deque([0]) while q: now = q.popleft() for nex in e[now]: if dis[nex] > dis[now]+1: q.append(nex) dis[nex] = dis[now]+1 if dis[-1] == n+1: print(-1) else: print(m-dis[-1])