Submission #747613

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7476132023-05-24 11:53:04Dan4LifeSpace Pirate (JOI14_space_pirate)C++17
0 / 100
22 ms35992 KiB
#include <bits/stdc++.h>
using namespace std;
const int mxN = (int)3e3+10;
const int mxLg = 60;
const int INF = 0x3f3f3f3f;
int n, k, p[mxN], ans[mxN];
int dis[mxN][mxN], jmp[mxLg][mxN];
int getPath(int x, int k){
for(int i = 0; i<mxLg; i++)
if((k>>i)&1) x = jmp[i][x];
return x;
}
int32_t main() {
cin >> n >> k;
for(int i = 1; i <= n; i++) cin >> p[i], jmp[0][p[i]]=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]];
memset(dis,63,sizeof(dis));
for(int i = 1; i <= n; i++)
for(int j = 0; j <= n; j++)
if(dis[i][getPath(i,j)]==INF)
dis[i][getPath(i,j)]=j;
for(int a = 1; a <= n; a++){
for(int b = 1; b <= n; b++){
if(dis[1][a]>=k) ans[getPath(1,k)]++;
else{
int xd = k-dis[1][a]-1, cyc;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...