# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
52280 | 2018-06-25T07:39:33 Z | 김세빈(#1347) | 우주 해적 (JOI14_space_pirate) | C++11 | 2000 ms | 142960 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll K[3030][3030], B[3030][3030]; ll R[3030], F[3030], P[101010]; ll ans[101010]; ll n,k; ll run(ll p,ll d) { if(d <= F[p]) return B[p][d]; if(d == 0) return p; return B[p][(d - F[p]) % R[p] + F[p]]; } ll f(ll a,ll b) { if(a == b) return a; if(a == 1){ if(K[b][1]){ ll r = k % (K[b][1] + 1); if(r == 0) return a; else if(r == 1) return b; else return run(b, r-1); } else return run(b, k-1); } if(K[b][a]){ ll r = (k - K[1][a]) % (K[b][a] + 1); if(r == 0) return a; else if(r == 1) return b; else return run(b, r-1); } else return run(b, k-1-K[1][a]); } int main() { scanf("%lld%lld",&n,&k); if(n > 3000){ return 0; } ll i,j,t; for(i=1;i<=n;i++){ scanf("%lld",P+i); } ll dfdsfdf = 0; for(i=1;i<=n;i++){ for(j=i,t=0;;j=P[j],t++){ if(K[i][j]) break; K[i][j] = t; B[i][t] = j; dfdsfdf ++; } R[i] = t-K[i][j]; F[i] = K[i][j]; } if(dfdsfdf > 9000000) return 1/0; ll cnt = 0; for(i=1;i<=n;i++) if(i == 1 || K[1][i]){ for(j=1;j<=n;j++){ ans[f(i,j)] ++; } cnt ++; } ans[run(1,k)] += n * (n - cnt); for(i=1;i<=n;i++) printf("%lld\n",ans[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 3 ms | 1252 KB | Output is correct |
3 | Correct | 3 ms | 1288 KB | Output is correct |
4 | Correct | 3 ms | 1492 KB | Output is correct |
5 | Correct | 3 ms | 1492 KB | Output is correct |
6 | Correct | 3 ms | 1492 KB | Output is correct |
7 | Correct | 4 ms | 1492 KB | Output is correct |
8 | Correct | 3 ms | 1492 KB | Output is correct |
9 | Correct | 3 ms | 1492 KB | Output is correct |
10 | Correct | 3 ms | 1492 KB | Output is correct |
11 | Correct | 3 ms | 1492 KB | Output is correct |
12 | Correct | 4 ms | 1516 KB | Output is correct |
13 | Correct | 3 ms | 1516 KB | Output is correct |
14 | Correct | 3 ms | 1516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 3 ms | 1252 KB | Output is correct |
3 | Correct | 3 ms | 1288 KB | Output is correct |
4 | Correct | 3 ms | 1492 KB | Output is correct |
5 | Correct | 3 ms | 1492 KB | Output is correct |
6 | Correct | 3 ms | 1492 KB | Output is correct |
7 | Correct | 4 ms | 1492 KB | Output is correct |
8 | Correct | 3 ms | 1492 KB | Output is correct |
9 | Correct | 3 ms | 1492 KB | Output is correct |
10 | Correct | 3 ms | 1492 KB | Output is correct |
11 | Correct | 3 ms | 1492 KB | Output is correct |
12 | Correct | 4 ms | 1516 KB | Output is correct |
13 | Correct | 3 ms | 1516 KB | Output is correct |
14 | Correct | 3 ms | 1516 KB | Output is correct |
15 | Correct | 137 ms | 84616 KB | Output is correct |
16 | Correct | 61 ms | 84616 KB | Output is correct |
17 | Correct | 166 ms | 86016 KB | Output is correct |
18 | Execution timed out | 2036 ms | 142960 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 142960 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1144 KB | Output is correct |
2 | Correct | 3 ms | 1252 KB | Output is correct |
3 | Correct | 3 ms | 1288 KB | Output is correct |
4 | Correct | 3 ms | 1492 KB | Output is correct |
5 | Correct | 3 ms | 1492 KB | Output is correct |
6 | Correct | 3 ms | 1492 KB | Output is correct |
7 | Correct | 4 ms | 1492 KB | Output is correct |
8 | Correct | 3 ms | 1492 KB | Output is correct |
9 | Correct | 3 ms | 1492 KB | Output is correct |
10 | Correct | 3 ms | 1492 KB | Output is correct |
11 | Correct | 3 ms | 1492 KB | Output is correct |
12 | Correct | 4 ms | 1516 KB | Output is correct |
13 | Correct | 3 ms | 1516 KB | Output is correct |
14 | Correct | 3 ms | 1516 KB | Output is correct |
15 | Correct | 137 ms | 84616 KB | Output is correct |
16 | Correct | 61 ms | 84616 KB | Output is correct |
17 | Correct | 166 ms | 86016 KB | Output is correct |
18 | Execution timed out | 2036 ms | 142960 KB | Time limit exceeded |
19 | Halted | 0 ms | 0 KB | - |