Submission #83140

#TimeUsernameProblemLanguageResultExecution timeMemory
83140Leonardo_PaesBirokracija (COCI18_birokracija)C++11
100 / 100
159 ms26040 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 200100 #define int long long vector<int> grafo[MAXN]; pair<int,int> resp[MAXN]; pair<int,int> dfs (int u){ for(int i=0; i<grafo[u].size(); i++){ pair<int,int> x = dfs(grafo[u][i]); resp[u].first+=x.first; resp[u].second+=x.second+x.first; } return resp[u]; } main(){ int n; cin >> n; for(int i=2; i<=n; i++){ int p; cin >> p; grafo[p].push_back(i); } for(int i=1; i<=n; i++){ resp[i].first=resp[i].second=1; } pair<int,int> k = dfs(1); for(int i=1; i<=n; i++){ cout << resp[i].second << " "; } cout << endl; return 0; }

Compilation message (stderr)

birokracija.cpp: In function 'std::pair<long long int, long long int> dfs(long long int)':
birokracija.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<grafo[u].size(); i++){
               ~^~~~~~~~~~~~~~~~
birokracija.cpp: At global scope:
birokracija.cpp:23:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main(){
       ^
birokracija.cpp: In function 'int main()':
birokracija.cpp:42:16: warning: variable 'k' set but not used [-Wunused-but-set-variable]
  pair<int,int> k = dfs(1);
                ^
#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...