QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656556 | #7986. 游戏 | yuanyq5523# | WA | 1ms | 5712kb | C++20 | 1.3kb | 2024-10-19 13:19:09 | 2024-10-19 13:19:09 |
Judging History
answer
/*
ANALYSIS:
*/
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <ctime>
#include <random>
#define int long long
#define endl '\n'
using namespace std;
const int N=1e5+5;
vector<int>edge[N];
int n,ans[N];
void dfs(int u,int fa){
if (edge[u].size()==1){
ans[u]=1;
return;
}
int cnt=0;
for (int v:edge[u]){
if (v==fa) continue;
dfs(v,u);
cnt+=ans[v];
}
if (cnt>=2) ans[u]=1;
}
void solution()
{
cin>>n;
for (int i=1,u,v;i<n;i++){
cin>>u>>v;
edge[u].push_back(v);
edge[v].push_back(u);
}
if (n==1||edge[1].size()==1) cout<<"You win, temporarily."<<endl;
else{
dfs(1,0);
if (ans[1]) cout<<"You win, temporarily."<<endl;
else cout<<"Wasted."<<endl;
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
for (int i=1;i<=T;i++) {
try {
cerr<<"Case #"<<i<<": "<<endl;
solution();
} catch (const char* e) {
cerr << "Caught exception in solution: " << e << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5712kb
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: 5616kb
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: 5616kb
input:
1
output:
You win, temporarily.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'