QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#389435 | #7986. 游戏 | O_start# | WA | 2ms | 8536kb | C++14 | 689b | 2024-04-14 13:19:05 | 2024-04-14 13:19:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX (int)2e5+100
vector<int> e[MAX];
int n;
int dfs(int now, int fa)
{
int cnt = 0;
int tot = 0;
for (auto it = e[now].begin(); it != e[now].end(); it++) {
if (*it == fa)
continue;
cnt += dfs(*it, now);
tot++;
}
if (tot == 0)
return 1;
if (cnt >= 2)
return 1;
//printf("%d\n", now);
return 0;
}
int main()
{
int i, j, k;
cin >> n;
for (i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
e[u].push_back(v);
e[v].push_back(u);
}
int res = dfs(1, 0);
if (!res)
printf("Wasted.\n");
else {
printf("You win, temporarily.\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 8536kb
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: 2ms
memory: 8408kb
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: 2ms
memory: 8428kb
input:
1
output:
You win, temporarily.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'