# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
797337 | 2023-07-29T09:32:13 Z | kingfran1907 | Nice sequence (IZhO18_sequence) | C++14 | 1 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; typedef long long llint; const int maxn = 1e6+10; int t; int n, m; int dis[maxn]; int out[maxn]; int sol; int cnt; void dfs(int x) { if (x < 0 || x > sol) return; if (dis[x] != -1) return; dis[x] = cnt++; dfs(x + n); dfs(x - m); } int main() { scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); sol = n + m - 1 - __gcd(n, m); printf("%d\n", sol); if (n == m) { for (int i = 0; i < sol; i++) printf("1 "); printf("\n"); continue; } for (int i = 0; i <= sol; i++) dis[i] = -1; cnt = 0; for (int i = 0; i <= sol; i++) { if (dis[i] == -1) dfs(i); } //for (int i = 0; i <= sol; i++) printf("%d ", dis[i]); printf("\n"); for (int i = 0; i <= sol; i++) dis[i] *= -1; for (int i = 0; i < sol; i++) out[i] = dis[i + 1] - dis[i]; for (int i = n; i <= sol; i++) assert(dis[i] - dis[i - n] <= -1); for (int i = m; i <= sol; i++) assert(dis[i] - dis[i - m] >= 1); for (int i = 0; i < sol; i++) printf("%d ", out[i]); printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |