Submission #83139

#TimeUsernameProblemLanguageResultExecution timeMemory
83139Leonardo_PaesBirokracija (COCI18_birokracija)C++11
70 / 100
200 ms14740 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 200100 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]; } int 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<int, int> dfs(int)':
birokracija.cpp:13:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<grafo[u].size(); i++){
               ~^~~~~~~~~~~~~~~~
birokracija.cpp: In function 'int main()':
birokracija.cpp:40: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...