QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660635#7786. Graft and Transplantiokanux#WA 0ms3664kbC++20917b2024-10-20 12:28:422024-10-20 12:28:43

Judging History

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

  • [2024-10-20 12:28:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-10-20 12:28:42]
  • 提交

answer

#pragma GCC optimize(O2)
#include<bits/stdc++.h>
#define int long long 
using namespace std;
                    
void solve(){
     int n;cin>>n;
     vector<vector<int>>g(n+1);
     vector<pair<int,int>>edges(n+1),st(n+1);
     for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
        edges[i]={min(u,v),max(v,u)};
     }
     int ok=0;
     for(int i=1;i<=n;i++){
        if(g[i].size()==n-1){
            cout<<"Bob\n";
            return;
        }     
        }
     for(int i=1;i<n;i++){
        auto [u,v]=edges[i];
        if(g[v].size()==1&&g[u].size()==1) continue;
        else ok++;
     }
     cout<<((ok&1)?"Alice":"Bob");
}
                   
signed main(){
   ios::sync_with_stdio(false);
   cin.tie(nullptr);cout.tie(nullptr);
   int T=1; 
   //cin>>T;
   while(T--){
      solve();
   }
   return 0;
}

详细

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: 3664kb

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

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

input:

2
1 2

output:

Bob

result:

ok "Bob"

Test #4:

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

input:

3
1 2
1 3

output:

Bob

result:

ok "Bob"

Test #5:

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

input:

5
2 1
2 3
3 4
1 5

output:

Bob

result:

ok "Bob"

Test #6:

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

input:

6
4 3
4 2
4 5
4 1
4 6

output:

Bob

result:

ok "Bob"

Test #7:

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

input:

7
2 4
4 1
1 5
5 3
3 7
7 6

output:

Bob

result:

ok "Bob"

Test #8:

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

input:

8
2 3
3 1
3 6
7 6
6 5
7 8
6 4

output:

Alice

result:

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