QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770310#7986. 游戏ToboWA 0ms3876kbC++201.0kb2024-11-21 21:24:542024-11-21 21:24:55

Judging History

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

  • [2024-11-21 21:24:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3876kb
  • [2024-11-21 21:24:54]
  • 提交

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.'