Submission #168329

#TimeUsernameProblemLanguageResultExecution timeMemory
168329Asamu13Birokracija (COCI18_birokracija)C++14
100 / 100
136 ms27320 KiB
#include<bits/stdc++.h> #define inf INT_MAX #define sc(a) scanf("%d",&a) #define scc(a,b) scanf("%d %d",&a,&b) #define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c) #define pf(a) printf("%d",a) #define pff(a,b) printf("%d %d",a,b) #define pfff(a,b,c) printf("%d %d %d",a,b,c) #define pb(a) push_back(a) #define em empty() #define fr front() #define cl clear() #define sz size() #define mp(a,b) make_pair(a,b) #define fri(b) freopen(b,"r",stdin) #define fro(b) freopen(b,"w",stdout) /* ID: uslusam1 TASK: test LANG: C++ */ using namespace std; //int visit[200013]; long long bas[200013]; long long is[200013]; long long par[200013]; vector< int > tut; vector< vector<long long> > grp; void dfs(int x){ tut.pb(x); for(int i=0;i<grp[x].size();i++){ par[grp[x][i]]=x; dfs(grp[x][i]); } return; } int main(){ long long n; cin>>n; for(int i=0;i<=n;i++){ vector<long long> aaa; grp.pb(aaa); } for(long long i=2;i<=n;i++){ int k; sc(k); grp[k].pb(i); } dfs(1); for(int i=tut.size()-1;i>0;i--){ int k=tut[i]; bas[k]++; is[k]++; is[par[k]]+=is[k]; bas[par[k]]+=bas[k]+is[k]; } bas[1]++; for(int i=1;i<=n;i++){ cout<<bas[i]<<" "; } return 0; }

Compilation message (stderr)

birokracija.cpp: In function 'void dfs(int)':
birokracija.cpp:33:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<grp[x].size();i++){
              ~^~~~~~~~~~~~~~
birokracija.cpp: In function 'int main()':
birokracija.cpp:3:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define sc(a) scanf("%d",&a)
               ~~~~~^~~~~~~~~
birokracija.cpp:51:3: note: in expansion of macro 'sc'
   sc(k);
   ^~
#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...