Submission #580127

# Submission time Handle Problem Language Result Execution time Memory
580127 2022-06-20T15:53:32 Z Naser Karte (COCI18_karte) C++17
0 / 120
1000 ms 4308 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#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]<<' ';
    }


}
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 1876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 4308 KB Time limit exceeded
2 Halted 0 ms 0 KB -