Submission #3450638
Source Code Expand
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #define LL long long #define M 200020 using namespace std; namespace IO{ const int BS=(1<<20); int Top=0; char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1; char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;} void flush(){fwrite(OT,1,OS-OT,stdout);} void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;} void write(int x){ if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-'); while(x) SS[++Top]=x%10,x/=10; while(Top) Putchar(SS[Top]+'0'),--Top; } int read(){ int nm=0,fh=1; char cw=Getchar(); for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh; for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0'); return nm*fh; } } using namespace IO; int n,fs[M],nt[M],to[M],tmp; void link(int x,int y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;} int DP(int x,int last){ int sg=0; for(int i=fs[x];i!=-1;i=nt[i]) if(to[i]!=last) sg^=(DP(to[i],x)+1); return sg; } int main(){ n=read(),memset(fs,-1,sizeof(fs)); for(int i=1;i<n;i++){int x=read(),y=read();link(x,y),link(y,x);} puts(DP(1,0)?"Alice":"Bob"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Game on Tree |
User | OYJason |
Language | C++ (GCC 5.4.1) |
Score | 1100 |
Code Size | 1218 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 9344 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 | 2 ms | 2816 KB |
a10.txt | AC | 2 ms | 3072 KB |
a11.txt | AC | 2 ms | 3072 KB |
a12.txt | AC | 2 ms | 3072 KB |
a13.txt | AC | 9 ms | 4608 KB |
a14.txt | AC | 9 ms | 4608 KB |
a15.txt | AC | 7 ms | 4224 KB |
a16.txt | AC | 9 ms | 4864 KB |
a17.txt | AC | 9 ms | 4864 KB |
a18.txt | AC | 9 ms | 4864 KB |
a19.txt | AC | 10 ms | 5632 KB |
a2.txt | AC | 2 ms | 2816 KB |
a20.txt | AC | 10 ms | 5760 KB |
a21.txt | AC | 9 ms | 5248 KB |
a22.txt | AC | 9 ms | 4608 KB |
a23.txt | AC | 8 ms | 4608 KB |
a24.txt | AC | 7 ms | 4224 KB |
a25.txt | AC | 9 ms | 4864 KB |
a26.txt | AC | 9 ms | 4864 KB |
a27.txt | AC | 9 ms | 4864 KB |
a28.txt | AC | 10 ms | 5632 KB |
a29.txt | AC | 10 ms | 5760 KB |
a3.txt | AC | 2 ms | 2816 KB |
a30.txt | AC | 8 ms | 5120 KB |
a4.txt | AC | 2 ms | 2944 KB |
a5.txt | AC | 2 ms | 2944 KB |
a6.txt | AC | 2 ms | 2944 KB |
a7.txt | AC | 2 ms | 2944 KB |
a8.txt | AC | 2 ms | 2944 KB |
a9.txt | AC | 2 ms | 2944 KB |
b1.txt | AC | 12 ms | 9344 KB |
b2.txt | AC | 12 ms | 7040 KB |
b3.txt | AC | 12 ms | 9344 KB |
b4.txt | AC | 11 ms | 6912 KB |
b5.txt | AC | 11 ms | 6912 KB |
sample1.txt | AC | 2 ms | 2816 KB |
sample2.txt | AC | 1 ms | 2816 KB |
sample3.txt | AC | 2 ms | 2816 KB |
sample4.txt | AC | 1 ms | 2816 KB |