AtCoder Grand Contest 017

Submission #3449710

Source codeソースコード

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

struct node { int t,next; }a[200010];

int head[100010],f[100010],n,tot;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void add(int x,int y) { a[++tot].t=y;a[tot].next=head[x];head[x]=tot; }

inline void dfs(int x,int y)
{
	f[x]=0;
	for (int i=head[x];i;i=a[i].next)
	{
		int t=a[i].t;
		if (t==y) continue;
		dfs(t,x);f[x]^=f[t]+1;
	}
}

int main()
{
	n=rd();tot=0;
	for (int i=1;i<n;i++) { int x=rd(),y=rd();add(x,y);add(y,x); }
	dfs(1,0);
	puts(f[1]?"Alice":"Bob");
	return 0;
}

Submission

Task問題 D - Game on Tree
User nameユーザ名 DCXDCX
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 1100
Source lengthソースコード長 674 Byte
File nameファイル名
Exec time実行時間 17 ms
Memory usageメモリ使用量 4992 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample1.txt,sample2.txt,sample3.txt,sample4.txt
All 1100 / 1100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
a1.txt AC 1 ms 256 KB
a10.txt AC 2 ms 512 KB
a11.txt AC 2 ms 512 KB
a12.txt AC 2 ms 512 KB
a13.txt AC 15 ms 2560 KB
a14.txt AC 15 ms 2560 KB
a15.txt AC 12 ms 2176 KB
a16.txt AC 15 ms 2688 KB
a17.txt AC 15 ms 2688 KB
a18.txt AC 15 ms 2688 KB
a19.txt AC 15 ms 3072 KB
a2.txt AC 1 ms 256 KB
a20.txt AC 16 ms 3200 KB
a21.txt AC 13 ms 2688 KB
a22.txt AC 15 ms 2560 KB
a23.txt AC 15 ms 2560 KB
a24.txt AC 12 ms 2176 KB
a25.txt AC 15 ms 2688 KB
a26.txt AC 15 ms 2688 KB
a27.txt AC 15 ms 2688 KB
a28.txt AC 16 ms 3072 KB
a29.txt AC 16 ms 3200 KB
a3.txt AC 2 ms 384 KB
a30.txt AC 13 ms 2688 KB
a4.txt AC 2 ms 512 KB
a5.txt AC 2 ms 512 KB
a6.txt AC 2 ms 512 KB
a7.txt AC 2 ms 512 KB
a8.txt AC 2 ms 512 KB
a9.txt AC 2 ms 512 KB
b1.txt AC 17 ms 4992 KB
b2.txt AC 17 ms 3840 KB
b3.txt AC 17 ms 4992 KB
b4.txt AC 17 ms 3840 KB
b5.txt AC 17 ms 3840 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