#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
const int K = 60;
const int N = 100;
int go[K][N];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n; ll k;
cin >> n >> k;
vector <int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
--a[i];
}
vector <int> cnt(n);
for (int x = 0; x < n; ++x) {
for (int y = 0; y < n; ++y) {
for (int i = 0; i < n; ++i) go[0][i] = a[i];
go[0][x] = y;
for (int i = 1; i < K; ++i) {
for (int j = 0; j < n; ++j) {
go[i][j] = go[i - 1][go[i - 1][j]];
}
}
int u = 0;
for (int i = K - 1; i >= 0; --i) {
if (k & (1LL << i)) u = go[i][u];
}
++cnt[u];
}
}
for (int i = 0; i < n; ++i) {
cout << cnt[i] << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
384 KB |
Output is correct |
2 |
Correct |
57 ms |
384 KB |
Output is correct |
3 |
Correct |
66 ms |
384 KB |
Output is correct |
4 |
Correct |
57 ms |
408 KB |
Output is correct |
5 |
Correct |
60 ms |
384 KB |
Output is correct |
6 |
Correct |
60 ms |
384 KB |
Output is correct |
7 |
Correct |
63 ms |
384 KB |
Output is correct |
8 |
Correct |
58 ms |
404 KB |
Output is correct |
9 |
Correct |
58 ms |
384 KB |
Output is correct |
10 |
Correct |
63 ms |
384 KB |
Output is correct |
11 |
Correct |
60 ms |
384 KB |
Output is correct |
12 |
Correct |
58 ms |
384 KB |
Output is correct |
13 |
Correct |
56 ms |
404 KB |
Output is correct |
14 |
Correct |
56 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
384 KB |
Output is correct |
2 |
Correct |
57 ms |
384 KB |
Output is correct |
3 |
Correct |
66 ms |
384 KB |
Output is correct |
4 |
Correct |
57 ms |
408 KB |
Output is correct |
5 |
Correct |
60 ms |
384 KB |
Output is correct |
6 |
Correct |
60 ms |
384 KB |
Output is correct |
7 |
Correct |
63 ms |
384 KB |
Output is correct |
8 |
Correct |
58 ms |
404 KB |
Output is correct |
9 |
Correct |
58 ms |
384 KB |
Output is correct |
10 |
Correct |
63 ms |
384 KB |
Output is correct |
11 |
Correct |
60 ms |
384 KB |
Output is correct |
12 |
Correct |
58 ms |
384 KB |
Output is correct |
13 |
Correct |
56 ms |
404 KB |
Output is correct |
14 |
Correct |
56 ms |
504 KB |
Output is correct |
15 |
Execution timed out |
2086 ms |
384 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
2688 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
384 KB |
Output is correct |
2 |
Correct |
57 ms |
384 KB |
Output is correct |
3 |
Correct |
66 ms |
384 KB |
Output is correct |
4 |
Correct |
57 ms |
408 KB |
Output is correct |
5 |
Correct |
60 ms |
384 KB |
Output is correct |
6 |
Correct |
60 ms |
384 KB |
Output is correct |
7 |
Correct |
63 ms |
384 KB |
Output is correct |
8 |
Correct |
58 ms |
404 KB |
Output is correct |
9 |
Correct |
58 ms |
384 KB |
Output is correct |
10 |
Correct |
63 ms |
384 KB |
Output is correct |
11 |
Correct |
60 ms |
384 KB |
Output is correct |
12 |
Correct |
58 ms |
384 KB |
Output is correct |
13 |
Correct |
56 ms |
404 KB |
Output is correct |
14 |
Correct |
56 ms |
504 KB |
Output is correct |
15 |
Execution timed out |
2086 ms |
384 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |