QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#656541#7986. 游戏yuanyq5523#WA 1ms5676kbC++201.3kb2024-10-19 13:17:312024-10-19 13:17:32

Judging History

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

  • [2024-10-19 13:17:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5676kb
  • [2024-10-19 13:17:31]
  • 提交

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) 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: 3560kb

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

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

input:

1

output:

You win, temporarily.

result:

wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'