QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770310 | #7986. 游戏 | Tobo | WA | 0ms | 3876kb | C++20 | 1.0kb | 2024-11-21 21:24:54 | 2024-11-21 21:24:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
bool Memory_begin;
bool Memory_end;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cerr << (&Memory_end - &Memory_begin) / 1048576.0 << "MB" << '\n';
int n;
cin >> n;
vector<vector<int>> adj(n + 1);
for (int i = 1, u, v; i < n; i++)
{
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
vector<int> dp(n + 1);
auto dfs = [&](auto &dfs, int cur, int fa) -> void
{
int son = 0;
for (int i : adj[cur])
{
if (i == fa)
continue;
dfs(dfs, i, cur);
son++;
dp[cur] += dp[i];
}
if (!son)
{
dp[cur] = 1;
return;
}
if (dp[cur] >= 2)
dp[cur] = 1;
else
dp[cur] = 0;
};
dfs(dfs, 1, 0);
if (dp[1])
cout << "You win, temporarily.\n";
else
cout << "Wasted.\n";
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
input:
6 1 2 2 3 2 4 1 5 5 6
output:
Wasted.
result:
ok single line: 'Wasted.'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
7 1 2 2 3 2 4 1 5 5 6 5 7
output:
You win, temporarily.
result:
ok single line: 'You win, temporarily.'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3876kb
input:
1
output:
You win, temporarily.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'