# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338108 | 2020-12-22T13:58:07 Z | BeanZ | Nice sequence (IZhO18_sequence) | C++14 | 65 ms | 25196 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e6 + 50; long long mod = 1e9 + 7; const int lim = 700; const int lg = 18; const int base = 311; const long double eps = 1e-6; ll n, m; vector<ll> node[N]; vector<ll> topo; ll vis[N], id[N]; void dfs(ll u){ vis[u] = 1; for (auto j : node[u]){ if (vis[j]) continue; dfs(j); } topo.push_back(u); } bool chk(ll mid){ for (int i = 0; i <= mid; i++) node[i].clear(), vis[i] = 0; for (int i = 0; i <= mid; i++){ if (i >= n) node[i - n].push_back(i); if (i >= m) node[i].push_back(i - m); } topo.clear(); for (int i = 0; i <= mid; i++){ if (vis[i]) continue; dfs(i); } for (int i = 0; i < topo.size(); i++){ id[topo[i]] = i; } for (int i = 0; i <= mid; i++){ for (auto j : node[i]){ if (id[i] < id[j]) return false; } } return true; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("tests.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll t; cin >> t; while (t--){ cin >> n >> m; ll l = 1, h = max(n, m); while (l <= h){ ll mid = (l + h) >> 1; if (chk(mid)) l = mid + 1; else h = mid - 1; } cout << h << endl; chk(h); for (int i = 1; i <= h; i++){ cout << id[i] - id[i - 1] << " "; } cout << endl; } } /* Ans: Out: */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Ok |
2 | Correct | 16 ms | 23900 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 17 ms | 23916 KB | Ok |
5 | Correct | 16 ms | 23788 KB | Ok |
6 | Correct | 18 ms | 23788 KB | Ok |
7 | Correct | 19 ms | 23788 KB | Ok |
8 | Correct | 17 ms | 23936 KB | Ok |
9 | Correct | 18 ms | 23788 KB | Ok |
10 | Correct | 17 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23808 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Ok |
2 | Correct | 17 ms | 23788 KB | Ok |
3 | Correct | 17 ms | 23916 KB | Ok |
4 | Correct | 19 ms | 23788 KB | Ok |
5 | Correct | 18 ms | 23788 KB | Ok |
6 | Correct | 25 ms | 24044 KB | Ok |
7 | Correct | 50 ms | 24940 KB | Ok |
8 | Correct | 31 ms | 24300 KB | Ok |
9 | Correct | 65 ms | 25196 KB | Ok |
10 | Correct | 39 ms | 24556 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | Ok |
2 | Correct | 16 ms | 23916 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 9, pans = 8 |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 23788 KB | Jury has the better answer : jans = 5, pans = 4 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Ok |
2 | Correct | 16 ms | 23900 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 17 ms | 23916 KB | Ok |
5 | Correct | 16 ms | 23788 KB | Ok |
6 | Correct | 18 ms | 23788 KB | Ok |
7 | Correct | 19 ms | 23788 KB | Ok |
8 | Correct | 17 ms | 23936 KB | Ok |
9 | Correct | 18 ms | 23788 KB | Ok |
10 | Correct | 17 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23808 KB | Ok |
13 | Correct | 16 ms | 23788 KB | Ok |
14 | Correct | 16 ms | 23916 KB | Ok |
15 | Correct | 16 ms | 23788 KB | Ok |
16 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 9, pans = 8 |
17 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Ok |
2 | Correct | 16 ms | 23900 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 17 ms | 23916 KB | Ok |
5 | Correct | 16 ms | 23788 KB | Ok |
6 | Correct | 18 ms | 23788 KB | Ok |
7 | Correct | 19 ms | 23788 KB | Ok |
8 | Correct | 17 ms | 23936 KB | Ok |
9 | Correct | 18 ms | 23788 KB | Ok |
10 | Correct | 17 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23808 KB | Ok |
13 | Correct | 17 ms | 23788 KB | Ok |
14 | Correct | 17 ms | 23788 KB | Ok |
15 | Correct | 17 ms | 23916 KB | Ok |
16 | Correct | 19 ms | 23788 KB | Ok |
17 | Correct | 18 ms | 23788 KB | Ok |
18 | Correct | 25 ms | 24044 KB | Ok |
19 | Correct | 50 ms | 24940 KB | Ok |
20 | Correct | 31 ms | 24300 KB | Ok |
21 | Correct | 65 ms | 25196 KB | Ok |
22 | Correct | 39 ms | 24556 KB | Ok |
23 | Correct | 16 ms | 23788 KB | Ok |
24 | Correct | 16 ms | 23916 KB | Ok |
25 | Correct | 16 ms | 23788 KB | Ok |
26 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 9, pans = 8 |
27 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Ok |
2 | Correct | 16 ms | 23900 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 17 ms | 23916 KB | Ok |
5 | Correct | 16 ms | 23788 KB | Ok |
6 | Correct | 18 ms | 23788 KB | Ok |
7 | Correct | 19 ms | 23788 KB | Ok |
8 | Correct | 17 ms | 23936 KB | Ok |
9 | Correct | 18 ms | 23788 KB | Ok |
10 | Correct | 17 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23808 KB | Ok |
13 | Correct | 17 ms | 23788 KB | Ok |
14 | Correct | 17 ms | 23788 KB | Ok |
15 | Correct | 17 ms | 23916 KB | Ok |
16 | Correct | 19 ms | 23788 KB | Ok |
17 | Correct | 18 ms | 23788 KB | Ok |
18 | Correct | 25 ms | 24044 KB | Ok |
19 | Correct | 50 ms | 24940 KB | Ok |
20 | Correct | 31 ms | 24300 KB | Ok |
21 | Correct | 65 ms | 25196 KB | Ok |
22 | Correct | 39 ms | 24556 KB | Ok |
23 | Correct | 16 ms | 23788 KB | Ok |
24 | Correct | 16 ms | 23916 KB | Ok |
25 | Correct | 16 ms | 23788 KB | Ok |
26 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 9, pans = 8 |
27 | Halted | 0 ms | 0 KB | - |