QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354450 | #7986. 游戏 | PorNPtree# | WA | 1ms | 6148kb | C++14 | 825b | 2024-03-15 13:29:32 | 2024-03-15 13:29:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> G[N];
int f[N];
void dfs(int x, int fa = -1)
{
if ((int)G[x].size() == 1 && ~fa) {
f[x] = 1e9;
} else {
for (auto v : G[x]) {
if (v != fa) {
dfs(v, x);
f[x] += min(f[v], 1);
}
}
f[x] = max(f[x] - 1, 0);
}
return;
}
signed main()
{
int n;
scanf("%d", &n);
if (n == 1) {
puts("Wasted");
return 0;
}
for (int i = 1, x, y; i < n; ++i) {
scanf("%d%d", &x, &y);
G[x].push_back(y);
G[y].push_back(x);
}
dfs(1);
if (f[1] > 0) {
puts("You win, temporarily.");
} else {
puts("Wasted.");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5968kb
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: 6148kb
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: 1ms
memory: 5904kb
input:
1
output:
Wasted
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'Wasted'