結果
問題 | No.977 アリス仕掛けの摩天楼 |
ユーザー |
![]() |
提出日時 | 2020-01-30 11:18:52 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,195 bytes |
コンパイル時間 | 841 ms |
コンパイル使用メモリ | 68,264 KB |
実行使用メモリ | 37,776 KB |
最終ジャッジ日時 | 2023-10-14 08:21:26 |
合計ジャッジ時間 | 4,403 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 55 ms
21,672 KB |
testcase_04 | AC | 65 ms
21,764 KB |
testcase_05 | AC | 54 ms
21,712 KB |
testcase_06 | AC | 56 ms
21,696 KB |
testcase_07 | AC | 57 ms
19,592 KB |
testcase_08 | AC | 60 ms
21,604 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 55 ms
21,708 KB |
testcase_12 | AC | 59 ms
21,724 KB |
testcase_13 | AC | 71 ms
23,640 KB |
testcase_14 | AC | 68 ms
23,756 KB |
testcase_15 | AC | 66 ms
23,876 KB |
testcase_16 | AC | 67 ms
25,672 KB |
testcase_17 | AC | 65 ms
23,828 KB |
testcase_18 | AC | 98 ms
28,480 KB |
testcase_19 | WA | - |
testcase_20 | AC | 127 ms
30,260 KB |
testcase_21 | AC | 160 ms
33,164 KB |
testcase_22 | AC | 200 ms
37,128 KB |
testcase_23 | WA | - |
testcase_24 | AC | 201 ms
35,628 KB |
testcase_25 | WA | - |
ソースコード
using System; using System.Linq; using System.Collections.Generic; public static class Program{ public static void Main() { int n=int.Parse(Console.ReadLine()); var graph=Enumerable.Range(0,n) .Select(_=>new List<int>()).ToArray(); for(int i=0;i<n-1;i++){ int[]uv=Console.ReadLine().Split().Select(int.Parse).ToArray(); graph[uv[0]].Add(uv[1]); graph[uv[1]].Add(uv[0]); } bool[]ckd=new bool[n]; var que=new Queue<int>(); int counter=0; for(int i=0;i<n;i++){ if(ckd[i])continue; que.Enqueue(i); while(0<que.Count){ int x=que.Dequeue(); ckd[x]=true; foreach(int y in graph[x]){ if(!ckd[y])que.Enqueue(y); } } } if(counter!=2) { Console.WriteLine(counter==1?"Bob":"Alice"); return; } for(int i=0;i<n;i++){ if(graph[i].Count!=0&&graph[i].Count!=2){ Console.WriteLine("Alice"); return; } } Console.WriteLine("Bob"); } }