QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707089#7786. Graft and TransplantSDNUyuqiWA 0ms3692kbC++23757b2024-11-03 14:38:582024-11-03 14:39:07

Judging History

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

  • [2024-11-03 14:39:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3692kb
  • [2024-11-03 14:38:58]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define endl "\n"

typedef long long ll;

const int N=100;

vector<int>nx[N];

int si[N];
int an;    int n;

void dfs(int be,int ne)
{
    si[ne]=1;
    for(auto i:nx[ne])
    {
        if(i==be)
        {
            continue;
        }
        dfs(ne,i);
        si[ne]+=si[i];
        if(si[i]>1&&n-si[i]>1)
        {
            an++;
        }
    }
}

int main()
{

    cin>>n;
    for(int i=2;i<=n;i++)
    {
        int u,v;
        cin>>u>>v;
        nx[u].push_back(v);
        nx[v].push_back(u);
    }   
    dfs(0,1);
    if(an)
    {
        cout<<"Alice\n";
    }
    else{
        cout<<"Bob\n";
    }
    //system("pause");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

4
1 2
2 3
3 4

output:

Alice

result:

ok "Alice"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

2
1 2

output:

Bob

result:

ok "Bob"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

3
1 2
1 3

output:

Bob

result:

ok "Bob"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3608kb

input:

5
2 1
2 3
3 4
1 5

output:

Alice

result:

wrong answer 1st words differ - expected: 'Bob', found: 'Alice'