結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー lloyzlloyz
提出日時 2021-12-30 12:27:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 666 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2024-04-15 20:01:17
合計ジャッジ時間 2,470 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 29 ms
11,648 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 WA -
testcase_04 AC 29 ms
10,880 KB
testcase_05 WA -
testcase_06 AC 53 ms
12,800 KB
testcase_07 AC 54 ms
12,800 KB
testcase_08 AC 53 ms
12,928 KB
testcase_09 WA -
testcase_10 AC 53 ms
12,928 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 52 ms
12,800 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 31 ms
10,880 KB
testcase_17 AC 30 ms
11,008 KB
testcase_18 WA -
testcase_19 AC 30 ms
11,008 KB
testcase_20 WA -
testcase_21 AC 31 ms
10,880 KB
testcase_22 WA -
testcase_23 AC 28 ms
10,880 KB
testcase_24 AC 26 ms
10,880 KB
testcase_25 AC 28 ms
10,880 KB
testcase_26 AC 28 ms
10,880 KB
testcase_27 WA -
testcase_28 AC 26 ms
11,008 KB
testcase_29 AC 27 ms
10,752 KB
testcase_30 AC 28 ms
10,880 KB
testcase_31 AC 26 ms
10,752 KB
testcase_32 AC 28 ms
10,752 KB
testcase_33 AC 26 ms
10,880 KB
testcase_34 AC 27 ms
10,880 KB
testcase_35 AC 28 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque

n, m = map(int, input().split())
edge = defaultdict(list)
V = [0 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
    V[a] += 1
    V[b] += 1

Que = deque()
seen = set()
for i in range(n):
    if V[i] == 1:
        Que.append(i)

while Que:
    curr = Que.popleft()
    seen.add(curr)
    for np in edge[curr]:
        V[np] -= 1
        if V[np] == 0:
            seen.add(np)
        elif V[np] == 1:
            Que.append(np)

if seen == set(range(n)):
    print("Yes")
else:
    print("No")
0