Submission #168319

#TimeUsernameProblemLanguageResultExecution timeMemory
168319ArKCaBirokracija (COCI18_birokracija)C++17
100 / 100
114 ms27088 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); } pair<ll,ll> dfs(ll x){ pair<ll,ll>sa,as; for(ll i=0;i<v[x].size();i++){ as=dfs(v[x][i]); sa.f1+=as.f1; sa.s2+=as.s2; } deger[x]=sa.f1+sa.s2; deger[x]++; return {deger[x],sa.s2+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 'std::pair<long long int, long long int> dfs(long long int)':
birokracija.cpp:22: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:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
birokracija.cpp:37: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...