QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#624064 | #7986. 游戏 | liaoyingyu | WA | 1ms | 6496kb | C++17 | 1.2kb | 2024-10-09 14:51:36 | 2024-10-09 14:51:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
using PII = pair<int, int>;
using PIII = tuple<int, int, int>;
const int MOD = 1e9 + 7;
struct cmp { //priority_queue
bool operator()(const PIII& a, const PIII& b) {
return std::get<0>(a) < std::get<0>(b); //down
}
};
bool cmpsort(const PII& a, const PII& b) { //sort
return a.first < b.first; //up
}
int flag[100010] = { 0 };
vector <int> mp[100010];
void dfs(int now,int pre) {
int f = 0;
int s = 0;
for (auto it : mp[now]) {
if (it == pre) {
continue;
}
else {
f = 1;
dfs(it, now);
if (flag[it] == 1) {
s++;
}
}
}
if (f == 0) {
flag[now] = 1;
}
if (s >= 2) {
flag[now] = 1;
}
}
void solve() {
int n;
cin >> n;
for (int i = 0; i < n-1; i++) {
int a, b;
cin >> a >> b;
mp[a].push_back(b);
mp[b].push_back(a);
}
dfs(1,-1);
if (mp[1].size() == 1 || flag[1] == 1) {
cout << "You win, temporarily.";
}
else {
cout << "Wasted.";
}
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
//cout << fixed << setprecision(12);
int t;
t = 1;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6496kb
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: 6176kb
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: 5988kb
input:
1
output:
You win, temporarily.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'