# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495840 | 2021-12-20T06:07:37 Z | Ziel | Nice sequence (IZhO18_sequence) | C++17 | 9 ms | 796 KB |
/** * LES GREATEABLES BRO TEAM **/ #include <bits/stdc++.h> using namespace std; using ll = long long; #define sz(x) (int)x.size() const bool FLAG = true; void setIO(const string &f = ""); void solve() { int n, m; cin >> n >> m; if (n == m) { cout << n - 1 << '\n'; for (int i = 0; i < n - 1; i++) cout << "1 "; } else if (n < m) { if (n == 1) { cout << m - 1 << '\n'; for (int i = 1; i < m; i++) cout << "-1 "; } else if (n == 2) { cout << m - 1 + (m % 2) << '\n'; int x = (m - 1) / 2 + 1; for (int i = 1; i <= m - 1 + (m % 2); i++) { if (i % 2 == 0) cout << -(x + 1) << ' '; else cout << x << ' '; } } else if (m % n == 0) { cout << m - 1 << '\n'; int x = m / n - 1; for (int i = 1; i < m; i++) { if (i % n == 0) cout << -(x * (n - 1) + 1) << ' '; else cout << x << ' '; } } else { if ((m + n - 1) % n == 0) { m = (m + n - 1) / n * n; cout << m << '\n'; int x = (m + 1) / n - 1; for (int i = 2; i <= m + 1; i++) { if (i % n == 0) cout << -(x * (n - 1) + 1) << ' '; else cout << x << ' '; } } else { m = (m + n - 1) / n * n - 1; cout << m << '\n'; int x = (m + 1) / n - 1; for (int i = 1; i <= m; i++) { if (i % n == 0) cout << -(x * (n - 1) + 1) << ' '; else cout << x << ' '; } } } } else { swap(n, m); if (n == 1) { cout << m - 1 << '\n'; for (int i = 1; i < m; i++) cout << "1 "; } else if (n == 2) { cout << m - 1 + (m % 2) << '\n'; int x = (m - 1) / 2 + 1; for (int i = 1; i <= m - 1 + (m % 2); i++) { if (i % 2 == 0) cout << (x + 1) << ' '; else cout << -x << ' '; } } else if (m % n == 0) { cout << m - 1 << '\n'; int x = m / n - 1; for (int i = 1; i < m; i++) { if (i % n == 0) cout << (x * (n - 1) + 1) << ' '; else cout << -x << ' '; } } else { if ((m + n - 1) % n == 0) { m = (m + n - 1) / n * n; cout << m << '\n'; int x = (m + 1) / n - 1; for (int i = 2; i <= m + 1; i++) { if (i % n == 0) cout << (x * (n - 1) + 1) << ' '; else cout << -x << ' '; } } else { m = (m + n - 1) / n * n - 1; cout << m << '\n'; int x = (m + 1) / n - 1; for (int i = 1; i <= m; i++) { if (i % n == 0) cout << (x * (n - 1) + 1) << ' '; else cout << -x << ' '; } } } } cout << '\n'; } signed main() { setIO(); int tt = 1; if (FLAG) { cin >> tt; } while (tt--) { solve(); } return 0; } void setIO(const string &f) { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen((f + ".in").c_str(), "r")) { freopen((f + ".in").c_str(), "r", stdin); freopen((f + ".out").c_str(), "w", stdout); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Ok |
2 | Correct | 1 ms | 204 KB | Ok |
3 | Correct | 1 ms | 204 KB | Ok |
4 | Correct | 0 ms | 204 KB | Ok |
5 | Correct | 1 ms | 204 KB | Ok |
6 | Correct | 1 ms | 204 KB | Ok |
7 | Correct | 0 ms | 204 KB | Ok |
8 | Correct | 1 ms | 204 KB | Ok |
9 | Correct | 0 ms | 204 KB | Ok |
10 | Correct | 1 ms | 204 KB | Ok |
11 | Correct | 0 ms | 204 KB | Ok |
12 | Correct | 1 ms | 204 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Ok |
2 | Correct | 1 ms | 204 KB | Ok |
3 | Correct | 1 ms | 204 KB | Ok |
4 | Correct | 1 ms | 204 KB | Ok |
5 | Correct | 0 ms | 204 KB | Ok |
6 | Correct | 3 ms | 332 KB | Ok |
7 | Correct | 7 ms | 716 KB | Ok |
8 | Correct | 4 ms | 460 KB | Ok |
9 | Correct | 9 ms | 796 KB | Ok |
10 | Correct | 5 ms | 588 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Ok |
2 | Correct | 1 ms | 204 KB | Ok |
3 | Correct | 1 ms | 204 KB | Ok |
4 | Incorrect | 0 ms | 204 KB | Jury has the better answer : jans = 9, pans = 8 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | there is incorrect sequence |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Ok |
2 | Correct | 1 ms | 204 KB | Ok |
3 | Correct | 1 ms | 204 KB | Ok |
4 | Correct | 0 ms | 204 KB | Ok |
5 | Correct | 1 ms | 204 KB | Ok |
6 | Correct | 1 ms | 204 KB | Ok |
7 | Correct | 0 ms | 204 KB | Ok |
8 | Correct | 1 ms | 204 KB | Ok |
9 | Correct | 0 ms | 204 KB | Ok |
10 | Correct | 1 ms | 204 KB | Ok |
11 | Correct | 0 ms | 204 KB | Ok |
12 | Correct | 1 ms | 204 KB | Ok |
13 | Correct | 1 ms | 204 KB | Ok |
14 | Correct | 1 ms | 204 KB | Ok |
15 | Correct | 1 ms | 204 KB | Ok |
16 | Incorrect | 0 ms | 204 KB | Jury has the better answer : jans = 9, pans = 8 |
17 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Ok |
2 | Correct | 1 ms | 204 KB | Ok |
3 | Correct | 1 ms | 204 KB | Ok |
4 | Correct | 0 ms | 204 KB | Ok |
5 | Correct | 1 ms | 204 KB | Ok |
6 | Correct | 1 ms | 204 KB | Ok |
7 | Correct | 0 ms | 204 KB | Ok |
8 | Correct | 1 ms | 204 KB | Ok |
9 | Correct | 0 ms | 204 KB | Ok |
10 | Correct | 1 ms | 204 KB | Ok |
11 | Correct | 0 ms | 204 KB | Ok |
12 | Correct | 1 ms | 204 KB | Ok |
13 | Correct | 1 ms | 204 KB | Ok |
14 | Correct | 1 ms | 204 KB | Ok |
15 | Correct | 1 ms | 204 KB | Ok |
16 | Correct | 1 ms | 204 KB | Ok |
17 | Correct | 0 ms | 204 KB | Ok |
18 | Correct | 3 ms | 332 KB | Ok |
19 | Correct | 7 ms | 716 KB | Ok |
20 | Correct | 4 ms | 460 KB | Ok |
21 | Correct | 9 ms | 796 KB | Ok |
22 | Correct | 5 ms | 588 KB | Ok |
23 | Correct | 1 ms | 204 KB | Ok |
24 | Correct | 1 ms | 204 KB | Ok |
25 | Correct | 1 ms | 204 KB | Ok |
26 | Incorrect | 0 ms | 204 KB | Jury has the better answer : jans = 9, pans = 8 |
27 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Ok |
2 | Correct | 1 ms | 204 KB | Ok |
3 | Correct | 1 ms | 204 KB | Ok |
4 | Correct | 0 ms | 204 KB | Ok |
5 | Correct | 1 ms | 204 KB | Ok |
6 | Correct | 1 ms | 204 KB | Ok |
7 | Correct | 0 ms | 204 KB | Ok |
8 | Correct | 1 ms | 204 KB | Ok |
9 | Correct | 0 ms | 204 KB | Ok |
10 | Correct | 1 ms | 204 KB | Ok |
11 | Correct | 0 ms | 204 KB | Ok |
12 | Correct | 1 ms | 204 KB | Ok |
13 | Correct | 1 ms | 204 KB | Ok |
14 | Correct | 1 ms | 204 KB | Ok |
15 | Correct | 1 ms | 204 KB | Ok |
16 | Correct | 1 ms | 204 KB | Ok |
17 | Correct | 0 ms | 204 KB | Ok |
18 | Correct | 3 ms | 332 KB | Ok |
19 | Correct | 7 ms | 716 KB | Ok |
20 | Correct | 4 ms | 460 KB | Ok |
21 | Correct | 9 ms | 796 KB | Ok |
22 | Correct | 5 ms | 588 KB | Ok |
23 | Correct | 1 ms | 204 KB | Ok |
24 | Correct | 1 ms | 204 KB | Ok |
25 | Correct | 1 ms | 204 KB | Ok |
26 | Incorrect | 0 ms | 204 KB | Jury has the better answer : jans = 9, pans = 8 |
27 | Halted | 0 ms | 0 KB | - |