QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#280203#7786. Graft and Transplantucup-team2010#WA 0ms3824kbC++17849b2023-12-09 14:23:462023-12-09 14:23:46

Judging History

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

  • [2023-12-09 14:23:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2023-12-09 14:23:46]
  • 提交

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<=2){
        cout<<"Bob";
        return;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(E[i].size()==1)ans++;
    }
    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;
}

詳細信息

Test #1:

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

input:

4
1 2
2 3
3 4

output:

Alice

result:

ok "Alice"

Test #2:

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

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

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

input:

2
1 2

output:

Bob

result:

ok "Bob"

Test #4:

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

input:

3
1 2
1 3

output:

Alice

result:

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