QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#403077#7755. Game on a ForestGodwangWA 1ms3644kbC++14849b2024-05-01 20:25:522024-05-01 20:25:53

Judging History

你现在查看的是最新测评结果

  • [2024-05-01 20:25:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-05-01 20:25:52]
  • 提交

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;
}


详细

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