Submission #168318

#TimeUsernameProblemLanguageResultExecution timeMemory
168318ArKCaBirokracija (COCI18_birokracija)C++17
60 / 100
1070 ms13452 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...