QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#352644 | #7986. 游戏 | lopzith | WA | 0ms | 8444kb | C++14 | 1.7kb | 2024-03-13 14:49:40 | 2024-03-13 14:49:40 |
Judging History
answer
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
#define int long long
#define i64 long long
#define ull unsigned long long
#define Arr std::vector
#define Ptn std::pair
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define popc(x) __builtin_popcount(x)
#define FILE(x) freopen(x ".in", "r", stdin), freopen(x ".out", "w", stdout)
#define TEST(x) freopen(x ".in", "r", stdin), freopen("test.out", "w", stdout)
#define debug std::cout << "Running on " << __FUNCTION__ << ' ' << __LINE__ << std::endl;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;
int n, f[N][2], fa[N]; // 0 -> I first 1 -> J first
Arr<int> e[N];
inline int read()
{
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
w = (w << 3) + (w << 1) + (ch - 48);
ch = getchar();
}
return w * f;
}
void dfs(int p)
{
bool flag = false; int cnt[2] = {};
int op = 0;
for (auto tt : e[p])
{
if (fa[p] == tt) continue;
fa[tt] = p;
dfs(tt); op++;
if (f[tt][1]) flag = true;
cnt[f[tt][1]]++;
}
if (flag) f[p][0] = 1;
if (cnt[1] >= 2) f[p][1] = 1;
if (!op) f[p][0] = f[p][1] = 1;
}
signed main()
{
n = read();
for (int i = 2; i <= n; i++)
{
int u = read(), v = read();
e[u].eb(v), e[v].eb(u);
}
dfs(1); for (int i = 1; i <= n; i++) printf("%lld %lld\n", f[i][0], f[i][1]);
if (f[1][1]) printf("You win, temporarily\n");
else printf("Wasted.\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8444kb
input:
6 1 2 2 3 2 4 1 5 5 6
output:
1 0 1 1 1 1 1 1 1 0 1 1 Wasted.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: '1 0'