# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747652 | Dan4Life | Space Pirate (JOI14_space_pirate) | C++17 | 960 ms | 71376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = (int)3e3+2;
const int mxLg = 12;
const int LINF = (int)1e18+2;
int n, k, p[mxN], ans[mxN];
int vis[mxN], cyc[mxN], SZ[mxN];
int D[mxN][mxN], jmp[mxLg][mxN];
int getPath(int x, int k){
if(D[x][cyc[x]] <= k)
k-=D[x][cyc[x]], k%=SZ[cyc[x]], x = cyc[x];
for(int i = 0; i<mxLg; i++)
if((k>>i)&1) x = jmp[i][x];
return x;
}
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> p[i], jmp[0][i]=p[i];
for(int i = 1; i < mxLg; i++)
for(int j = 1; j <= n; j++)
jmp[i][j] = jmp[i-1][jmp[i-1][j]];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
D[i][j] = LINF;
for(int i = 1; i <= n; i++){
int j = i, tot=0; vector<int> v; v.clear();
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |