QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413369#7986. 游戏XiaoMuchenRE 0ms3712kbC++201.2kb2024-05-17 14:18:182024-05-17 14:18:19

Judging History

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

  • [2024-05-17 14:18:19]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3712kb
  • [2024-05-17 14:18:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define lld long long int
#define ulld unsigned long long int
#define pii pair<int, int>
#define pll pair<lld, lld>
#define pff pair<double, double>

const int dinf = 1e9 + 10;
const lld ldinf = 1e18 + 10;

const int W = 512;
const int N = 1e5 / W + 10;
const int M = 998244353;

int n, cn[N];
vector<int> g[N];

bool dfs(int p, int q)
{
    if (g[p].size() == 1) return true;
    int cnt = 0;
    for (int i = 0; i < g[p].size(); i++)
    {
        if (g[p][i] == q) continue;
        cnt += dfs(g[p][i], p);
    }
    return cnt >= 2;
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cout << (dfs(1, -1) ? "You win, temporarily." : "Wasted.") << endl;
}

#define debug 0
int main()
{
#if debug
    clock_t start = clock();
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
#endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }

#if debug
    cout << endl << "time: " << clock() - start << endl;
#endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

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: 3712kb

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: 0
Accepted
time: 0ms
memory: 3644kb

input:

1

output:

Wasted.

result:

ok single line: 'Wasted.'

Test #4:

score: -100
Runtime Error

input:

100000
86389 1
68115 86389
27661 68115
9669 27661
7343 9669
59420 7343
98078 59420
39321 98078
14847 39321
76863 14847
21104 14847
24241 39321
82708 39321
73282 82708
7424 39321
64358 7424
81481 39321
17105 81481
74205 17105
81202 98078
63636 81202
62429 63636
85827 62429
8648 62429
67963 63636
7287...

output:


result: