QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352279#7986. 游戏Kevin5307WA 1ms3700kbC++20561b2024-03-13 07:49:562024-03-13 07:49:56

Judging History

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

  • [2024-03-13 07:49:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2024-03-13 07:49:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
vector<int> G[100100];
int f[100100];
void dfs(int u,int fa)
{
	if(G[u].size()==1)
	{
		f[u]=1;
		return ;
	}
	int cnt=0;
	for(auto v:G[u])
		if(v!=fa)
		{
			dfs(v,u);
			cnt+=f[v];
		}
	f[u]=(cnt>1);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	if(f[1])
		puts("Wasted.");
	else
		puts("You win, temporarily.");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3700kb

input:

6
1 2
2 3
2 4
1 5
5 6

output:

You win, temporarily.

result:

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