답안 #580236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580236 2022-06-20T19:10:48 Z 7as__7 Birokracija (COCI18_birokracija) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
int arr[n + 1] = {};
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,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){
            arr[x] += tot--;
            y = x;
            x = mp[x].back();
         }
         arr[x]++;
         mp[y].pop_back();
      }
      arr[1]++;
      for(int i = 1;i<=n;i++){
        cout << arr[i] << " ";
      }
    }
}

Compilation message

birokracija.cpp:4:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    4 | int arr[n + 1] = {};
      |         ^
      |         yn
birokracija.cpp: In function 'int32_t main()':
birokracija.cpp:30:13: error: 'arr' was not declared in this scope
   30 |             arr[x] += tot--;
      |             ^~~
birokracija.cpp:34:10: error: 'arr' was not declared in this scope
   34 |          arr[x]++;
      |          ^~~
birokracija.cpp:37:7: error: 'arr' was not declared in this scope
   37 |       arr[1]++;
      |       ^~~