# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
611836 | qwerasdfzxcl | Space Pirate (JOI14_space_pirate) | C++14 | 2072 ms | 2380 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.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int adj[100100], idx[100100];
ll ans[100100], t;
void solve(int a, int b){
int org = adj[a];
adj[a] = b;
vector<int> V = {0};
int i;
ll cur = t, len = 0;
for (i=1;;i=adj[i]){
if (idx[i]) {len = (int)V.size() - idx[i]; break;}
V.push_back(i);
idx[i] = (int)V.size()-1;
--cur;
}
cur %= len;
for (;cur;cur--){
i = adj[i];
}
ans[i]++;
for (auto &x:V) idx[x] = 0;
adj[a] = org;
}
int main(){
int n;
scanf("%d %lld", &n, &t);
for (int i=1;i<=n;i++) scanf("%d", adj+i);
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++) solve(i, j);
}
for (int i=1;i<=n;i++) printf("%lld\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... |