답안 #580126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580126 2022-06-20T15:52:55 Z Naser Karte (COCI18_karte) C++17
컴파일 오류
0 ms 0 KB
#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)
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vector<int>A(n+5);
    vector<bool>V(n+5);
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        A[i+1]=a;
        V[a]=1;
    }
    map<int,ll>mp;
    for(int i=1;i<=n;i++){
        int res=1;
        int ind=i;
        while(true){
            mp[ind]+=res;
            res++;
            if(ind==1)
                break;
            ind=A[ind];
        }
    }
    for(int i=1;i<=n;i++){
        cout<<mp[i]<<' ';
    }


}

Compilation message

karte.cpp: In function 'int32_t main()':
karte.cpp:19:13: error: 'll' was not declared in this scope; did you mean 'all'?
   19 |     map<int,ll>mp;
      |             ^~
      |             all
karte.cpp:19:15: error: template argument 2 is invalid
   19 |     map<int,ll>mp;
      |               ^
karte.cpp:19:15: error: template argument 4 is invalid
karte.cpp:24:15: error: invalid types 'int[long long int]' for array subscript
   24 |             mp[ind]+=res;
      |               ^
karte.cpp:32:17: error: invalid types 'int[long long int]' for array subscript
   32 |         cout<<mp[i]<<' ';
      |                 ^