結果

問題 No.2202 贅沢てりたまチキン
ユーザー lloyzlloyz
提出日時 2023-02-03 21:54:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 843 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 1,001 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 138,868 KB
最終ジャッジ日時 2023-09-15 17:39:02
合計ジャッジ時間 8,976 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,544 KB
testcase_01 AC 96 ms
71,724 KB
testcase_02 AC 96 ms
71,784 KB
testcase_03 AC 95 ms
71,772 KB
testcase_04 AC 96 ms
71,780 KB
testcase_05 AC 96 ms
71,328 KB
testcase_06 AC 95 ms
71,828 KB
testcase_07 AC 97 ms
71,620 KB
testcase_08 AC 97 ms
71,592 KB
testcase_09 AC 96 ms
71,488 KB
testcase_10 AC 226 ms
118,828 KB
testcase_11 AC 95 ms
71,820 KB
testcase_12 AC 96 ms
71,824 KB
testcase_13 AC 95 ms
71,492 KB
testcase_14 AC 338 ms
131,972 KB
testcase_15 AC 345 ms
131,876 KB
testcase_16 AC 322 ms
126,656 KB
testcase_17 AC 358 ms
138,868 KB
testcase_18 AC 242 ms
106,720 KB
testcase_19 AC 245 ms
112,840 KB
testcase_20 AC 401 ms
131,896 KB
testcase_21 AC 407 ms
131,888 KB
testcase_22 AC 250 ms
88,876 KB
testcase_23 AC 343 ms
88,624 KB
testcase_24 AC 290 ms
88,616 KB
testcase_25 AC 843 ms
127,064 KB
testcase_26 AC 382 ms
133,244 KB
testcase_27 AC 335 ms
131,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque

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

visited = [[False, False] for _ in range(n)]
for i in range(n):
    if visited[i][0] and visited[i][1]:
        continue
    if visited[i][0] and not visited[i][1]:
        print("No")
        exit()
    if not visited[i][0] and visited[i][1]:
        print("No")
        exit()
    Que = deque([(i, 0)])
    visited[i][0] = True
    while Que:
        cp, cf = Que.popleft()
        nf = 1 ^ cf
        for np in G[cp]:
            if visited[np][nf]:
                continue
            visited[np][nf] = True
            Que.append((np, nf))
for i in range(n):
    if not visited[i][0] or not visited[i][1]:
        print("No")
        exit()
print("Yes")
0