Submission #93882

# Submission time Handle Problem Language Result Execution time Memory
93882 2019-01-12T19:46:01 Z dalgerok Nice sequence (IZhO18_sequence) C++14
76 / 100
96 ms 9336 KB
#include<bits/stdc++.h>
using namespace std;


const int N = 2e5 + 5;




int n, m, pref[N], timer, ans;


void dfs(int v){
    if(v - m >= 0 && pref[v - m] == 0){
        dfs(v - m);
    }
    if(v + n <= ans && pref[v + n] == 0){
        dfs(v + n);
    }
    pref[v] = ++timer;
}

void solve(){
    cin >> n >> m;
    ans = n + m - 1 - __gcd(n, m);
    memset(pref, 0, sizeof(pref));
    timer = 0;
    for(int i = 0; i <= ans; i++){
        if(!pref[i]){
            dfs(i);
        }
    }
    cout << ans << "\n";
    for(int i = 1; i <= ans; i++){
        cout << pref[i] - pref[i - 1] << " ";
    }
    if(ans > 0){
        cout << "\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int test;
    cin >> test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Ok
2 Correct 3 ms 1144 KB Ok
3 Correct 3 ms 1144 KB Ok
4 Correct 3 ms 1144 KB Ok
5 Correct 3 ms 1144 KB Ok
6 Correct 3 ms 1144 KB Ok
7 Correct 3 ms 1144 KB Ok
8 Correct 3 ms 1144 KB Ok
9 Correct 3 ms 1144 KB Ok
10 Correct 3 ms 1144 KB Ok
11 Correct 3 ms 1144 KB Ok
12 Correct 3 ms 1144 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Ok
2 Correct 2 ms 1144 KB Ok
3 Correct 3 ms 1144 KB Ok
4 Correct 2 ms 1148 KB Ok
5 Correct 3 ms 1192 KB Ok
6 Correct 4 ms 1144 KB Ok
7 Correct 9 ms 1660 KB Ok
8 Correct 6 ms 1272 KB Ok
9 Correct 9 ms 1656 KB Ok
10 Correct 7 ms 1528 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1144 KB Ok
2 Correct 3 ms 1144 KB Ok
3 Correct 2 ms 1144 KB Ok
4 Correct 3 ms 1144 KB Ok
5 Correct 3 ms 1144 KB Ok
6 Correct 2 ms 1144 KB Ok
7 Correct 2 ms 1144 KB Ok
8 Correct 3 ms 1144 KB Ok
9 Correct 3 ms 1144 KB Ok
10 Correct 2 ms 1144 KB Ok
11 Correct 3 ms 1144 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Ok
2 Correct 3 ms 1144 KB Ok
3 Correct 4 ms 1144 KB Ok
4 Correct 3 ms 1144 KB Ok
5 Correct 2 ms 1144 KB Ok
6 Correct 59 ms 5564 KB Ok
7 Correct 47 ms 6264 KB Ok
8 Correct 93 ms 9336 KB Ok
9 Correct 76 ms 8440 KB Ok
10 Correct 44 ms 3832 KB Ok
11 Correct 66 ms 6136 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Ok
2 Correct 3 ms 1144 KB Ok
3 Correct 3 ms 1144 KB Ok
4 Correct 3 ms 1144 KB Ok
5 Correct 3 ms 1144 KB Ok
6 Correct 3 ms 1144 KB Ok
7 Correct 3 ms 1144 KB Ok
8 Correct 3 ms 1144 KB Ok
9 Correct 3 ms 1144 KB Ok
10 Correct 3 ms 1144 KB Ok
11 Correct 3 ms 1144 KB Ok
12 Correct 3 ms 1144 KB Ok
13 Correct 2 ms 1144 KB Ok
14 Correct 3 ms 1144 KB Ok
15 Correct 2 ms 1144 KB Ok
16 Correct 3 ms 1144 KB Ok
17 Correct 3 ms 1144 KB Ok
18 Correct 2 ms 1144 KB Ok
19 Correct 2 ms 1144 KB Ok
20 Correct 3 ms 1144 KB Ok
21 Correct 3 ms 1144 KB Ok
22 Correct 2 ms 1144 KB Ok
23 Correct 3 ms 1144 KB Ok
24 Correct 4 ms 1144 KB Ok
25 Correct 4 ms 1148 KB Ok
26 Correct 4 ms 1144 KB Ok
27 Correct 3 ms 1144 KB Ok
28 Correct 3 ms 1144 KB Ok
29 Correct 4 ms 1144 KB Ok
30 Correct 3 ms 1144 KB Ok
31 Correct 4 ms 1144 KB Ok
32 Correct 4 ms 1144 KB Ok
33 Correct 8 ms 1144 KB Ok
34 Correct 5 ms 1272 KB Ok
35 Correct 5 ms 1272 KB Ok
36 Correct 5 ms 1272 KB Ok
37 Correct 5 ms 1272 KB Ok
38 Correct 5 ms 1272 KB Ok
39 Correct 5 ms 1272 KB Ok
40 Correct 5 ms 1272 KB Ok
41 Correct 5 ms 1272 KB Ok
42 Correct 5 ms 1272 KB Ok
43 Correct 6 ms 1276 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Ok
2 Correct 3 ms 1144 KB Ok
3 Correct 3 ms 1144 KB Ok
4 Correct 3 ms 1144 KB Ok
5 Correct 3 ms 1144 KB Ok
6 Correct 3 ms 1144 KB Ok
7 Correct 3 ms 1144 KB Ok
8 Correct 3 ms 1144 KB Ok
9 Correct 3 ms 1144 KB Ok
10 Correct 3 ms 1144 KB Ok
11 Correct 3 ms 1144 KB Ok
12 Correct 3 ms 1144 KB Ok
13 Correct 3 ms 1144 KB Ok
14 Correct 2 ms 1144 KB Ok
15 Correct 3 ms 1144 KB Ok
16 Correct 2 ms 1148 KB Ok
17 Correct 3 ms 1192 KB Ok
18 Correct 4 ms 1144 KB Ok
19 Correct 9 ms 1660 KB Ok
20 Correct 6 ms 1272 KB Ok
21 Correct 9 ms 1656 KB Ok
22 Correct 7 ms 1528 KB Ok
23 Correct 2 ms 1144 KB Ok
24 Correct 3 ms 1144 KB Ok
25 Correct 2 ms 1144 KB Ok
26 Correct 3 ms 1144 KB Ok
27 Correct 3 ms 1144 KB Ok
28 Correct 2 ms 1144 KB Ok
29 Correct 2 ms 1144 KB Ok
30 Correct 3 ms 1144 KB Ok
31 Correct 3 ms 1144 KB Ok
32 Correct 2 ms 1144 KB Ok
33 Correct 3 ms 1144 KB Ok
34 Correct 4 ms 1144 KB Ok
35 Correct 4 ms 1148 KB Ok
36 Correct 4 ms 1144 KB Ok
37 Correct 3 ms 1144 KB Ok
38 Correct 3 ms 1144 KB Ok
39 Correct 4 ms 1144 KB Ok
40 Correct 3 ms 1144 KB Ok
41 Correct 4 ms 1144 KB Ok
42 Correct 4 ms 1144 KB Ok
43 Correct 8 ms 1144 KB Ok
44 Correct 5 ms 1272 KB Ok
45 Correct 5 ms 1272 KB Ok
46 Correct 5 ms 1272 KB Ok
47 Correct 5 ms 1272 KB Ok
48 Correct 5 ms 1272 KB Ok
49 Correct 5 ms 1272 KB Ok
50 Correct 5 ms 1272 KB Ok
51 Correct 5 ms 1272 KB Ok
52 Correct 5 ms 1272 KB Ok
53 Correct 6 ms 1276 KB Ok
54 Correct 44 ms 2836 KB Ok
55 Correct 51 ms 3044 KB Ok
56 Correct 51 ms 3064 KB Ok
57 Correct 40 ms 2424 KB Ok
58 Correct 47 ms 2608 KB Ok
59 Correct 43 ms 2424 KB Ok
60 Correct 41 ms 2340 KB Ok
61 Correct 40 ms 2424 KB Ok
62 Correct 51 ms 2904 KB Ok
63 Correct 43 ms 2680 KB Ok
64 Correct 51 ms 3064 KB Ok
65 Correct 47 ms 2680 KB Ok
66 Correct 44 ms 2696 KB Ok
67 Correct 38 ms 2552 KB Ok
68 Correct 46 ms 2552 KB Ok
69 Correct 94 ms 8440 KB Ok
70 Correct 94 ms 8952 KB Ok
71 Correct 92 ms 8440 KB Ok
72 Correct 87 ms 8448 KB Ok
73 Correct 90 ms 8312 KB Ok
74 Correct 91 ms 8184 KB Ok
75 Correct 88 ms 7928 KB Ok
76 Correct 96 ms 8696 KB Ok
77 Correct 84 ms 7672 KB Ok
78 Correct 90 ms 8184 KB Ok
79 Correct 93 ms 8540 KB Ok
80 Correct 90 ms 8568 KB Ok
81 Correct 91 ms 8312 KB Ok
82 Correct 91 ms 8448 KB Ok
83 Correct 87 ms 8084 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1144 KB Ok
2 Correct 3 ms 1144 KB Ok
3 Correct 3 ms 1144 KB Ok
4 Correct 3 ms 1144 KB Ok
5 Correct 3 ms 1144 KB Ok
6 Correct 3 ms 1144 KB Ok
7 Correct 3 ms 1144 KB Ok
8 Correct 3 ms 1144 KB Ok
9 Correct 3 ms 1144 KB Ok
10 Correct 3 ms 1144 KB Ok
11 Correct 3 ms 1144 KB Ok
12 Correct 3 ms 1144 KB Ok
13 Correct 3 ms 1144 KB Ok
14 Correct 2 ms 1144 KB Ok
15 Correct 3 ms 1144 KB Ok
16 Correct 2 ms 1148 KB Ok
17 Correct 3 ms 1192 KB Ok
18 Correct 4 ms 1144 KB Ok
19 Correct 9 ms 1660 KB Ok
20 Correct 6 ms 1272 KB Ok
21 Correct 9 ms 1656 KB Ok
22 Correct 7 ms 1528 KB Ok
23 Correct 2 ms 1144 KB Ok
24 Correct 3 ms 1144 KB Ok
25 Correct 2 ms 1144 KB Ok
26 Correct 3 ms 1144 KB Ok
27 Correct 3 ms 1144 KB Ok
28 Correct 2 ms 1144 KB Ok
29 Correct 2 ms 1144 KB Ok
30 Correct 3 ms 1144 KB Ok
31 Correct 3 ms 1144 KB Ok
32 Correct 2 ms 1144 KB Ok
33 Correct 3 ms 1144 KB Ok
34 Correct 3 ms 1144 KB Ok
35 Correct 3 ms 1144 KB Ok
36 Correct 4 ms 1144 KB Ok
37 Correct 3 ms 1144 KB Ok
38 Correct 2 ms 1144 KB Ok
39 Correct 59 ms 5564 KB Ok
40 Correct 47 ms 6264 KB Ok
41 Correct 93 ms 9336 KB Ok
42 Correct 76 ms 8440 KB Ok
43 Correct 44 ms 3832 KB Ok
44 Correct 66 ms 6136 KB Ok
45 Correct 4 ms 1144 KB Ok
46 Correct 4 ms 1148 KB Ok
47 Correct 4 ms 1144 KB Ok
48 Correct 3 ms 1144 KB Ok
49 Correct 3 ms 1144 KB Ok
50 Correct 4 ms 1144 KB Ok
51 Correct 3 ms 1144 KB Ok
52 Correct 4 ms 1144 KB Ok
53 Correct 4 ms 1144 KB Ok
54 Correct 8 ms 1144 KB Ok
55 Correct 5 ms 1272 KB Ok
56 Correct 5 ms 1272 KB Ok
57 Correct 5 ms 1272 KB Ok
58 Correct 5 ms 1272 KB Ok
59 Correct 5 ms 1272 KB Ok
60 Correct 5 ms 1272 KB Ok
61 Correct 5 ms 1272 KB Ok
62 Correct 5 ms 1272 KB Ok
63 Correct 5 ms 1272 KB Ok
64 Correct 6 ms 1276 KB Ok
65 Correct 44 ms 2836 KB Ok
66 Correct 51 ms 3044 KB Ok
67 Correct 51 ms 3064 KB Ok
68 Correct 40 ms 2424 KB Ok
69 Correct 47 ms 2608 KB Ok
70 Correct 43 ms 2424 KB Ok
71 Correct 41 ms 2340 KB Ok
72 Correct 40 ms 2424 KB Ok
73 Correct 51 ms 2904 KB Ok
74 Correct 43 ms 2680 KB Ok
75 Correct 51 ms 3064 KB Ok
76 Correct 47 ms 2680 KB Ok
77 Correct 44 ms 2696 KB Ok
78 Correct 38 ms 2552 KB Ok
79 Correct 46 ms 2552 KB Ok
80 Correct 94 ms 8440 KB Ok
81 Correct 94 ms 8952 KB Ok
82 Correct 92 ms 8440 KB Ok
83 Correct 87 ms 8448 KB Ok
84 Correct 90 ms 8312 KB Ok
85 Correct 91 ms 8184 KB Ok
86 Correct 88 ms 7928 KB Ok
87 Correct 96 ms 8696 KB Ok
88 Correct 84 ms 7672 KB Ok
89 Correct 90 ms 8184 KB Ok
90 Correct 93 ms 8540 KB Ok
91 Correct 90 ms 8568 KB Ok
92 Correct 91 ms 8312 KB Ok
93 Correct 91 ms 8448 KB Ok
94 Correct 87 ms 8084 KB Ok
95 Runtime error 41 ms 3424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
96 Halted 0 ms 0 KB -