Submission #580115

#TimeUsernameProblemLanguageResultExecution timeMemory
580115vqpahmadBirokracija (COCI18_birokracija)C++14
60 / 100
1084 ms4224 KiB
#include <bits/stdc++.h> #define ll long long #define endl '\n' #define all(a) a.begin(),a.end() #define mod (ll)(10000007) using namespace std; const int mx = 1e6 + 15; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a(n); vector<ll> freq(n+1); a[0]=-1; for (int i=1;i<n;i++){ cin >> a[i]; a[i]--; } for (int i=n-1; i>=1;i--){ freq[i+1]++; int cur = a[i]; int cnt = 1; //cout << cur+1 << ' '; while (cur!=-1){ freq[cur]+=++cnt; cur = a[cur]; //cout << cur+1 << ' '; } } freq[0]++; freq[1]++; // idk why for (int i=0;i<n;i++){ cout << freq[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...