QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#731296 | #2376. Game on a Tree | LaVuna47 | WA | 1ms | 3728kb | C++20 | 1.4kb | 2024-11-10 01:50:31 | 2024-11-10 01:50:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
#ifdef ONPC
mt19937 rnd(228);
#endif
const int N = 1e5 + 47;
vector<int> g[N];
int dp[N];
void dfs(int v, int p)
{
int sm = 0;
for (int to: g[v])
{
if (to != p)
dfs(to, v);
sm += dp[to];
}
if (sm == 0)
dp[v] = 1;
else
dp[v] = sm - 1;
}
int solve()
{
int n;
if (!(cin >> n))
return 1;
fill(g, g + n, vector<int>());
fill(dp, dp + n, 0);
FOR (i, 0, n - 1)
{
int v, u;
cin >> v >> u;
--v;--u;
g[v].pb(u);
g[u].pb(v);
}
dfs(0, -1);
if (dp[0])
cout << "Bob\n";
else
cout << "Alice\n";
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
break;
#ifdef ONPC
cerr << "_____________________________\n";
#endif
}
#ifdef ONPC
cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3728kb
input:
4 1 2 2 3 3 4
output:
Alice
result:
wrong answer 1st lines differ - expected: 'Bob', found: 'Alice'