Submission #580532

#TimeUsernameProblemLanguageResultExecution timeMemory
580532MrM7mdBirokracija (COCI18_birokracija)C++17
100 / 100
112 ms21044 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define all(a) a.begin(),a.end() #define mod (ll)(10000007) signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; vector<int>A(n+5),T(n+5),S(n+5),app(n+5); for(int i=1;i<n;i++){ cin>>A[i+1]; app[A[i+1]]=1; } map<int,int>mp; for(int i=n;i>=1;i--){ if(!app[i]) T[i]=1; T[A[i]]+=T[i]+1; if(mp[A[i]])T[A[i]]--; mp[A[i]]=1; S[A[i]]+=S[i]+T[i]; S[i]+=T[i]; } for(int i=1;i<=n;i++){ cout<<S[i]<<' '; } } //Essa2006 code
#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...