# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52306 | 2018-06-25T08:57:37 Z | 강태규(#1345) | Space Pirate (JOI14_space_pirate) | C++11 | 2000 ms | 2024 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; int n; llong k; int nxt[100001]; int dist[100001]; int sz[100001]; llong ans[100001]; int main() { scanf("%d%lld", &n, &k); for (int i = 1; i <= n; ++i) { scanf("%d", nxt + i); } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { for (int k = 1; k <= n; ++k) { dist[k] = -1; } int tp = nxt[i]; nxt[i] = j; int cyc, s; for (int k = 1, m = 0; ; k = nxt[k], ++m) { if (dist[k] != -1) { cyc = m - dist[k]; s = k; break; } dist[k] = m; } int x = 1; for (int d = (k - dist[s]) % cyc; d--; ) { x = nxt[x]; } ++ans[x]; nxt[i] = tp; } } for (int i = 1; i <= n; ++i) { printf("%lld\n", ans[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2076 ms | 2024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |