Submission #1608925
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; using System.IO; using static System.Console; using Pair = System.Collections.Generic.KeyValuePair<int, int>; //using System.Numerics; using static System.Math; class Program { static void Main() { //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; readonly int mod = 1000000007; readonly string alfa = "abcdefghijklmnopqrstuvwxyz"; readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int N; List<int>[] G; void solve() { N = cin.nextint; G = Enumerable.Range(0, N).Select(i => new List<int>()).ToArray(); for (int i = 0; i < N - 1; i++) { int x = cin.nextint - 1; int y = cin.nextint - 1; G[x].Add(y); G[y].Add(x); } int ret = calc(0, -1); WriteLine(ret == 0 ? "Bob" : "Alice"); } int calc(int u, int par) { int xor = 0; foreach (var v in G[u]) { if (v == par) continue; xor ^= (calc(v, u) + 1); } return xor; } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }
Submission Info
Submission Time | |
---|---|
Task | D - Game on Tree |
User | claw88 |
Language | C# (Mono 4.6.2.0) |
Score | 1100 |
Code Size | 2283 Byte |
Status | AC |
Exec Time | 207 ms |
Memory | 39568 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All | sample1.txt, sample2.txt, sample3.txt, sample4.txt, a1.txt, a10.txt, a11.txt, a12.txt, a13.txt, a14.txt, a15.txt, a16.txt, a17.txt, a18.txt, a19.txt, a2.txt, a20.txt, a21.txt, a22.txt, a23.txt, a24.txt, a25.txt, a26.txt, a27.txt, a28.txt, a29.txt, a3.txt, a30.txt, a4.txt, a5.txt, a6.txt, a7.txt, a8.txt, a9.txt, b1.txt, b2.txt, b3.txt, b4.txt, b5.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
a1.txt | AC | 27 ms | 13496 KB |
a10.txt | AC | 37 ms | 15840 KB |
a11.txt | AC | 37 ms | 13792 KB |
a12.txt | AC | 37 ms | 13792 KB |
a13.txt | AC | 178 ms | 31372 KB |
a14.txt | AC | 176 ms | 27276 KB |
a15.txt | AC | 154 ms | 22864 KB |
a16.txt | AC | 176 ms | 29580 KB |
a17.txt | AC | 174 ms | 29072 KB |
a18.txt | AC | 189 ms | 25612 KB |
a19.txt | AC | 186 ms | 28888 KB |
a2.txt | AC | 27 ms | 9372 KB |
a20.txt | AC | 180 ms | 29200 KB |
a21.txt | AC | 144 ms | 24900 KB |
a22.txt | AC | 178 ms | 29324 KB |
a23.txt | AC | 176 ms | 26640 KB |
a24.txt | AC | 144 ms | 22868 KB |
a25.txt | AC | 183 ms | 27532 KB |
a26.txt | AC | 173 ms | 24976 KB |
a27.txt | AC | 179 ms | 27660 KB |
a28.txt | AC | 169 ms | 28888 KB |
a29.txt | AC | 175 ms | 29200 KB |
a3.txt | AC | 31 ms | 11420 KB |
a30.txt | AC | 155 ms | 28996 KB |
a4.txt | AC | 37 ms | 13536 KB |
a5.txt | AC | 37 ms | 13536 KB |
a6.txt | AC | 37 ms | 15584 KB |
a7.txt | AC | 37 ms | 13552 KB |
a8.txt | AC | 36 ms | 13536 KB |
a9.txt | AC | 36 ms | 11488 KB |
b1.txt | AC | 188 ms | 37516 KB |
b2.txt | AC | 207 ms | 36112 KB |
b3.txt | AC | 184 ms | 39568 KB |
b4.txt | AC | 188 ms | 36112 KB |
b5.txt | AC | 181 ms | 29968 KB |
sample1.txt | AC | 25 ms | 13396 KB |
sample2.txt | AC | 25 ms | 11348 KB |
sample3.txt | AC | 25 ms | 11348 KB |
sample4.txt | AC | 25 ms | 11348 KB |