結果

問題 No.977 アリス仕掛けの摩天楼
ユーザー tomomo2b2
提出日時 2020-01-31 21:30:17
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,277 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 105,472 KB
実行使用メモリ 45,692 KB
最終ジャッジ日時 2024-09-17 07:14:21
合計ジャッジ時間 4,267 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

class MyClass
{
    public static void Solve()
    {
        var N = int.Parse(Console.ReadLine());
        var adj = new HashSet<int>[N];
        for (int i = 0; i < N; i++)
        {
            adj[i] = new HashSet<int>();
        }
        for (int i = 0; i < N-1; i++)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var u = input[0];
            var v = input[1];
            adj[u].Add(v);
            adj[v].Add(u);
        }
        var sol = 0;
        var deg1 = 0;
        for (int i = 0; i < N; i++)
        {
            if (adj[i].Count == 0)
            {
                sol++;
            }
            else if (adj[i].Count == 1)
            {
                deg1++;
            }
        }
        if (sol >= 2 || (sol == 1 && deg1 >= 1))
        {
            Console.WriteLine("Alice");
        }
        else
        {
            Console.WriteLine("Bob");
        }
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
0