QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#281341 | #7786. Graft and Transplant | ucup-team2894# | WA | 7ms | 27052kb | C++20 | 952b | 2023-12-10 03:03:22 | 2023-12-10 03:03:23 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;
using pii = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
using lll = __int128;
using pll = pair<ll,ll>;
using vi = vector<int>;
#define fr first
#define sc second
using ld = long double;
#define all(x) (x).begin(), (x).end()
const int maxn = 1e6+10, inf = 1e9+100;
const ll linf = 8e18+100;
const int mod = 998244353;
// #define cerr if(0) cerr
vi g[maxn];
void solve () {
int n;
cin >> n;
for(int i=0;i<n-1;i++){
int a,b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
int rel = 0;
for(int i=0;i<n;i++)if(g[i].size()>1)rel++;
if(n<=2||rel%2==1){
cout << "Bob\n";
}
else {
cout << "Alice\n";
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout<<fixed;
cout.precision(20);
// int tc;
// cin >> tc;
// while(tc--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 27052kb
input:
4 1 2 2 3 3 4
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 6ms
memory: 26884kb
input:
4 1 2 1 3 1 4
output:
Bob
result:
ok "Bob"
Test #3:
score: 0
Accepted
time: 0ms
memory: 26976kb
input:
2 1 2
output:
Bob
result:
ok "Bob"
Test #4:
score: 0
Accepted
time: 0ms
memory: 26876kb
input:
3 1 2 1 3
output:
Bob
result:
ok "Bob"
Test #5:
score: 0
Accepted
time: 7ms
memory: 26828kb
input:
5 2 1 2 3 3 4 1 5
output:
Bob
result:
ok "Bob"
Test #6:
score: 0
Accepted
time: 0ms
memory: 26928kb
input:
6 4 3 4 2 4 5 4 1 4 6
output:
Bob
result:
ok "Bob"
Test #7:
score: -100
Wrong Answer
time: 3ms
memory: 26936kb
input:
7 2 4 4 1 1 5 5 3 3 7 7 6
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'