# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
747640 | Dan4Life | Space Pirate (JOI14_space_pirate) | C++17 | 2033 ms | 72440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = (int)3e3+10;
const int mxLg = 60;
const int LINF = (int)1e18+10;
int n, k, p[mxN], ans[mxN];
int dis[mxN][mxN], jmp[mxLg][mxN];
int getPath(int x, int k){
if(k==0) return x;
int xd = log2(k); xd+=2;
for(int i = 0; i<xd; 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++)
dis[i][j] = LINF;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n; j++){
int p = getPath(i,j);
# | 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... |