QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627761 | #7986. 游戏 | cjl000 | WA | 1ms | 3672kb | C++23 | 1.3kb | 2024-10-10 17:04:39 | 2024-10-10 17:04:39 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<math.h>
#include<string.h>
#include<deque>
#include<string>
#include<queue>
#include<cstring>
#include<string>
#include<numeric>
#include<bitset>
#include <stack>
using namespace std;
#define lowbit(x) x & ( -x )
#define endl '\n'
#define itn long long
#define int long long
#define ull unsigned long long
const int p = 131;
const ull hx = 2000003;
vector<int>g[200005];
int cnt[200005];
bool bl[200005];
void dfs(int fa, int now)
{
if (g[now].size() == 1)
{
bl[now] = 1;
cnt[now] = 1;
return;
}
for (auto t : g[now])
{
if (t == fa)
continue;
dfs(now, t);
cnt[now] += bl[t];
}
if (cnt[now] >= 2)
bl[now] = 1;
}
void tt()
{
//宽搜
int n;
cin >> n;
for (int i = 1; i < n; i++)
{
int x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
if (g[1].size() == 1)
{
cout << "You win, temporarily." << endl;
return;
}
int root = 1;
g[1].push_back(-1);
dfs(-1, 1);
if (bl[1])
cout << "You win, temporarily." << endl;
else
cout << "Wasted." << endl;
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
tt();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3672kb
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: 1ms
memory: 3596kb
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: 3672kb
input:
1
output:
You win, temporarily.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'