結果

問題 No.1565 Union
ユーザー 👑 H20H20
提出日時 2021-06-27 16:13:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 353 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 142,176 KB
最終ジャッジ日時 2023-09-07 18:02:34
合計ジャッジ時間 10,623 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,304 KB
testcase_01 AC 74 ms
71,452 KB
testcase_02 AC 72 ms
71,492 KB
testcase_03 WA -
testcase_04 AC 72 ms
71,260 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 72 ms
71,192 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 360 ms
99,528 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int, input().split())
L = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int, input().split())
    L[b].append(a)
    L[a].append(b)

PASS = [False]*(N+1)

def dfs(p,cnt):
    if p==N:
        print(cnt)
        exit()
    if PASS[p]==False:
        PASS[p]=True
        for n in L[p]:
            dfs(n,cnt+1)

dfs(1,0)
print(-1)

0