結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー ngtkanangtkana
提出日時 2020-01-30 11:04:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 914 bytes
コンパイル時間 1,074 ms
コンパイル使用メモリ 70,224 KB
実行使用メモリ 37,236 KB
最終ジャッジ日時 2023-10-14 08:20:55
合計ジャッジ時間 5,175 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
23,560 KB
testcase_01 AC 63 ms
23,580 KB
testcase_02 AC 64 ms
23,636 KB
testcase_03 AC 63 ms
21,544 KB
testcase_04 AC 63 ms
23,496 KB
testcase_05 AC 63 ms
21,556 KB
testcase_06 AC 63 ms
23,572 KB
testcase_07 AC 63 ms
23,588 KB
testcase_08 AC 64 ms
21,560 KB
testcase_09 AC 63 ms
21,500 KB
testcase_10 WA -
testcase_11 AC 64 ms
21,636 KB
testcase_12 AC 64 ms
19,644 KB
testcase_13 AC 76 ms
23,712 KB
testcase_14 AC 75 ms
25,652 KB
testcase_15 AC 76 ms
23,812 KB
testcase_16 AC 77 ms
23,580 KB
testcase_17 AC 77 ms
24,692 KB
testcase_18 AC 107 ms
28,376 KB
testcase_19 WA -
testcase_20 AC 141 ms
33,276 KB
testcase_21 AC 185 ms
32,936 KB
testcase_22 AC 223 ms
37,236 KB
testcase_23 AC 264 ms
35,544 KB
testcase_24 AC 251 ms
35,468 KB
testcase_25 AC 268 ms
35,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
想定誤答:連結性だけをみる。
*/

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];
        Action<int>dfs=null;
        dfs=x=>{
            ckd[x]=true;
            foreach(int y in graph[x]){
                if(!ckd[y])dfs(y);
            }
        };
        dfs(0);
        for(int i=0;i<n;i++){
            if(!ckd[i]){
                Console.WriteLine("Alice");
                return;
            }
        }
        Console.WriteLine("Bob");
    }
}
0