Submission #168318

# Submission time Handle Problem Language Result Execution time Memory
168318 2019-12-12T11:38:16 Z ArKCa Birokracija (COCI18_birokracija) C++17
60 / 100
1000 ms 13452 KB
#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

birokracija.cpp: In function 'void dfs(long long int)':
birokracija.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i=0;i<v[x].size();i++){
                ~^~~~~~~~~~~~
birokracija.cpp: In function 'int main()':
birokracija.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
birokracija.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&ata[i]);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 5896 KB Output is correct
2 Correct 189 ms 6180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 7928 KB Output is correct
2 Execution timed out 1054 ms 8220 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 133 ms 13452 KB Output is correct
2 Execution timed out 1069 ms 12984 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 130 ms 13432 KB Output is correct
2 Execution timed out 1060 ms 12924 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 132 ms 13280 KB Output is correct
2 Execution timed out 1070 ms 12868 KB Time limit exceeded
3 Halted 0 ms 0 KB -