# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
338119 | 2020-12-22T14:12:32 Z | BeanZ | Nice sequence (IZhO18_sequence) | C++14 | 2000 ms | 95600 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; if (u >= m && vis[u - m] == 0) dfs(u - m, mid); if ((u + n) <= mid && vis[u + n] == 0) dfs(u + n, 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 u = 0; u <= mid; u++){ if (u >= m && id[u] < id[u - m]) return false; if ((u + n) <= mid && id[u] < id[u + n]) 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 = 4e5 + 1; 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 | 283 ms | 88928 KB | Ok |
2 | Correct | 274 ms | 88928 KB | Ok |
3 | Correct | 261 ms | 83040 KB | Ok |
4 | Correct | 261 ms | 83680 KB | Ok |
5 | Correct | 277 ms | 83040 KB | Ok |
6 | Correct | 263 ms | 84192 KB | Ok |
7 | Correct | 266 ms | 82912 KB | Ok |
8 | Correct | 263 ms | 84192 KB | Ok |
9 | Correct | 265 ms | 83168 KB | Ok |
10 | Correct | 282 ms | 85856 KB | Ok |
11 | Correct | 262 ms | 82912 KB | Ok |
12 | Correct | 255 ms | 82784 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 287 ms | 89056 KB | Ok |
2 | Correct | 302 ms | 88928 KB | Ok |
3 | Correct | 272 ms | 88928 KB | Ok |
4 | Correct | 286 ms | 88928 KB | Ok |
5 | Correct | 280 ms | 88928 KB | Ok |
6 | Correct | 278 ms | 88800 KB | Ok |
7 | Correct | 294 ms | 88160 KB | Ok |
8 | Correct | 293 ms | 88800 KB | Ok |
9 | Correct | 301 ms | 88160 KB | Ok |
10 | Correct | 294 ms | 88928 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 122 ms | 51552 KB | Ok |
2 | Correct | 291 ms | 88928 KB | Ok |
3 | Correct | 272 ms | 89044 KB | Ok |
4 | Correct | 288 ms | 88928 KB | Ok |
5 | Correct | 281 ms | 88880 KB | Ok |
6 | Correct | 292 ms | 88928 KB | Ok |
7 | Correct | 281 ms | 88928 KB | Ok |
8 | Correct | 286 ms | 88928 KB | Ok |
9 | Correct | 281 ms | 89056 KB | Ok |
10 | Correct | 287 ms | 88928 KB | Ok |
11 | Correct | 285 ms | 88928 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 290 ms | 88928 KB | Ok |
2 | Correct | 312 ms | 89056 KB | Ok |
3 | Correct | 297 ms | 88928 KB | Ok |
4 | Correct | 306 ms | 89204 KB | Ok |
5 | Correct | 292 ms | 88928 KB | Ok |
6 | Correct | 562 ms | 86496 KB | Ok |
7 | Correct | 554 ms | 86112 KB | Ok |
8 | Correct | 825 ms | 84064 KB | Ok |
9 | Correct | 648 ms | 86808 KB | Ok |
10 | Correct | 504 ms | 85984 KB | Ok |
11 | Correct | 607 ms | 83424 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 283 ms | 88928 KB | Ok |
2 | Correct | 274 ms | 88928 KB | Ok |
3 | Correct | 261 ms | 83040 KB | Ok |
4 | Correct | 261 ms | 83680 KB | Ok |
5 | Correct | 277 ms | 83040 KB | Ok |
6 | Correct | 263 ms | 84192 KB | Ok |
7 | Correct | 266 ms | 82912 KB | Ok |
8 | Correct | 263 ms | 84192 KB | Ok |
9 | Correct | 265 ms | 83168 KB | Ok |
10 | Correct | 282 ms | 85856 KB | Ok |
11 | Correct | 262 ms | 82912 KB | Ok |
12 | Correct | 255 ms | 82784 KB | Ok |
13 | Correct | 122 ms | 51552 KB | Ok |
14 | Correct | 291 ms | 88928 KB | Ok |
15 | Correct | 272 ms | 89044 KB | Ok |
16 | Correct | 288 ms | 88928 KB | Ok |
17 | Correct | 281 ms | 88880 KB | Ok |
18 | Correct | 292 ms | 88928 KB | Ok |
19 | Correct | 281 ms | 88928 KB | Ok |
20 | Correct | 286 ms | 88928 KB | Ok |
21 | Correct | 281 ms | 89056 KB | Ok |
22 | Correct | 287 ms | 88928 KB | Ok |
23 | Correct | 285 ms | 88928 KB | Ok |
24 | Correct | 274 ms | 82528 KB | Ok |
25 | Correct | 271 ms | 82704 KB | Ok |
26 | Correct | 271 ms | 82820 KB | Ok |
27 | Correct | 275 ms | 82912 KB | Ok |
28 | Correct | 272 ms | 82656 KB | Ok |
29 | Correct | 271 ms | 84704 KB | Ok |
30 | Correct | 272 ms | 82912 KB | Ok |
31 | Correct | 286 ms | 82656 KB | Ok |
32 | Correct | 274 ms | 82656 KB | Ok |
33 | Correct | 273 ms | 82912 KB | Ok |
34 | Correct | 304 ms | 88800 KB | Ok |
35 | Correct | 304 ms | 88860 KB | Ok |
36 | Correct | 294 ms | 88800 KB | Ok |
37 | Correct | 308 ms | 88928 KB | Ok |
38 | Correct | 300 ms | 88800 KB | Ok |
39 | Correct | 298 ms | 88800 KB | Ok |
40 | Correct | 310 ms | 88800 KB | Ok |
41 | Correct | 303 ms | 88800 KB | Ok |
42 | Correct | 296 ms | 88800 KB | Ok |
43 | Correct | 304 ms | 88816 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 283 ms | 88928 KB | Ok |
2 | Correct | 274 ms | 88928 KB | Ok |
3 | Correct | 261 ms | 83040 KB | Ok |
4 | Correct | 261 ms | 83680 KB | Ok |
5 | Correct | 277 ms | 83040 KB | Ok |
6 | Correct | 263 ms | 84192 KB | Ok |
7 | Correct | 266 ms | 82912 KB | Ok |
8 | Correct | 263 ms | 84192 KB | Ok |
9 | Correct | 265 ms | 83168 KB | Ok |
10 | Correct | 282 ms | 85856 KB | Ok |
11 | Correct | 262 ms | 82912 KB | Ok |
12 | Correct | 255 ms | 82784 KB | Ok |
13 | Correct | 287 ms | 89056 KB | Ok |
14 | Correct | 302 ms | 88928 KB | Ok |
15 | Correct | 272 ms | 88928 KB | Ok |
16 | Correct | 286 ms | 88928 KB | Ok |
17 | Correct | 280 ms | 88928 KB | Ok |
18 | Correct | 278 ms | 88800 KB | Ok |
19 | Correct | 294 ms | 88160 KB | Ok |
20 | Correct | 293 ms | 88800 KB | Ok |
21 | Correct | 301 ms | 88160 KB | Ok |
22 | Correct | 294 ms | 88928 KB | Ok |
23 | Correct | 122 ms | 51552 KB | Ok |
24 | Correct | 291 ms | 88928 KB | Ok |
25 | Correct | 272 ms | 89044 KB | Ok |
26 | Correct | 288 ms | 88928 KB | Ok |
27 | Correct | 281 ms | 88880 KB | Ok |
28 | Correct | 292 ms | 88928 KB | Ok |
29 | Correct | 281 ms | 88928 KB | Ok |
30 | Correct | 286 ms | 88928 KB | Ok |
31 | Correct | 281 ms | 89056 KB | Ok |
32 | Correct | 287 ms | 88928 KB | Ok |
33 | Correct | 285 ms | 88928 KB | Ok |
34 | Correct | 274 ms | 82528 KB | Ok |
35 | Correct | 271 ms | 82704 KB | Ok |
36 | Correct | 271 ms | 82820 KB | Ok |
37 | Correct | 275 ms | 82912 KB | Ok |
38 | Correct | 272 ms | 82656 KB | Ok |
39 | Correct | 271 ms | 84704 KB | Ok |
40 | Correct | 272 ms | 82912 KB | Ok |
41 | Correct | 286 ms | 82656 KB | Ok |
42 | Correct | 274 ms | 82656 KB | Ok |
43 | Correct | 273 ms | 82912 KB | Ok |
44 | Correct | 304 ms | 88800 KB | Ok |
45 | Correct | 304 ms | 88860 KB | Ok |
46 | Correct | 294 ms | 88800 KB | Ok |
47 | Correct | 308 ms | 88928 KB | Ok |
48 | Correct | 300 ms | 88800 KB | Ok |
49 | Correct | 298 ms | 88800 KB | Ok |
50 | Correct | 310 ms | 88800 KB | Ok |
51 | Correct | 303 ms | 88800 KB | Ok |
52 | Correct | 296 ms | 88800 KB | Ok |
53 | Correct | 304 ms | 88816 KB | Ok |
54 | Correct | 446 ms | 78580 KB | Ok |
55 | Correct | 491 ms | 78976 KB | Ok |
56 | Correct | 478 ms | 79072 KB | Ok |
57 | Correct | 402 ms | 79072 KB | Ok |
58 | Correct | 448 ms | 78560 KB | Ok |
59 | Correct | 418 ms | 78356 KB | Ok |
60 | Correct | 396 ms | 78452 KB | Ok |
61 | Correct | 403 ms | 78816 KB | Ok |
62 | Correct | 481 ms | 78944 KB | Ok |
63 | Correct | 418 ms | 78816 KB | Ok |
64 | Correct | 467 ms | 79072 KB | Ok |
65 | Correct | 448 ms | 78816 KB | Ok |
66 | Correct | 425 ms | 78560 KB | Ok |
67 | Correct | 400 ms | 78816 KB | Ok |
68 | Correct | 421 ms | 79200 KB | Ok |
69 | Correct | 647 ms | 88544 KB | Ok |
70 | Correct | 651 ms | 89312 KB | Ok |
71 | Correct | 624 ms | 88672 KB | Ok |
72 | Correct | 672 ms | 88604 KB | Ok |
73 | Correct | 630 ms | 88800 KB | Ok |
74 | Correct | 644 ms | 88672 KB | Ok |
75 | Correct | 651 ms | 88288 KB | Ok |
76 | Correct | 665 ms | 88928 KB | Ok |
77 | Correct | 643 ms | 88032 KB | Ok |
78 | Correct | 655 ms | 88928 KB | Ok |
79 | Correct | 668 ms | 88800 KB | Ok |
80 | Correct | 666 ms | 88800 KB | Ok |
81 | Correct | 661 ms | 88672 KB | Ok |
82 | Correct | 647 ms | 88800 KB | Ok |
83 | Correct | 633 ms | 88160 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 283 ms | 88928 KB | Ok |
2 | Correct | 274 ms | 88928 KB | Ok |
3 | Correct | 261 ms | 83040 KB | Ok |
4 | Correct | 261 ms | 83680 KB | Ok |
5 | Correct | 277 ms | 83040 KB | Ok |
6 | Correct | 263 ms | 84192 KB | Ok |
7 | Correct | 266 ms | 82912 KB | Ok |
8 | Correct | 263 ms | 84192 KB | Ok |
9 | Correct | 265 ms | 83168 KB | Ok |
10 | Correct | 282 ms | 85856 KB | Ok |
11 | Correct | 262 ms | 82912 KB | Ok |
12 | Correct | 255 ms | 82784 KB | Ok |
13 | Correct | 287 ms | 89056 KB | Ok |
14 | Correct | 302 ms | 88928 KB | Ok |
15 | Correct | 272 ms | 88928 KB | Ok |
16 | Correct | 286 ms | 88928 KB | Ok |
17 | Correct | 280 ms | 88928 KB | Ok |
18 | Correct | 278 ms | 88800 KB | Ok |
19 | Correct | 294 ms | 88160 KB | Ok |
20 | Correct | 293 ms | 88800 KB | Ok |
21 | Correct | 301 ms | 88160 KB | Ok |
22 | Correct | 294 ms | 88928 KB | Ok |
23 | Correct | 122 ms | 51552 KB | Ok |
24 | Correct | 291 ms | 88928 KB | Ok |
25 | Correct | 272 ms | 89044 KB | Ok |
26 | Correct | 288 ms | 88928 KB | Ok |
27 | Correct | 281 ms | 88880 KB | Ok |
28 | Correct | 292 ms | 88928 KB | Ok |
29 | Correct | 281 ms | 88928 KB | Ok |
30 | Correct | 286 ms | 88928 KB | Ok |
31 | Correct | 281 ms | 89056 KB | Ok |
32 | Correct | 287 ms | 88928 KB | Ok |
33 | Correct | 285 ms | 88928 KB | Ok |
34 | Correct | 290 ms | 88928 KB | Ok |
35 | Correct | 312 ms | 89056 KB | Ok |
36 | Correct | 297 ms | 88928 KB | Ok |
37 | Correct | 306 ms | 89204 KB | Ok |
38 | Correct | 292 ms | 88928 KB | Ok |
39 | Correct | 562 ms | 86496 KB | Ok |
40 | Correct | 554 ms | 86112 KB | Ok |
41 | Correct | 825 ms | 84064 KB | Ok |
42 | Correct | 648 ms | 86808 KB | Ok |
43 | Correct | 504 ms | 85984 KB | Ok |
44 | Correct | 607 ms | 83424 KB | Ok |
45 | Correct | 274 ms | 82528 KB | Ok |
46 | Correct | 271 ms | 82704 KB | Ok |
47 | Correct | 271 ms | 82820 KB | Ok |
48 | Correct | 275 ms | 82912 KB | Ok |
49 | Correct | 272 ms | 82656 KB | Ok |
50 | Correct | 271 ms | 84704 KB | Ok |
51 | Correct | 272 ms | 82912 KB | Ok |
52 | Correct | 286 ms | 82656 KB | Ok |
53 | Correct | 274 ms | 82656 KB | Ok |
54 | Correct | 273 ms | 82912 KB | Ok |
55 | Correct | 304 ms | 88800 KB | Ok |
56 | Correct | 304 ms | 88860 KB | Ok |
57 | Correct | 294 ms | 88800 KB | Ok |
58 | Correct | 308 ms | 88928 KB | Ok |
59 | Correct | 300 ms | 88800 KB | Ok |
60 | Correct | 298 ms | 88800 KB | Ok |
61 | Correct | 310 ms | 88800 KB | Ok |
62 | Correct | 303 ms | 88800 KB | Ok |
63 | Correct | 296 ms | 88800 KB | Ok |
64 | Correct | 304 ms | 88816 KB | Ok |
65 | Correct | 446 ms | 78580 KB | Ok |
66 | Correct | 491 ms | 78976 KB | Ok |
67 | Correct | 478 ms | 79072 KB | Ok |
68 | Correct | 402 ms | 79072 KB | Ok |
69 | Correct | 448 ms | 78560 KB | Ok |
70 | Correct | 418 ms | 78356 KB | Ok |
71 | Correct | 396 ms | 78452 KB | Ok |
72 | Correct | 403 ms | 78816 KB | Ok |
73 | Correct | 481 ms | 78944 KB | Ok |
74 | Correct | 418 ms | 78816 KB | Ok |
75 | Correct | 467 ms | 79072 KB | Ok |
76 | Correct | 448 ms | 78816 KB | Ok |
77 | Correct | 425 ms | 78560 KB | Ok |
78 | Correct | 400 ms | 78816 KB | Ok |
79 | Correct | 421 ms | 79200 KB | Ok |
80 | Correct | 647 ms | 88544 KB | Ok |
81 | Correct | 651 ms | 89312 KB | Ok |
82 | Correct | 624 ms | 88672 KB | Ok |
83 | Correct | 672 ms | 88604 KB | Ok |
84 | Correct | 630 ms | 88800 KB | Ok |
85 | Correct | 644 ms | 88672 KB | Ok |
86 | Correct | 651 ms | 88288 KB | Ok |
87 | Correct | 665 ms | 88928 KB | Ok |
88 | Correct | 643 ms | 88032 KB | Ok |
89 | Correct | 655 ms | 88928 KB | Ok |
90 | Correct | 668 ms | 88800 KB | Ok |
91 | Correct | 666 ms | 88800 KB | Ok |
92 | Correct | 661 ms | 88672 KB | Ok |
93 | Correct | 647 ms | 88800 KB | Ok |
94 | Correct | 633 ms | 88160 KB | Ok |
95 | Correct | 698 ms | 73436 KB | Ok |
96 | Correct | 945 ms | 69512 KB | Ok |
97 | Correct | 915 ms | 70748 KB | Ok |
98 | Correct | 700 ms | 69816 KB | Ok |
99 | Correct | 831 ms | 70316 KB | Ok |
100 | Correct | 887 ms | 72076 KB | Ok |
101 | Correct | 871 ms | 70236 KB | Ok |
102 | Correct | 832 ms | 69888 KB | Ok |
103 | Correct | 833 ms | 70492 KB | Ok |
104 | Correct | 953 ms | 68572 KB | Ok |
105 | Correct | 922 ms | 71004 KB | Ok |
106 | Correct | 802 ms | 69468 KB | Ok |
107 | Correct | 859 ms | 68956 KB | Ok |
108 | Correct | 959 ms | 70236 KB | Ok |
109 | Correct | 901 ms | 70108 KB | Ok |
110 | Execution timed out | 2062 ms | 95600 KB | Time limit exceeded |
111 | Halted | 0 ms | 0 KB | - |