# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89409 | 2018-12-13T15:12:34 Z | nicksona | Nice sequence (IZhO18_sequence) | C++14 | 2000 ms | 66468 KB |
#include<bits/stdc++.h> #define ll long long #define pb push_back using namespace std; int n,m; int t; int M=0; vector <int> v[400001]; int mas[400001]; int fix[400001],nmas[1000001]; void top_sort (int u){ fix[u]=1; for (int i=0;i<v[u].size();i++){ int node=v[u][i]; if (fix[node]==0) top_sort(node); } mas[u]=++M; } void solve (int sz){ for (int i=0;i<=sz;i++){ if (i+n<=sz){ v[i].pb(i+n); } if (i+m<=sz){ v[i+m].pb(i); } } for (int i=0;i<=sz;i++){ if (fix[i]==0){ top_sort(i); } } for (int i=0;i<=sz;i++){ nmas[i]=mas[i]-mas[i-1]; } for (int i=0;i<=sz;i++){ fix[i]=0; v[i].clear(); } } int gcd(int a,int b){ if (a%b==0){ return b; } else{ return gcd(b,a%b); } } main () { ios::sync_with_stdio(false); cin>>t; while (t--){ cin>>n>>m; int ans=m+n-gcd(n,m)-1; M=0; solve(ans); cout<<ans<<endl; for (int i=1;i<=ans;i++){ cout<<nmas[i]<<" "; } cout<<endl; } return 0; } /* 1 2 4 _ _ _ _ | \ | | (_) | | | \| | _ ___ | | __ ___ ___ _ __ __ _ | . ` | | | / __| | |/ / / __| / _ \ | '_ \ / _` | | |\ | | | | (__ | < \__ \ | (_) | | | | | | (_| | |_| \_| |_| \___| |_|\_\ |___/ \___/ |_| |_| \__,_| */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 9720 KB | Ok |
2 | Correct | 11 ms | 9848 KB | Ok |
3 | Correct | 11 ms | 10056 KB | Ok |
4 | Correct | 11 ms | 10056 KB | Ok |
5 | Correct | 12 ms | 10056 KB | Ok |
6 | Correct | 12 ms | 10056 KB | Ok |
7 | Correct | 11 ms | 10056 KB | Ok |
8 | Correct | 12 ms | 10056 KB | Ok |
9 | Correct | 11 ms | 10056 KB | Ok |
10 | Correct | 11 ms | 10056 KB | Ok |
11 | Correct | 12 ms | 10056 KB | Ok |
12 | Correct | 11 ms | 10056 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 10056 KB | Ok |
2 | Correct | 11 ms | 10056 KB | Ok |
3 | Correct | 12 ms | 10136 KB | Ok |
4 | Correct | 12 ms | 10136 KB | Ok |
5 | Correct | 12 ms | 10136 KB | Ok |
6 | Correct | 13 ms | 10160 KB | Ok |
7 | Correct | 21 ms | 11068 KB | Ok |
8 | Correct | 20 ms | 11068 KB | Ok |
9 | Correct | 22 ms | 11112 KB | Ok |
10 | Correct | 19 ms | 11112 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 11112 KB | Ok |
2 | Correct | 10 ms | 11112 KB | Ok |
3 | Correct | 10 ms | 11112 KB | Ok |
4 | Correct | 10 ms | 11112 KB | Ok |
5 | Correct | 10 ms | 11112 KB | Ok |
6 | Correct | 10 ms | 11112 KB | Ok |
7 | Correct | 9 ms | 11112 KB | Ok |
8 | Correct | 10 ms | 11112 KB | Ok |
9 | Correct | 9 ms | 11112 KB | Ok |
10 | Correct | 10 ms | 11112 KB | Ok |
11 | Correct | 10 ms | 11112 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 11112 KB | Ok |
2 | Correct | 10 ms | 11112 KB | Ok |
3 | Correct | 10 ms | 11112 KB | Ok |
4 | Correct | 10 ms | 11112 KB | Ok |
5 | Correct | 10 ms | 11112 KB | Ok |
6 | Correct | 106 ms | 22592 KB | Ok |
7 | Correct | 110 ms | 27008 KB | Ok |
8 | Correct | 196 ms | 29780 KB | Ok |
9 | Correct | 144 ms | 29780 KB | Ok |
10 | Correct | 82 ms | 29780 KB | Ok |
11 | Correct | 120 ms | 29780 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 9720 KB | Ok |
2 | Correct | 11 ms | 9848 KB | Ok |
3 | Correct | 11 ms | 10056 KB | Ok |
4 | Correct | 11 ms | 10056 KB | Ok |
5 | Correct | 12 ms | 10056 KB | Ok |
6 | Correct | 12 ms | 10056 KB | Ok |
7 | Correct | 11 ms | 10056 KB | Ok |
8 | Correct | 12 ms | 10056 KB | Ok |
9 | Correct | 11 ms | 10056 KB | Ok |
10 | Correct | 11 ms | 10056 KB | Ok |
11 | Correct | 12 ms | 10056 KB | Ok |
12 | Correct | 11 ms | 10056 KB | Ok |
13 | Correct | 10 ms | 11112 KB | Ok |
14 | Correct | 10 ms | 11112 KB | Ok |
15 | Correct | 10 ms | 11112 KB | Ok |
16 | Correct | 10 ms | 11112 KB | Ok |
17 | Correct | 10 ms | 11112 KB | Ok |
18 | Correct | 10 ms | 11112 KB | Ok |
19 | Correct | 9 ms | 11112 KB | Ok |
20 | Correct | 10 ms | 11112 KB | Ok |
21 | Correct | 9 ms | 11112 KB | Ok |
22 | Correct | 10 ms | 11112 KB | Ok |
23 | Correct | 10 ms | 11112 KB | Ok |
24 | Correct | 14 ms | 29780 KB | Ok |
25 | Correct | 14 ms | 29780 KB | Ok |
26 | Correct | 14 ms | 29780 KB | Ok |
27 | Correct | 14 ms | 29780 KB | Ok |
28 | Correct | 13 ms | 29780 KB | Ok |
29 | Correct | 13 ms | 29780 KB | Ok |
30 | Correct | 13 ms | 29780 KB | Ok |
31 | Correct | 13 ms | 29780 KB | Ok |
32 | Correct | 13 ms | 29780 KB | Ok |
33 | Correct | 14 ms | 29780 KB | Ok |
34 | Correct | 16 ms | 29780 KB | Ok |
35 | Correct | 16 ms | 29780 KB | Ok |
36 | Correct | 16 ms | 29780 KB | Ok |
37 | Correct | 16 ms | 29780 KB | Ok |
38 | Correct | 16 ms | 29780 KB | Ok |
39 | Correct | 16 ms | 29780 KB | Ok |
40 | Correct | 16 ms | 29780 KB | Ok |
41 | Correct | 14 ms | 29780 KB | Ok |
42 | Correct | 16 ms | 29780 KB | Ok |
43 | Correct | 17 ms | 29780 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 9720 KB | Ok |
2 | Correct | 11 ms | 9848 KB | Ok |
3 | Correct | 11 ms | 10056 KB | Ok |
4 | Correct | 11 ms | 10056 KB | Ok |
5 | Correct | 12 ms | 10056 KB | Ok |
6 | Correct | 12 ms | 10056 KB | Ok |
7 | Correct | 11 ms | 10056 KB | Ok |
8 | Correct | 12 ms | 10056 KB | Ok |
9 | Correct | 11 ms | 10056 KB | Ok |
10 | Correct | 11 ms | 10056 KB | Ok |
11 | Correct | 12 ms | 10056 KB | Ok |
12 | Correct | 11 ms | 10056 KB | Ok |
13 | Correct | 11 ms | 10056 KB | Ok |
14 | Correct | 11 ms | 10056 KB | Ok |
15 | Correct | 12 ms | 10136 KB | Ok |
16 | Correct | 12 ms | 10136 KB | Ok |
17 | Correct | 12 ms | 10136 KB | Ok |
18 | Correct | 13 ms | 10160 KB | Ok |
19 | Correct | 21 ms | 11068 KB | Ok |
20 | Correct | 20 ms | 11068 KB | Ok |
21 | Correct | 22 ms | 11112 KB | Ok |
22 | Correct | 19 ms | 11112 KB | Ok |
23 | Correct | 10 ms | 11112 KB | Ok |
24 | Correct | 10 ms | 11112 KB | Ok |
25 | Correct | 10 ms | 11112 KB | Ok |
26 | Correct | 10 ms | 11112 KB | Ok |
27 | Correct | 10 ms | 11112 KB | Ok |
28 | Correct | 10 ms | 11112 KB | Ok |
29 | Correct | 9 ms | 11112 KB | Ok |
30 | Correct | 10 ms | 11112 KB | Ok |
31 | Correct | 9 ms | 11112 KB | Ok |
32 | Correct | 10 ms | 11112 KB | Ok |
33 | Correct | 10 ms | 11112 KB | Ok |
34 | Correct | 14 ms | 29780 KB | Ok |
35 | Correct | 14 ms | 29780 KB | Ok |
36 | Correct | 14 ms | 29780 KB | Ok |
37 | Correct | 14 ms | 29780 KB | Ok |
38 | Correct | 13 ms | 29780 KB | Ok |
39 | Correct | 13 ms | 29780 KB | Ok |
40 | Correct | 13 ms | 29780 KB | Ok |
41 | Correct | 13 ms | 29780 KB | Ok |
42 | Correct | 13 ms | 29780 KB | Ok |
43 | Correct | 14 ms | 29780 KB | Ok |
44 | Correct | 16 ms | 29780 KB | Ok |
45 | Correct | 16 ms | 29780 KB | Ok |
46 | Correct | 16 ms | 29780 KB | Ok |
47 | Correct | 16 ms | 29780 KB | Ok |
48 | Correct | 16 ms | 29780 KB | Ok |
49 | Correct | 16 ms | 29780 KB | Ok |
50 | Correct | 16 ms | 29780 KB | Ok |
51 | Correct | 14 ms | 29780 KB | Ok |
52 | Correct | 16 ms | 29780 KB | Ok |
53 | Correct | 17 ms | 29780 KB | Ok |
54 | Correct | 93 ms | 29780 KB | Ok |
55 | Correct | 103 ms | 29780 KB | Ok |
56 | Correct | 127 ms | 29780 KB | Ok |
57 | Correct | 76 ms | 29780 KB | Ok |
58 | Correct | 90 ms | 29780 KB | Ok |
59 | Correct | 80 ms | 29780 KB | Ok |
60 | Correct | 72 ms | 29780 KB | Ok |
61 | Correct | 79 ms | 29780 KB | Ok |
62 | Correct | 97 ms | 29780 KB | Ok |
63 | Correct | 79 ms | 29780 KB | Ok |
64 | Correct | 95 ms | 29780 KB | Ok |
65 | Correct | 84 ms | 29780 KB | Ok |
66 | Correct | 77 ms | 29780 KB | Ok |
67 | Correct | 87 ms | 29780 KB | Ok |
68 | Correct | 94 ms | 29780 KB | Ok |
69 | Correct | 228 ms | 29780 KB | Ok |
70 | Correct | 287 ms | 29780 KB | Ok |
71 | Correct | 239 ms | 29780 KB | Ok |
72 | Correct | 229 ms | 29780 KB | Ok |
73 | Correct | 262 ms | 29780 KB | Ok |
74 | Correct | 264 ms | 29780 KB | Ok |
75 | Correct | 266 ms | 29780 KB | Ok |
76 | Correct | 349 ms | 29780 KB | Ok |
77 | Correct | 190 ms | 29780 KB | Ok |
78 | Correct | 219 ms | 29780 KB | Ok |
79 | Correct | 309 ms | 29780 KB | Ok |
80 | Correct | 246 ms | 29780 KB | Ok |
81 | Correct | 214 ms | 29780 KB | Ok |
82 | Correct | 242 ms | 29780 KB | Ok |
83 | Correct | 240 ms | 29780 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 9720 KB | Ok |
2 | Correct | 11 ms | 9848 KB | Ok |
3 | Correct | 11 ms | 10056 KB | Ok |
4 | Correct | 11 ms | 10056 KB | Ok |
5 | Correct | 12 ms | 10056 KB | Ok |
6 | Correct | 12 ms | 10056 KB | Ok |
7 | Correct | 11 ms | 10056 KB | Ok |
8 | Correct | 12 ms | 10056 KB | Ok |
9 | Correct | 11 ms | 10056 KB | Ok |
10 | Correct | 11 ms | 10056 KB | Ok |
11 | Correct | 12 ms | 10056 KB | Ok |
12 | Correct | 11 ms | 10056 KB | Ok |
13 | Correct | 11 ms | 10056 KB | Ok |
14 | Correct | 11 ms | 10056 KB | Ok |
15 | Correct | 12 ms | 10136 KB | Ok |
16 | Correct | 12 ms | 10136 KB | Ok |
17 | Correct | 12 ms | 10136 KB | Ok |
18 | Correct | 13 ms | 10160 KB | Ok |
19 | Correct | 21 ms | 11068 KB | Ok |
20 | Correct | 20 ms | 11068 KB | Ok |
21 | Correct | 22 ms | 11112 KB | Ok |
22 | Correct | 19 ms | 11112 KB | Ok |
23 | Correct | 10 ms | 11112 KB | Ok |
24 | Correct | 10 ms | 11112 KB | Ok |
25 | Correct | 10 ms | 11112 KB | Ok |
26 | Correct | 10 ms | 11112 KB | Ok |
27 | Correct | 10 ms | 11112 KB | Ok |
28 | Correct | 10 ms | 11112 KB | Ok |
29 | Correct | 9 ms | 11112 KB | Ok |
30 | Correct | 10 ms | 11112 KB | Ok |
31 | Correct | 9 ms | 11112 KB | Ok |
32 | Correct | 10 ms | 11112 KB | Ok |
33 | Correct | 10 ms | 11112 KB | Ok |
34 | Correct | 10 ms | 11112 KB | Ok |
35 | Correct | 10 ms | 11112 KB | Ok |
36 | Correct | 10 ms | 11112 KB | Ok |
37 | Correct | 10 ms | 11112 KB | Ok |
38 | Correct | 10 ms | 11112 KB | Ok |
39 | Correct | 106 ms | 22592 KB | Ok |
40 | Correct | 110 ms | 27008 KB | Ok |
41 | Correct | 196 ms | 29780 KB | Ok |
42 | Correct | 144 ms | 29780 KB | Ok |
43 | Correct | 82 ms | 29780 KB | Ok |
44 | Correct | 120 ms | 29780 KB | Ok |
45 | Correct | 14 ms | 29780 KB | Ok |
46 | Correct | 14 ms | 29780 KB | Ok |
47 | Correct | 14 ms | 29780 KB | Ok |
48 | Correct | 14 ms | 29780 KB | Ok |
49 | Correct | 13 ms | 29780 KB | Ok |
50 | Correct | 13 ms | 29780 KB | Ok |
51 | Correct | 13 ms | 29780 KB | Ok |
52 | Correct | 13 ms | 29780 KB | Ok |
53 | Correct | 13 ms | 29780 KB | Ok |
54 | Correct | 14 ms | 29780 KB | Ok |
55 | Correct | 16 ms | 29780 KB | Ok |
56 | Correct | 16 ms | 29780 KB | Ok |
57 | Correct | 16 ms | 29780 KB | Ok |
58 | Correct | 16 ms | 29780 KB | Ok |
59 | Correct | 16 ms | 29780 KB | Ok |
60 | Correct | 16 ms | 29780 KB | Ok |
61 | Correct | 16 ms | 29780 KB | Ok |
62 | Correct | 14 ms | 29780 KB | Ok |
63 | Correct | 16 ms | 29780 KB | Ok |
64 | Correct | 17 ms | 29780 KB | Ok |
65 | Correct | 93 ms | 29780 KB | Ok |
66 | Correct | 103 ms | 29780 KB | Ok |
67 | Correct | 127 ms | 29780 KB | Ok |
68 | Correct | 76 ms | 29780 KB | Ok |
69 | Correct | 90 ms | 29780 KB | Ok |
70 | Correct | 80 ms | 29780 KB | Ok |
71 | Correct | 72 ms | 29780 KB | Ok |
72 | Correct | 79 ms | 29780 KB | Ok |
73 | Correct | 97 ms | 29780 KB | Ok |
74 | Correct | 79 ms | 29780 KB | Ok |
75 | Correct | 95 ms | 29780 KB | Ok |
76 | Correct | 84 ms | 29780 KB | Ok |
77 | Correct | 77 ms | 29780 KB | Ok |
78 | Correct | 87 ms | 29780 KB | Ok |
79 | Correct | 94 ms | 29780 KB | Ok |
80 | Correct | 228 ms | 29780 KB | Ok |
81 | Correct | 287 ms | 29780 KB | Ok |
82 | Correct | 239 ms | 29780 KB | Ok |
83 | Correct | 229 ms | 29780 KB | Ok |
84 | Correct | 262 ms | 29780 KB | Ok |
85 | Correct | 264 ms | 29780 KB | Ok |
86 | Correct | 266 ms | 29780 KB | Ok |
87 | Correct | 349 ms | 29780 KB | Ok |
88 | Correct | 190 ms | 29780 KB | Ok |
89 | Correct | 219 ms | 29780 KB | Ok |
90 | Correct | 309 ms | 29780 KB | Ok |
91 | Correct | 246 ms | 29780 KB | Ok |
92 | Correct | 214 ms | 29780 KB | Ok |
93 | Correct | 242 ms | 29780 KB | Ok |
94 | Correct | 240 ms | 29780 KB | Ok |
95 | Correct | 270 ms | 29780 KB | Ok |
96 | Correct | 390 ms | 31144 KB | Ok |
97 | Correct | 329 ms | 31144 KB | Ok |
98 | Correct | 238 ms | 31144 KB | Ok |
99 | Correct | 282 ms | 31144 KB | Ok |
100 | Correct | 320 ms | 31144 KB | Ok |
101 | Correct | 306 ms | 31144 KB | Ok |
102 | Correct | 281 ms | 31144 KB | Ok |
103 | Correct | 268 ms | 31144 KB | Ok |
104 | Correct | 350 ms | 31144 KB | Ok |
105 | Correct | 348 ms | 31144 KB | Ok |
106 | Correct | 324 ms | 31332 KB | Ok |
107 | Correct | 341 ms | 31332 KB | Ok |
108 | Correct | 392 ms | 31332 KB | Ok |
109 | Correct | 368 ms | 32076 KB | Ok |
110 | Correct | 1902 ms | 63944 KB | Ok |
111 | Correct | 1627 ms | 65996 KB | Ok |
112 | Correct | 1626 ms | 65996 KB | Ok |
113 | Correct | 1523 ms | 66112 KB | Ok |
114 | Correct | 1653 ms | 66468 KB | Ok |
115 | Correct | 1795 ms | 66468 KB | Ok |
116 | Execution timed out | 2028 ms | 66468 KB | Time limit exceeded |
117 | Halted | 0 ms | 0 KB | - |