# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40506 | 2018-02-03T08:49:31 Z | Akylbek | Nice sequence (IZhO18_sequence) | C++14 | 5 ms | 5212 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int N = 2e5 + 10; const int md = 1e9 + 7; int T; int n, m; vector <int> g[N]; int p[N]; int used[N]; void dfs (int v) { used[v] = 1; for (auto to : g[v]) { if (!used[to]) dfs(to); } if (v == 0) p[v] = 0; else { p[v] = -1000000; for (auto to : g[v]) { p[v] = max(p[v], p[to] + 1); } } } int main() { scanf("%d", &T); while (T--) { scanf("%d%d", &n, &m); int len = n + m - __gcd(n, m) - 1; for (int i = n; i <= len; i++) { g[i - n].pb(i); } for (int i = m; i <= len; i++) { g[i].pb(i - m); } for (int i = 0; i <= len; i++) { if (!used[i]) { dfs(i); } } for (int i = 0; i <= len; i++) { g[i].clear(); used[i] = 0; } cout << len << '\n'; for (int i = 1; i <= len; i++) { cout << p[i] - p[i - 1] << ' '; } cout << '\n'; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4984 KB | Ok |
2 | Incorrect | 5 ms | 5088 KB | All the numbers must be nonzero |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5088 KB | All the numbers must be nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5088 KB | Ok |
2 | Correct | 5 ms | 5088 KB | Ok |
3 | Incorrect | 5 ms | 5212 KB | All the numbers must be nonzero |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5212 KB | All the numbers must be nonzero |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4984 KB | Ok |
2 | Incorrect | 5 ms | 5088 KB | All the numbers must be nonzero |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4984 KB | Ok |
2 | Incorrect | 5 ms | 5088 KB | All the numbers must be nonzero |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4984 KB | Ok |
2 | Incorrect | 5 ms | 5088 KB | All the numbers must be nonzero |
3 | Halted | 0 ms | 0 KB | - |