結果
問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
ユーザー |
![]() |
提出日時 | 2021-07-24 09:25:35 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,458 bytes |
コンパイル時間 | 2,279 ms |
コンパイル使用メモリ | 105,856 KB |
実行使用メモリ | 20,352 KB |
最終ジャッジ日時 | 2024-07-19 09:17:18 |
合計ジャッジ時間 | 3,498 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq; using System.Collections.Generic; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var m = int.Parse(line[1]); var aa = new List<int>[n]; for (int i = 0; i < n; i++) aa[i] = new List<int>(); var es = new int[n]; for (int i = 0; i < m; i++) { line = Console.ReadLine().Trim().Split(' '); var a = int.Parse(line[0]) - 1; var b = int.Parse(line[1]) - 1; aa[a].Add(b); aa[b].Add(a); es[a]++; es[b]++; } getAns(n, aa, es); } static void getAns(int n, List<int>[] aa, int[] es) { var q = new Queue<int>(); var deleted = new bool[n]; for (int i = 0; i < n; i++) { if (es[i] == 1) q.Enqueue(i); } var count = 0; while (q.Count() > 0) { var w = q.Dequeue(); deleted[w] = true; if (es[w] == 0) continue; foreach (var x in aa[w]) { if (deleted[x]) continue; if (es[x] >= 1) { es[x]--; count++; if (es[x] == 1) q.Enqueue(x); } } } Console.WriteLine(count % 2 == 1 ? "Yes" : "No"); } }