QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#677736 | #7786. Graft and Transplant | yumingsk# | WA | 0ms | 3616kb | C++20 | 1.2kb | 2024-10-26 13:20:45 | 2024-10-26 13:20:45 |
Judging History
answer
#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";
using namespace std;
const int Mod = 998244353;
using ll = long long;
void solve()
{
int n;
cin >> n;
vector<int> deg(n + 1, 0);
for (int i = 1; i < n; i++)
{
int x, y;
cin >> x >> y;
// cout << x << ' ' << y << '\n';
deg[y]++;
deg[x]++;
}
int cnt = 0;
for (int i = 1; i <= n; i++)
{
if (deg[i] != 1)
cnt++;
// cout << cnt << '\n';
}
// cout << cnt << '\n';
if (cnt & 1)
{
cout << "Bob\n";
}
else
{
cout << "Alice\n";
}
}
int main()
{
IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
clock_t start_time = clock();
#endif
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
#ifndef ONLINE_JUDGE
cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
4 1 2 2 3 3 4
output:
Alice
result:
ok "Alice"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 1 2 1 3 1 4
output:
Bob
result:
ok "Bob"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3532kb
input:
2 1 2
output:
Alice
result:
wrong answer 1st words differ - expected: 'Bob', found: 'Alice'