# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338114 | 2020-12-22T14:05:47 Z | BeanZ | Nice sequence (IZhO18_sequence) | C++14 | 46 ms | 25452 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll int #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, ll mid){ vis[u] = 1; for (auto j : node[u]){ if (vis[j] || j > mid) continue; dfs(j, mid); } topo.push_back(u); } bool chk(ll mid){ for (int i = 0; i <= mid; i++) vis[i] = 0; topo.clear(); for (int i = 0; i <= mid; i++){ if (vis[i]) continue; dfs(i, mid); } 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 (j > mid) continue; 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) + 1; for (int i = 0; i <= h; i++) node[i].clear(); for (int i = 0; i <= h; i++){ if (i >= n) node[i - n].push_back(i); if (i >= m) node[i].push_back(i - 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 | 16 ms | 23788 KB | Ok |
2 | Correct | 17 ms | 23788 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 16 ms | 23788 KB | Ok |
5 | Correct | 17 ms | 23788 KB | Ok |
6 | Correct | 17 ms | 23788 KB | Ok |
7 | Correct | 16 ms | 23788 KB | Ok |
8 | Correct | 18 ms | 23788 KB | Ok |
9 | Correct | 16 ms | 23788 KB | Ok |
10 | Correct | 16 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23788 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23808 KB | Ok |
2 | Correct | 18 ms | 23788 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 17 ms | 23788 KB | Ok |
5 | Correct | 17 ms | 23788 KB | Ok |
6 | Correct | 21 ms | 24044 KB | Ok |
7 | Correct | 43 ms | 25196 KB | Ok |
8 | Correct | 30 ms | 24428 KB | Ok |
9 | Correct | 46 ms | 25452 KB | Ok |
10 | Correct | 35 ms | 24812 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Ok |
2 | Correct | 17 ms | 23788 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 17 ms | 23788 KB | Ok |
5 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 11, pans = 10 |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 23788 KB | Jury has the better answer : jans = 7, pans = 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | Ok |
2 | Correct | 17 ms | 23788 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 16 ms | 23788 KB | Ok |
5 | Correct | 17 ms | 23788 KB | Ok |
6 | Correct | 17 ms | 23788 KB | Ok |
7 | Correct | 16 ms | 23788 KB | Ok |
8 | Correct | 18 ms | 23788 KB | Ok |
9 | Correct | 16 ms | 23788 KB | Ok |
10 | Correct | 16 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23788 KB | Ok |
13 | Correct | 17 ms | 23788 KB | Ok |
14 | Correct | 17 ms | 23788 KB | Ok |
15 | Correct | 16 ms | 23788 KB | Ok |
16 | Correct | 17 ms | 23788 KB | Ok |
17 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 11, pans = 10 |
18 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | Ok |
2 | Correct | 17 ms | 23788 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 16 ms | 23788 KB | Ok |
5 | Correct | 17 ms | 23788 KB | Ok |
6 | Correct | 17 ms | 23788 KB | Ok |
7 | Correct | 16 ms | 23788 KB | Ok |
8 | Correct | 18 ms | 23788 KB | Ok |
9 | Correct | 16 ms | 23788 KB | Ok |
10 | Correct | 16 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23788 KB | Ok |
13 | Correct | 17 ms | 23808 KB | Ok |
14 | Correct | 18 ms | 23788 KB | Ok |
15 | Correct | 16 ms | 23788 KB | Ok |
16 | Correct | 17 ms | 23788 KB | Ok |
17 | Correct | 17 ms | 23788 KB | Ok |
18 | Correct | 21 ms | 24044 KB | Ok |
19 | Correct | 43 ms | 25196 KB | Ok |
20 | Correct | 30 ms | 24428 KB | Ok |
21 | Correct | 46 ms | 25452 KB | Ok |
22 | Correct | 35 ms | 24812 KB | Ok |
23 | Correct | 17 ms | 23788 KB | Ok |
24 | Correct | 17 ms | 23788 KB | Ok |
25 | Correct | 16 ms | 23788 KB | Ok |
26 | Correct | 17 ms | 23788 KB | Ok |
27 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 11, pans = 10 |
28 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 23788 KB | Ok |
2 | Correct | 17 ms | 23788 KB | Ok |
3 | Correct | 16 ms | 23788 KB | Ok |
4 | Correct | 16 ms | 23788 KB | Ok |
5 | Correct | 17 ms | 23788 KB | Ok |
6 | Correct | 17 ms | 23788 KB | Ok |
7 | Correct | 16 ms | 23788 KB | Ok |
8 | Correct | 18 ms | 23788 KB | Ok |
9 | Correct | 16 ms | 23788 KB | Ok |
10 | Correct | 16 ms | 23788 KB | Ok |
11 | Correct | 17 ms | 23788 KB | Ok |
12 | Correct | 17 ms | 23788 KB | Ok |
13 | Correct | 17 ms | 23808 KB | Ok |
14 | Correct | 18 ms | 23788 KB | Ok |
15 | Correct | 16 ms | 23788 KB | Ok |
16 | Correct | 17 ms | 23788 KB | Ok |
17 | Correct | 17 ms | 23788 KB | Ok |
18 | Correct | 21 ms | 24044 KB | Ok |
19 | Correct | 43 ms | 25196 KB | Ok |
20 | Correct | 30 ms | 24428 KB | Ok |
21 | Correct | 46 ms | 25452 KB | Ok |
22 | Correct | 35 ms | 24812 KB | Ok |
23 | Correct | 17 ms | 23788 KB | Ok |
24 | Correct | 17 ms | 23788 KB | Ok |
25 | Correct | 16 ms | 23788 KB | Ok |
26 | Correct | 17 ms | 23788 KB | Ok |
27 | Incorrect | 17 ms | 23788 KB | Jury has the better answer : jans = 11, pans = 10 |
28 | Halted | 0 ms | 0 KB | - |