QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#280192#7786. Graft and Transplantucup-team2010#WA 0ms3872kbC++17847b2023-12-09 14:21:342023-12-09 14:21:34

Judging History

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

  • [2023-12-09 14:21:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2023-12-09 14:21:34]
  • 提交

answer

#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define LNF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
template <class T> using Tree = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
#define pll pair<int,int>
void solve(void){
    ll n;
    cin>>n;
    std::vector<std::vector<int>> E(n+1);
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    if(n<=3){
        cout<<"Bob";
        return;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=(E[i].size()==1);
    }
    cout<<((ans%2==0)?"Alice":"Bob");
}
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t=1;
    // cin>>t;
    while(t--)
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 2
2 3
3 4

output:

Alice

result:

ok "Alice"

Test #2:

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

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

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

input:

2
1 2

output:

Bob

result:

ok "Bob"

Test #4:

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

input:

3
1 2
1 3

output:

Bob

result:

ok "Bob"

Test #5:

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

input:

5
2 1
2 3
3 4
1 5

output:

Alice

result:

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