# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126647 | fizzydavid | Space Pirate (JOI14_space_pirate) | C++14 | 2064 ms | 25208 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.
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
const int maxn = 100111;
int n, a[maxn];
ll K;
int go[60][maxn];
int ans[maxn];
int calc()
{
for (int i=1; i<60; i++) for (int j=1; j<=n; j++) go[i][j] = go[i-1][go[i-1][j]];
int x = 1;
for (int i=0; i<60; i++) if ((K>>i)&1) x = go[i][x];
return x;
}
int main()
{
scanf("%d%lld", &n, &K);
for (int i=1; i<=n; i++) scanf("%d", &a[i]);
for (int i=1; i<=n; i++)
{
for (int j=1; j<=n; j++)
{
for (int k=1; k<=n; k++)
{
go[0][k] = k==i?j:a[k];
}
ans[calc()]++;
}
}
for (int i=1; i<=n; i++) printf("%d\n", ans[i]);
return 0;
}
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... |