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;
typedef long long ll;
const int N = (int) 1e5 + 7;
int n;
int nxt[N];
ll solution[N];
ll k;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> nxt[i];
}
for (int a = 1; a <= n; a++) {
int init = nxt[a];
for (int b = 1; b <= n; b++) {
nxt[a] = b;
int current = 1;
for (ll step = 1; step <= k; step++) {
current = nxt[current];
}
solution[current]++;
}
nxt[a] = init;
}
for (int i = 1; i <= n; i++) {
cout << solution[i] << "\n";
}
return 0;
}
# | 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... |