QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#280174 | #7786. Graft and Transplant | ucup-team2010# | WA | 0ms | 3784kb | C++17 | 851b | 2023-12-09 14:15:50 | 2023-12-09 14:15:51 |
Judging History
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++){
if(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: 3504kb
input:
4 1 2 2 3 3 4
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
4 1 2 1 3 1 4
output:
Bob
result:
ok "Bob"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2 1 2
output:
Bob
result:
ok "Bob"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
3 1 2 1 3
output:
Bob
result:
ok "Bob"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3656kb
input:
5 2 1 2 3 3 4 1 5
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'