QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#793104 | #7786. Graft and Transplant | chenjiaqiy | WA | 1ms | 3640kb | C++20 | 953b | 2024-11-29 16:43:10 | 2024-11-29 16:43:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define x first
#define y second
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
using i64 = long long;
const int mod = 998244353;
const int N = 1e5 + 10, M = 20;
vector<int> g[N];
void solve()
{
int n;
cin >> n;
for (int i = 1; i < n; i++)
{
int u, v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
int cnt = 0;
for (int i = 1; i <= n; i++)
{
if (g[i].size() == 1)
cnt++;
}
if ((n - cnt) & 1)
{
cout << "Bob";
}
else
cout << "Alice";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int _ = 1;
// cin >> _;
while (_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
input:
4 1 2 2 3 3 4
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4 1 2 1 3 1 4
output:
Bob
result:
ok "Bob"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3640kb
input:
2 1 2
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'