結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-21 23:02:32
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,456 bytes
コンパイル時間 14,524 ms
コンパイル使用メモリ 158,356 KB
実行使用メモリ 179,788 KB
最終ジャッジ日時 2024-02-21 23:02:53
合計ジャッジ時間 20,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
32,932 KB
testcase_01 AC 81 ms
33,188 KB
testcase_02 AC 86 ms
32,932 KB
testcase_03 AC 84 ms
32,932 KB
testcase_04 AC 82 ms
32,804 KB
testcase_05 AC 91 ms
35,108 KB
testcase_06 AC 91 ms
35,108 KB
testcase_07 AC 90 ms
35,108 KB
testcase_08 AC 91 ms
35,108 KB
testcase_09 AC 91 ms
35,108 KB
testcase_10 AC 116 ms
35,108 KB
testcase_11 AC 91 ms
35,108 KB
testcase_12 AC 91 ms
35,108 KB
testcase_13 AC 90 ms
35,108 KB
testcase_14 AC 84 ms
33,060 KB
testcase_15 AC 84 ms
33,060 KB
testcase_16 AC 85 ms
33,060 KB
testcase_17 AC 85 ms
33,060 KB
testcase_18 AC 85 ms
33,060 KB
testcase_19 AC 85 ms
33,060 KB
testcase_20 AC 85 ms
33,060 KB
testcase_21 AC 87 ms
33,060 KB
testcase_22 AC 89 ms
33,060 KB
testcase_23 AC 84 ms
32,932 KB
testcase_24 AC 82 ms
32,804 KB
testcase_25 AC 85 ms
32,932 KB
testcase_26 AC 84 ms
32,932 KB
testcase_27 AC 85 ms
32,932 KB
testcase_28 AC 83 ms
32,804 KB
testcase_29 AC 82 ms
32,804 KB
testcase_30 AC 82 ms
32,804 KB
testcase_31 AC 83 ms
32,804 KB
testcase_32 AC 82 ms
32,804 KB
testcase_33 AC 83 ms
32,804 KB
testcase_34 AC 83 ms
32,804 KB
testcase_35 AC 83 ms
179,788 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var map = NMap(m);
        var tree = new HashSet<int>[n];
        for (var i = 0; i < tree.Length; ++i) tree[i] = new HashSet<int>();
        foreach (var edge in map)
        {
            tree[edge[0]].Add(edge[1]);
            tree[edge[1]].Add(edge[0]);
        }
        var ans = 0;
        var q = new Queue<int>();
        for (var i = 0; i < n; ++i) if (tree[i].Count == 1) q.Enqueue(i);
        while (q.Count > 0)
        {
            var cur = q.Dequeue();
            if (tree[cur].Count != 1) continue;
            var list = new List<int>(tree[cur]);
            foreach (var li in list)
            {
                tree[cur].Remove(li);
                tree[li].Remove(cur);
                ++ans;
                if (tree[li].Count == 1) q.Enqueue(li);
            }
        }
        WriteLine(ans % 2 == 1 ? "Yes" : "No");
    }
}
0