Submission #580232

# Submission time Handle Problem Language Result Execution time Memory
580232 2022-06-20T19:06:14 Z 7as__7 Birokracija (COCI18_birokracija) C++17
50 / 100
1000 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
      int n;
      cin >> n;
      map<int,int>mptot;
      map<int,deque<int> >mp;
      for(int i = 2;i<=n;i++){
          int x;
          cin >> x;
          mp[x].push_front(i);
      }
      while(mp[1].size() > 0){
         int x = 1;
         int tot = 0;
         while(mp[x].size() > 0){
            tot++;
            x = mp[x].back();
         }
         tot++;
         x = 1;
         int y = 0;
         while(mp[x].size() > 0){
            mptot[x] += tot--;
            y = x;
            x = mp[x].back();
         }
         mptot[x]++;
         mp[y].pop_back();
      }
      mptot[1]++;
      for(int i = 1;i<=n;i++){
        cout << mptot[i] << " ";
      }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 724 KB Output is correct
2 Correct 10 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 15 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 16028 KB Output is correct
2 Execution timed out 1078 ms 20320 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 377 ms 56348 KB Output is correct
2 Execution timed out 1080 ms 55584 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 97 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 105 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -