Submission #2708843


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int n, x, y;

int dp[MAXN];

void dfs(int nd, int f)
{
	for (int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == f) continue;
		dfs(to, nd), dp[nd] ^= dp[to]+1;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 2; i <= n; i++) {
		cin >> x >> y;
		push(x, y), push(y, x);
	}
	dfs(1, 0);
	if (dp[1] != 0) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Game on Tree
User ljt12138
Language C++14 (GCC 5.4.1)
Score 1100
Code Size 686 Byte
Status AC
Exec Time 26 ms
Memory 7296 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1100 / 1100
Status
AC × 4
AC × 43
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 1 ms 256 KB
a10.txt AC 3 ms 640 KB
a11.txt AC 3 ms 640 KB
a12.txt AC 3 ms 640 KB
a13.txt AC 22 ms 2688 KB
a14.txt AC 21 ms 2688 KB
a15.txt AC 17 ms 2176 KB
a16.txt AC 22 ms 2816 KB
a17.txt AC 22 ms 2816 KB
a18.txt AC 22 ms 2816 KB
a19.txt AC 22 ms 3584 KB
a2.txt AC 2 ms 256 KB
a20.txt AC 23 ms 3712 KB
a21.txt AC 19 ms 3072 KB
a22.txt AC 22 ms 2688 KB
a23.txt AC 22 ms 2688 KB
a24.txt AC 17 ms 2176 KB
a25.txt AC 22 ms 2816 KB
a26.txt AC 22 ms 2816 KB
a27.txt AC 22 ms 2816 KB
a28.txt AC 22 ms 3584 KB
a29.txt AC 23 ms 3712 KB
a3.txt AC 2 ms 384 KB
a30.txt AC 19 ms 3072 KB
a4.txt AC 3 ms 512 KB
a5.txt AC 3 ms 512 KB
a6.txt AC 3 ms 512 KB
a7.txt AC 3 ms 512 KB
a8.txt AC 3 ms 512 KB
a9.txt AC 3 ms 512 KB
b1.txt AC 26 ms 7296 KB
b2.txt AC 25 ms 4992 KB
b3.txt AC 26 ms 7296 KB
b4.txt AC 24 ms 4992 KB
b5.txt AC 25 ms 4992 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB
sample4.txt AC 1 ms 256 KB