# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168318 | ArKCa | Birokracija (COCI18_birokracija) | C++17 | 1070 ms | 13452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define f1 first
#define s2 second
#define N 200005
#define ekle 200
using namespace std;
vector<ll>v[N];
ll ata[N],cocuk[N],deger[N];
ll n;
void atam(ll x,ll dgr){
if(x==-1)return;
deger[x]+=dgr;
atam(ata[x],dgr+1);
}
void dfs(ll x){
for(ll i=0;i<v[x].size();i++){
dfs(v[x][i]);
}
atam(x,1);
}
int main(){
// freopen("a.gir","r",stdin);
// freopen("a.cik","w",stdout);
scanf("%lld",&n);
ata[1]=-1;
for(ll i=2;i<=n;i++){
scanf("%lld",&ata[i]);
v[ata[i]].pb(i);
}
dfs(1);
for(ll i=1;i<=n;i++){
printf("%lld ",deger[i] );
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |