Submission #1063454

# Submission time Handle Problem Language Result Execution time Memory
1063454 2024-08-17T18:42:37 Z vjudge1 Space Pirate (JOI14_space_pirate) C++17
0 / 100
2000 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
const int N=3000;

int n;
ll k;
vector<int>graph(N+10);
vector<int>pairs(N+10);

int dfs(ll k, pair<int,int>pareja,int pos){
    if(k<=0){
        return pos;
    }
    if(pareja.first==pos){
        return dfs(k-1,pareja,pareja.second);
    }
    return dfs(k-1,pareja, graph[pos]);
}

int main(){
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        int a; cin >> a;
        graph[i]=a;
    }


    for(int x=1;x<=n;x++){
        for(int y=1;y<=n;y++){
            pairs[dfs(k,{x,y},1)]++;
        }
    }
    for(int i=1;i<=n;i++){
        cout<<pairs[i]<<endl;
    }

}
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 1116 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -