QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745356 | #7986. 游戏 | ucup-team4352# | WA | 1ms | 3712kb | C++23 | 715b | 2024-11-14 09:25:54 | 2024-11-14 09:25:55 |
Judging History
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'