結果
| 問題 |
No.977 アリス仕掛けの摩天楼
|
| ユーザー |
ngtkana
|
| 提出日時 | 2020-01-30 11:18:52 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,195 bytes |
| コンパイル時間 | 2,069 ms |
| コンパイル使用メモリ | 107,776 KB |
| 実行使用メモリ | 32,756 KB |
| 最終ジャッジ日時 | 2024-09-16 03:28:11 |
| 合計ジャッジ時間 | 3,940 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 8 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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");
}
}
ngtkana