Submission #62637

#TimeUsernameProblemLanguageResultExecution timeMemory
62637win11905Birokracija (COCI18_birokracija)C++11
100 / 100
258 ms29724 KiB
#include <bits/stdc++.h> using namespace std; #define long long long const int N = 2e5+5; int n; long ans[N]; vector<int> g[N]; void dfs(int u) { for(int v : g[u]) dfs(v), ans[u] += ans[v]; } int main() { fill_n(ans, N, 1); scanf("%d", &n); for(int i = 2, p; i <= n; ++i) { scanf("%d", &p); g[p].emplace_back(i); } dfs(1), dfs(1); for_each(ans+1, ans+n+1, [](long x) { printf("%lld ", x); }); }

Compilation message (stderr)

birokracija.cpp: In function 'int main()':
birokracija.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
birokracija.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &p);
         ~~~~~^~~~~~~~~~
#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...