結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー brthyyjpbrthyyjp
提出日時 2021-07-22 18:01:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 79,000 KB
最終ジャッジ日時 2023-09-24 20:40:16
合計ジャッジ時間 6,494 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,320 KB
testcase_01 AC 102 ms
76,680 KB
testcase_02 AC 98 ms
71,440 KB
testcase_03 AC 94 ms
71,648 KB
testcase_04 AC 93 ms
71,684 KB
testcase_05 AC 130 ms
78,904 KB
testcase_06 AC 125 ms
79,000 KB
testcase_07 AC 123 ms
78,868 KB
testcase_08 AC 126 ms
78,848 KB
testcase_09 AC 123 ms
78,188 KB
testcase_10 AC 126 ms
78,892 KB
testcase_11 AC 123 ms
78,632 KB
testcase_12 AC 120 ms
78,180 KB
testcase_13 AC 121 ms
78,804 KB
testcase_14 AC 92 ms
71,448 KB
testcase_15 AC 95 ms
71,484 KB
testcase_16 AC 92 ms
71,560 KB
testcase_17 AC 93 ms
71,432 KB
testcase_18 AC 96 ms
71,252 KB
testcase_19 AC 97 ms
71,556 KB
testcase_20 AC 95 ms
71,256 KB
testcase_21 AC 93 ms
71,444 KB
testcase_22 AC 94 ms
71,632 KB
testcase_23 AC 89 ms
71,448 KB
testcase_24 AC 91 ms
71,444 KB
testcase_25 AC 92 ms
71,344 KB
testcase_26 AC 93 ms
71,560 KB
testcase_27 AC 92 ms
71,312 KB
testcase_28 AC 91 ms
71,428 KB
testcase_29 AC 93 ms
71,712 KB
testcase_30 AC 95 ms
71,604 KB
testcase_31 AC 94 ms
71,548 KB
testcase_32 AC 92 ms
71,556 KB
testcase_33 AC 91 ms
71,580 KB
testcase_34 AC 92 ms
71,480 KB
testcase_35 AC 93 ms
71,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, m = map(int, input().split())
g = [[] for i in range(n)]
ind = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)
    ind[a] += 1
    ind[b] += 1

from collections import deque
def cycle_detectable_topological_sort(g, ind):
    V = len(g)
    order = []
    depth = [-1]*V
    q = deque([])
    for i in range(V):
        if ind[i] == 1:
            depth[i] = 0
            q.append(i)
    while q:
        v = q.popleft()
        if ind[v] == 1:
            order.append(v)
        cur_depth = depth[v]
        for u in g[v]:
            ind[u] -= 1
            if ind[u] == 1:
                depth[u] = max(depth[u], cur_depth+1)
                q.append(u)
    return order, depth

order, depth = cycle_detectable_topological_sort(g, ind)
if len(order)%2 == 1:
    print('Yes')
else:
    print('No')
0