QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354450#7986. 游戏PorNPtree#WA 1ms6148kbC++14825b2024-03-15 13:29:322024-03-15 13:29:33

Judging History

你现在查看的是最新测评结果

  • [2024-03-15 13:29:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6148kb
  • [2024-03-15 13:29:32]
  • 提交

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'