# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
676873 | 2023-01-01T12:44:06 Z | YENGOYAN | Nice sequence (IZhO18_sequence) | C++17 | 1339 ms | 89092 KB |
/* //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\ \\ // // 271828___182845__904523__53602__ \\ \\ 87___47____13______52____66__24_ // // 97___75____72______47____09___36 \\ \\ 999595_____74______96____69___67 // // 62___77____24______07____66__30_ \\ \\ 35___35____47______59____45713__ // // \\ \\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\// */ #include <iostream> #include <vector> #include <set> #include <map> #include <unordered_map> #include <unordered_map> #include <cmath> #include <climits> #include <algorithm> #include <random> #include <queue> #include <deque> #include <iomanip> #include <string> #include <tuple> #include <bitset> #include <chrono> #include <ctime> #include <fstream> #include <stack> #include <cstdio> using namespace std; using ll = long long; const int N = 1e5 + 5; const ll mod = 1e9 + 7, inf = 1e12; vector<bool> vis; vector<vector<int>> gp; vector<int> order; void dfs(int u) { if (u >= vis.size()) { cout << "Co sik apushe im arev!\n"; return; } vis[u] = 1; for (int& v : gp[u]) { if (!vis[v]) { dfs(v); } } order.push_back(u); } int gcd(int a, int b) { while (b) { a %= b; swap(a, b); } return a; } vector<int> top_order(int mid, int n, int m) { ++mid; gp = vector<vector<int>> (mid); vis = vector<bool> (mid); for (int i = n; i < mid; ++i) gp[i].push_back(i - n); for (int i = m; i < mid; ++i) gp[i - m].push_back(i); order.clear(); bool f = 0; if (f) return {}; for (int i = 0; i < mid; ++i) { if (!vis[i]) dfs(i); } reverse(order.begin(), order.end()); vector<int> pref(mid); for (int i = 0; i < order.size(); ++i) pref[order[i]] = i; // return {}; vector<int> ans; for (int i = 1; i < mid; ++i) ans.push_back(pref[i] - pref[i - 1]); return ans; } void solve() { int n, m; cin >> n >> m; vector<int> ans = top_order(n + m - gcd(n, m) - 1, n, m); cout << ans.size() << "\n"; for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " "; cout << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int _; cin >> _; while (_--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 1 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 0 ms | 212 KB | Ok |
7 | Correct | 1 ms | 212 KB | Ok |
8 | Correct | 1 ms | 212 KB | Ok |
9 | Correct | 0 ms | 212 KB | Ok |
10 | Correct | 0 ms | 212 KB | Ok |
11 | Correct | 1 ms | 212 KB | Ok |
12 | Correct | 1 ms | 212 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 0 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 3 ms | 596 KB | Ok |
7 | Correct | 12 ms | 1720 KB | Ok |
8 | Correct | 6 ms | 1116 KB | Ok |
9 | Correct | 14 ms | 2004 KB | Ok |
10 | Correct | 8 ms | 1220 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 0 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 0 ms | 212 KB | Ok |
7 | Correct | 0 ms | 212 KB | Ok |
8 | Correct | 0 ms | 212 KB | Ok |
9 | Correct | 0 ms | 212 KB | Ok |
10 | Correct | 0 ms | 212 KB | Ok |
11 | Correct | 0 ms | 212 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 0 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 122 ms | 22112 KB | Ok |
7 | Correct | 98 ms | 21328 KB | Ok |
8 | Correct | 185 ms | 27964 KB | Ok |
9 | Correct | 144 ms | 22156 KB | Ok |
10 | Correct | 87 ms | 15240 KB | Ok |
11 | Correct | 141 ms | 32960 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 1 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 0 ms | 212 KB | Ok |
7 | Correct | 1 ms | 212 KB | Ok |
8 | Correct | 1 ms | 212 KB | Ok |
9 | Correct | 0 ms | 212 KB | Ok |
10 | Correct | 0 ms | 212 KB | Ok |
11 | Correct | 1 ms | 212 KB | Ok |
12 | Correct | 1 ms | 212 KB | Ok |
13 | Correct | 1 ms | 212 KB | Ok |
14 | Correct | 0 ms | 212 KB | Ok |
15 | Correct | 0 ms | 212 KB | Ok |
16 | Correct | 0 ms | 212 KB | Ok |
17 | Correct | 0 ms | 212 KB | Ok |
18 | Correct | 0 ms | 212 KB | Ok |
19 | Correct | 0 ms | 212 KB | Ok |
20 | Correct | 0 ms | 212 KB | Ok |
21 | Correct | 0 ms | 212 KB | Ok |
22 | Correct | 0 ms | 212 KB | Ok |
23 | Correct | 0 ms | 212 KB | Ok |
24 | Correct | 3 ms | 596 KB | Ok |
25 | Correct | 2 ms | 580 KB | Ok |
26 | Correct | 2 ms | 596 KB | Ok |
27 | Correct | 3 ms | 596 KB | Ok |
28 | Correct | 2 ms | 468 KB | Ok |
29 | Correct | 2 ms | 468 KB | Ok |
30 | Correct | 2 ms | 468 KB | Ok |
31 | Correct | 2 ms | 596 KB | Ok |
32 | Correct | 2 ms | 596 KB | Ok |
33 | Correct | 2 ms | 596 KB | Ok |
34 | Correct | 5 ms | 948 KB | Ok |
35 | Correct | 6 ms | 960 KB | Ok |
36 | Correct | 5 ms | 968 KB | Ok |
37 | Correct | 5 ms | 940 KB | Ok |
38 | Correct | 5 ms | 952 KB | Ok |
39 | Correct | 5 ms | 948 KB | Ok |
40 | Correct | 6 ms | 936 KB | Ok |
41 | Correct | 5 ms | 940 KB | Ok |
42 | Correct | 5 ms | 1072 KB | Ok |
43 | Correct | 5 ms | 980 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 1 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 0 ms | 212 KB | Ok |
7 | Correct | 1 ms | 212 KB | Ok |
8 | Correct | 1 ms | 212 KB | Ok |
9 | Correct | 0 ms | 212 KB | Ok |
10 | Correct | 0 ms | 212 KB | Ok |
11 | Correct | 1 ms | 212 KB | Ok |
12 | Correct | 1 ms | 212 KB | Ok |
13 | Correct | 1 ms | 212 KB | Ok |
14 | Correct | 0 ms | 212 KB | Ok |
15 | Correct | 0 ms | 212 KB | Ok |
16 | Correct | 0 ms | 212 KB | Ok |
17 | Correct | 0 ms | 212 KB | Ok |
18 | Correct | 3 ms | 596 KB | Ok |
19 | Correct | 12 ms | 1720 KB | Ok |
20 | Correct | 6 ms | 1116 KB | Ok |
21 | Correct | 14 ms | 2004 KB | Ok |
22 | Correct | 8 ms | 1220 KB | Ok |
23 | Correct | 1 ms | 212 KB | Ok |
24 | Correct | 0 ms | 212 KB | Ok |
25 | Correct | 0 ms | 212 KB | Ok |
26 | Correct | 0 ms | 212 KB | Ok |
27 | Correct | 0 ms | 212 KB | Ok |
28 | Correct | 0 ms | 212 KB | Ok |
29 | Correct | 0 ms | 212 KB | Ok |
30 | Correct | 0 ms | 212 KB | Ok |
31 | Correct | 0 ms | 212 KB | Ok |
32 | Correct | 0 ms | 212 KB | Ok |
33 | Correct | 0 ms | 212 KB | Ok |
34 | Correct | 3 ms | 596 KB | Ok |
35 | Correct | 2 ms | 580 KB | Ok |
36 | Correct | 2 ms | 596 KB | Ok |
37 | Correct | 3 ms | 596 KB | Ok |
38 | Correct | 2 ms | 468 KB | Ok |
39 | Correct | 2 ms | 468 KB | Ok |
40 | Correct | 2 ms | 468 KB | Ok |
41 | Correct | 2 ms | 596 KB | Ok |
42 | Correct | 2 ms | 596 KB | Ok |
43 | Correct | 2 ms | 596 KB | Ok |
44 | Correct | 5 ms | 948 KB | Ok |
45 | Correct | 6 ms | 960 KB | Ok |
46 | Correct | 5 ms | 968 KB | Ok |
47 | Correct | 5 ms | 940 KB | Ok |
48 | Correct | 5 ms | 952 KB | Ok |
49 | Correct | 5 ms | 948 KB | Ok |
50 | Correct | 6 ms | 936 KB | Ok |
51 | Correct | 5 ms | 940 KB | Ok |
52 | Correct | 5 ms | 1072 KB | Ok |
53 | Correct | 5 ms | 980 KB | Ok |
54 | Correct | 92 ms | 10656 KB | Ok |
55 | Correct | 100 ms | 11956 KB | Ok |
56 | Correct | 95 ms | 11912 KB | Ok |
57 | Correct | 69 ms | 9280 KB | Ok |
58 | Correct | 90 ms | 9408 KB | Ok |
59 | Correct | 83 ms | 10448 KB | Ok |
60 | Correct | 71 ms | 9120 KB | Ok |
61 | Correct | 71 ms | 8600 KB | Ok |
62 | Correct | 105 ms | 11144 KB | Ok |
63 | Correct | 75 ms | 9940 KB | Ok |
64 | Correct | 103 ms | 11932 KB | Ok |
65 | Correct | 91 ms | 10860 KB | Ok |
66 | Correct | 82 ms | 9560 KB | Ok |
67 | Correct | 77 ms | 9288 KB | Ok |
68 | Correct | 88 ms | 10588 KB | Ok |
69 | Correct | 194 ms | 19436 KB | Ok |
70 | Correct | 206 ms | 21152 KB | Ok |
71 | Correct | 196 ms | 18996 KB | Ok |
72 | Correct | 183 ms | 21496 KB | Ok |
73 | Correct | 197 ms | 18836 KB | Ok |
74 | Correct | 174 ms | 20416 KB | Ok |
75 | Correct | 185 ms | 19064 KB | Ok |
76 | Correct | 188 ms | 21788 KB | Ok |
77 | Correct | 175 ms | 19404 KB | Ok |
78 | Correct | 207 ms | 20676 KB | Ok |
79 | Correct | 186 ms | 18692 KB | Ok |
80 | Correct | 182 ms | 19336 KB | Ok |
81 | Correct | 193 ms | 19488 KB | Ok |
82 | Correct | 184 ms | 20504 KB | Ok |
83 | Correct | 172 ms | 21824 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Ok |
2 | Correct | 0 ms | 212 KB | Ok |
3 | Correct | 0 ms | 212 KB | Ok |
4 | Correct | 1 ms | 212 KB | Ok |
5 | Correct | 0 ms | 212 KB | Ok |
6 | Correct | 0 ms | 212 KB | Ok |
7 | Correct | 1 ms | 212 KB | Ok |
8 | Correct | 1 ms | 212 KB | Ok |
9 | Correct | 0 ms | 212 KB | Ok |
10 | Correct | 0 ms | 212 KB | Ok |
11 | Correct | 1 ms | 212 KB | Ok |
12 | Correct | 1 ms | 212 KB | Ok |
13 | Correct | 1 ms | 212 KB | Ok |
14 | Correct | 0 ms | 212 KB | Ok |
15 | Correct | 0 ms | 212 KB | Ok |
16 | Correct | 0 ms | 212 KB | Ok |
17 | Correct | 0 ms | 212 KB | Ok |
18 | Correct | 3 ms | 596 KB | Ok |
19 | Correct | 12 ms | 1720 KB | Ok |
20 | Correct | 6 ms | 1116 KB | Ok |
21 | Correct | 14 ms | 2004 KB | Ok |
22 | Correct | 8 ms | 1220 KB | Ok |
23 | Correct | 1 ms | 212 KB | Ok |
24 | Correct | 0 ms | 212 KB | Ok |
25 | Correct | 0 ms | 212 KB | Ok |
26 | Correct | 0 ms | 212 KB | Ok |
27 | Correct | 0 ms | 212 KB | Ok |
28 | Correct | 0 ms | 212 KB | Ok |
29 | Correct | 0 ms | 212 KB | Ok |
30 | Correct | 0 ms | 212 KB | Ok |
31 | Correct | 0 ms | 212 KB | Ok |
32 | Correct | 0 ms | 212 KB | Ok |
33 | Correct | 0 ms | 212 KB | Ok |
34 | Correct | 0 ms | 212 KB | Ok |
35 | Correct | 0 ms | 212 KB | Ok |
36 | Correct | 0 ms | 212 KB | Ok |
37 | Correct | 0 ms | 212 KB | Ok |
38 | Correct | 0 ms | 212 KB | Ok |
39 | Correct | 122 ms | 22112 KB | Ok |
40 | Correct | 98 ms | 21328 KB | Ok |
41 | Correct | 185 ms | 27964 KB | Ok |
42 | Correct | 144 ms | 22156 KB | Ok |
43 | Correct | 87 ms | 15240 KB | Ok |
44 | Correct | 141 ms | 32960 KB | Ok |
45 | Correct | 3 ms | 596 KB | Ok |
46 | Correct | 2 ms | 580 KB | Ok |
47 | Correct | 2 ms | 596 KB | Ok |
48 | Correct | 3 ms | 596 KB | Ok |
49 | Correct | 2 ms | 468 KB | Ok |
50 | Correct | 2 ms | 468 KB | Ok |
51 | Correct | 2 ms | 468 KB | Ok |
52 | Correct | 2 ms | 596 KB | Ok |
53 | Correct | 2 ms | 596 KB | Ok |
54 | Correct | 2 ms | 596 KB | Ok |
55 | Correct | 5 ms | 948 KB | Ok |
56 | Correct | 6 ms | 960 KB | Ok |
57 | Correct | 5 ms | 968 KB | Ok |
58 | Correct | 5 ms | 940 KB | Ok |
59 | Correct | 5 ms | 952 KB | Ok |
60 | Correct | 5 ms | 948 KB | Ok |
61 | Correct | 6 ms | 936 KB | Ok |
62 | Correct | 5 ms | 940 KB | Ok |
63 | Correct | 5 ms | 1072 KB | Ok |
64 | Correct | 5 ms | 980 KB | Ok |
65 | Correct | 92 ms | 10656 KB | Ok |
66 | Correct | 100 ms | 11956 KB | Ok |
67 | Correct | 95 ms | 11912 KB | Ok |
68 | Correct | 69 ms | 9280 KB | Ok |
69 | Correct | 90 ms | 9408 KB | Ok |
70 | Correct | 83 ms | 10448 KB | Ok |
71 | Correct | 71 ms | 9120 KB | Ok |
72 | Correct | 71 ms | 8600 KB | Ok |
73 | Correct | 105 ms | 11144 KB | Ok |
74 | Correct | 75 ms | 9940 KB | Ok |
75 | Correct | 103 ms | 11932 KB | Ok |
76 | Correct | 91 ms | 10860 KB | Ok |
77 | Correct | 82 ms | 9560 KB | Ok |
78 | Correct | 77 ms | 9288 KB | Ok |
79 | Correct | 88 ms | 10588 KB | Ok |
80 | Correct | 194 ms | 19436 KB | Ok |
81 | Correct | 206 ms | 21152 KB | Ok |
82 | Correct | 196 ms | 18996 KB | Ok |
83 | Correct | 183 ms | 21496 KB | Ok |
84 | Correct | 197 ms | 18836 KB | Ok |
85 | Correct | 174 ms | 20416 KB | Ok |
86 | Correct | 185 ms | 19064 KB | Ok |
87 | Correct | 188 ms | 21788 KB | Ok |
88 | Correct | 175 ms | 19404 KB | Ok |
89 | Correct | 207 ms | 20676 KB | Ok |
90 | Correct | 186 ms | 18692 KB | Ok |
91 | Correct | 182 ms | 19336 KB | Ok |
92 | Correct | 193 ms | 19488 KB | Ok |
93 | Correct | 184 ms | 20504 KB | Ok |
94 | Correct | 172 ms | 21824 KB | Ok |
95 | Correct | 204 ms | 26268 KB | Ok |
96 | Correct | 303 ms | 40840 KB | Ok |
97 | Correct | 299 ms | 34404 KB | Ok |
98 | Correct | 215 ms | 29856 KB | Ok |
99 | Correct | 259 ms | 29400 KB | Ok |
100 | Correct | 294 ms | 33968 KB | Ok |
101 | Correct | 273 ms | 34652 KB | Ok |
102 | Correct | 248 ms | 31532 KB | Ok |
103 | Correct | 255 ms | 34880 KB | Ok |
104 | Correct | 305 ms | 36920 KB | Ok |
105 | Correct | 299 ms | 41576 KB | Ok |
106 | Correct | 232 ms | 35352 KB | Ok |
107 | Correct | 274 ms | 38744 KB | Ok |
108 | Correct | 320 ms | 39368 KB | Ok |
109 | Correct | 266 ms | 32748 KB | Ok |
110 | Correct | 1057 ms | 88124 KB | Ok |
111 | Correct | 1261 ms | 88720 KB | Ok |
112 | Correct | 1179 ms | 82732 KB | Ok |
113 | Correct | 1080 ms | 88248 KB | Ok |
114 | Correct | 1215 ms | 72428 KB | Ok |
115 | Correct | 1339 ms | 87692 KB | Ok |
116 | Correct | 1293 ms | 87760 KB | Ok |
117 | Correct | 1150 ms | 87380 KB | Ok |
118 | Correct | 1221 ms | 80084 KB | Ok |
119 | Correct | 1287 ms | 86672 KB | Ok |
120 | Correct | 1211 ms | 89092 KB | Ok |
121 | Correct | 1150 ms | 85596 KB | Ok |
122 | Correct | 1168 ms | 79320 KB | Ok |
123 | Correct | 1286 ms | 76548 KB | Ok |
124 | Correct | 1117 ms | 76092 KB | Ok |
125 | Correct | 550 ms | 62052 KB | Ok |