#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define kuaidian ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1000 + 7, maxd = 1e5 + 7;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int n;
vector<int> vec[maxn];
bool check(int x) {
int cnt = 0;
for(int i = 0; i < vec[x].size(); ++i) {
if(!vec[vec[x][i]].size()) {
cnt++;
}
}
if(cnt >= 3) return true;
else return false;
}
int main() {
scanf("%d", &n);
for(int i = 2; i <= n; ++i) {
int x;
scanf("%d", &x);
vec[x].push_back(i);
}
for(int i = 1; i <= n; ++i) {
if(vec[i].size()) {
if(!check(i)) {
return 0 * puts("No");
}
}
}
puts("Yes");
return 0;
}
Hello 2018 B - Christmas Spruce
最新推荐文章于 2018-02-24 17:03:37 发布
