QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745356#7986. 游戏ucup-team4352#WA 1ms3712kbC++23715b2024-11-14 09:25:542024-11-14 09:25:55

Judging History

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

  • [2024-11-14 09:25:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2024-11-14 09:25:54]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
vector<int>e[maxn];
int dp[maxn];
void dfs(int x,int f){
	int cnt=0;
	if(e[x].size()==1)dp[x]=1;
	for(auto u:e[x]){
		if(u==f)continue;
		dfs(u,x);
		cnt+=dp[u]>0;
	}
	if(dp[x]==0)dp[x]=cnt>1;
	// cout<<x<<" "<<dp[x]<<" "<<cnt<<"\n";
}
void solve(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1,0);
	if(dp[1])cout<<"1\n";
	else cout<<"0\n";
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	// cin>>t;
	while(t--)solve();
	return 0;
}
/*
6
1 2
2 3
2 4
1 5
5 6

7
1 2
2 3
2 4
1 5
5 6
5 7
*/

详细

Test #1:

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

input:

6
1 2
2 3
2 4
1 5
5 6

output:

0

result:

wrong answer 1st lines differ - expected: 'Wasted.', found: '0'