結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー nebukuro09nebukuro09
提出日時 2021-07-21 21:26:40
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 1,242 ms
コンパイル使用メモリ 103,664 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-04 13:19:02
合計ジャッジ時間 2,952 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 7 ms
4,380 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 8 ms
4,384 KB
testcase_08 AC 7 ms
4,384 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 7 ms
4,384 KB
testcase_12 AC 7 ms
4,384 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,504 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 1 ms
4,384 KB
testcase_35 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        G[u] ~= v;
        G[v] ~= u;
    }

    auto q = new DList!int;
    foreach (i; 0..N) if (G[i].length == 1) q.insertBack(i);
    int ans = 0;

    while (!q.empty) {
        auto n = q.front;
        q.removeFront;
        if (G[n].length != 1) continue;
        ans += 1;
        auto m = G[n][0];
        G[n].popBack;
        foreach (i; 0..G[m].length.to!int) if (G[m][i] == n) {
            swap(G[m][i], G[m].back);
            G[m].popBack;
            if (G[m].length == 1) {
                q.insertBack(m);
            }
            break;
        }
    }

    writeln(ans % 2 ? "Yes" : "No");
}
0