QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#403077 | #7755. Game on a Forest | Godwang | WA | 1ms | 3644kb | C++14 | 849b | 2024-05-01 20:25:52 | 2024-05-01 20:25:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int maxn=100010;
int n;
int head[maxn],tot;
struct edge{
int v,nxt;
}e[maxn*2];
void init(){
tot=0;
for(int i=0;i<=n;i++) head[i]=-1;
}
void addedge(int u,int v){
e[tot].v=v;e[tot].nxt=head[u];
head[u]=tot++;
}
int dp[maxn];
void dfs(int u,int p){
dp[u]=0;
for(int i=head[u];~i;i=e[i].nxt){
int v=e[i].v;
if(v==p) continue;
dfs(v,u);
dp[u]+=dp[v];
}
if(dp[u]==0) dp[u]=1;
else dp[u]--;
}
int main(){
scanf("%d",&n);
int u,v;
init();
for(int i=1;i<n;i++){
scanf("%d%d",&u,&v);
addedge(u,v);
addedge(v,u);
}
dfs(1,1);
if(dp[1]==0) puts("Bob");
else puts("Alice");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3644kb
input:
3 1 1 2
output:
Bob
result:
wrong output format Expected integer, but "Bob" found