Submission #580381

# Submission time Handle Problem Language Result Execution time Memory
580381 2022-06-21T07:33:55 Z MrM7md Birokracija (COCI18_birokracija) C++17
70 / 100
45 ms 5416 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define endl "\n"

const int MOD = 1e9 + 7;

int a[1000000];
int add[1000000];
signed main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   int b[n];
   b[0]=100000;
   for(int i=1;i<n;i++){
      cin >> b[i];
      b[i]--;
   }
   for(int t=n-1;t>=0;t--){
      add[b[t]]+=add[t]+1;
      a[t]++;
      a[b[t]]+=a[t]+add[t];
   }
   for(int i=0;i<n;i++){
      cout<<a[i]+add[i]<<' ';
   }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 852 KB Output is correct
2 Correct 4 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2132 KB Output is correct
2 Correct 13 ms 2080 KB Output is correct
3 Correct 12 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 5416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 5336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 5332 KB Output isn't correct
2 Halted 0 ms 0 KB -