Submission #1608919
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; bool[] B; 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); } B = new bool[N]; int ret = calc(0); WriteLine(ret == 0 ? "Bob" : "Alice"); } int calc(int u) { B[u] = true; int xor = 0; int item = 0; foreach (var v in G[u]) { if (B[v]) continue; xor ^= calc(v); item++; } if (item == 1) xor++; 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 | 0 |
Code Size | 2397 Byte |
Status | WA |
Exec Time | 177 ms |
Memory | 36240 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 26 ms | 11448 KB |
a10.txt | WA | 36 ms | 13792 KB |
a11.txt | AC | 36 ms | 13792 KB |
a12.txt | AC | 36 ms | 15840 KB |
a13.txt | WA | 177 ms | 27404 KB |
a14.txt | WA | 172 ms | 29448 KB |
a15.txt | AC | 136 ms | 22992 KB |
a16.txt | AC | 170 ms | 31756 KB |
a17.txt | WA | 170 ms | 27152 KB |
a18.txt | WA | 174 ms | 25612 KB |
a19.txt | AC | 163 ms | 32984 KB |
a2.txt | WA | 26 ms | 11420 KB |
a20.txt | AC | 170 ms | 27276 KB |
a21.txt | AC | 142 ms | 26948 KB |
a22.txt | WA | 167 ms | 27404 KB |
a23.txt | AC | 167 ms | 28688 KB |
a24.txt | WA | 136 ms | 22992 KB |
a25.txt | WA | 169 ms | 27660 KB |
a26.txt | AC | 167 ms | 27152 KB |
a27.txt | AC | 170 ms | 25612 KB |
a28.txt | WA | 162 ms | 26840 KB |
a29.txt | AC | 170 ms | 27280 KB |
a3.txt | AC | 30 ms | 11420 KB |
a30.txt | AC | 139 ms | 24900 KB |
a4.txt | WA | 36 ms | 15584 KB |
a5.txt | WA | 35 ms | 13536 KB |
a6.txt | AC | 36 ms | 13536 KB |
a7.txt | AC | 36 ms | 13664 KB |
a8.txt | WA | 37 ms | 13664 KB |
a9.txt | WA | 36 ms | 15584 KB |
b1.txt | AC | 174 ms | 35596 KB |
b2.txt | AC | 173 ms | 36240 KB |
b3.txt | AC | 172 ms | 35472 KB |
b4.txt | AC | 170 ms | 36240 KB |
b5.txt | AC | 169 ms | 30096 KB |
sample1.txt | AC | 24 ms | 9300 KB |
sample2.txt | AC | 24 ms | 9300 KB |
sample3.txt | AC | 24 ms | 11348 KB |
sample4.txt | AC | 25 ms | 11348 KB |