QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#280186 | #7786. Graft and Transplant | ucup-team2010# | WA | 1ms | 3512kb | C++17 | 853b | 2023-12-09 14:19:28 | 2023-12-09 14:19:28 |
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<<"Alice";
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: 1ms
memory: 3508kb
input:
4 1 2 2 3 3 4
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
4 1 2 1 3 1 4
output:
Bob
result:
ok "Bob"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3440kb
input:
2 1 2
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'