답안 #485539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485539 2021-11-08T05:20:27 Z SirCovidThe19th Nice sequence (IZhO18_sequence) C++17
100 / 100
412 ms 41332 KB
#include <bits/stdc++.h>
using namespace std;

int n, m, ti = 0, sz, pre[400005];

void dfs(int cur){
    if (pre[cur]) return;
    if (cur - n >= 0) dfs(cur - n); 
    if (cur + m <= sz) dfs(cur + m);
    pre[cur] = ++ti;
}

int main(){
    int tc; cin >> tc;
    while (tc--){
        cin >> n >> m; sz = n + m - __gcd(n, m) - 1;
        ti = 0; fill(pre, pre + sz + 1, 0);

        for (int i = 0; i <= sz; i++) dfs(i);

        cout<<sz<<endl;
        for (int i = 0; i < sz; i++) cout<<pre[i] - pre[i + 1]<<" ";
        cout<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 0 ms 304 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 300 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 0 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 300 KB Ok
12 Correct 0 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 296 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
6 Correct 3 ms 332 KB Ok
7 Correct 8 ms 844 KB Ok
8 Correct 4 ms 460 KB Ok
9 Correct 14 ms 1004 KB Ok
10 Correct 6 ms 588 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 0 ms 296 KB Ok
6 Correct 0 ms 204 KB Ok
7 Correct 0 ms 204 KB Ok
8 Correct 0 ms 204 KB Ok
9 Correct 0 ms 204 KB Ok
10 Correct 0 ms 296 KB Ok
11 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 0 ms 204 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
6 Correct 73 ms 9092 KB Ok
7 Correct 79 ms 7652 KB Ok
8 Correct 112 ms 10876 KB Ok
9 Correct 94 ms 9288 KB Ok
10 Correct 60 ms 6340 KB Ok
11 Correct 91 ms 12232 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 0 ms 304 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 300 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 0 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 300 KB Ok
12 Correct 0 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 204 KB Ok
16 Correct 1 ms 204 KB Ok
17 Correct 0 ms 296 KB Ok
18 Correct 0 ms 204 KB Ok
19 Correct 0 ms 204 KB Ok
20 Correct 0 ms 204 KB Ok
21 Correct 0 ms 204 KB Ok
22 Correct 0 ms 296 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 2 ms 300 KB Ok
25 Correct 4 ms 332 KB Ok
26 Correct 2 ms 332 KB Ok
27 Correct 2 ms 332 KB Ok
28 Correct 2 ms 332 KB Ok
29 Correct 2 ms 340 KB Ok
30 Correct 2 ms 332 KB Ok
31 Correct 2 ms 332 KB Ok
32 Correct 3 ms 296 KB Ok
33 Correct 2 ms 332 KB Ok
34 Correct 3 ms 424 KB Ok
35 Correct 4 ms 460 KB Ok
36 Correct 3 ms 576 KB Ok
37 Correct 4 ms 464 KB Ok
38 Correct 4 ms 460 KB Ok
39 Correct 4 ms 460 KB Ok
40 Correct 4 ms 588 KB Ok
41 Correct 4 ms 460 KB Ok
42 Correct 3 ms 588 KB Ok
43 Correct 3 ms 552 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 0 ms 304 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 300 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 0 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 300 KB Ok
12 Correct 0 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 296 KB Ok
16 Correct 0 ms 204 KB Ok
17 Correct 0 ms 204 KB Ok
18 Correct 3 ms 332 KB Ok
19 Correct 8 ms 844 KB Ok
20 Correct 4 ms 460 KB Ok
21 Correct 14 ms 1004 KB Ok
22 Correct 6 ms 588 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 1 ms 204 KB Ok
25 Correct 1 ms 204 KB Ok
26 Correct 1 ms 204 KB Ok
27 Correct 0 ms 296 KB Ok
28 Correct 0 ms 204 KB Ok
29 Correct 0 ms 204 KB Ok
30 Correct 0 ms 204 KB Ok
31 Correct 0 ms 204 KB Ok
32 Correct 0 ms 296 KB Ok
33 Correct 1 ms 204 KB Ok
34 Correct 2 ms 300 KB Ok
35 Correct 4 ms 332 KB Ok
36 Correct 2 ms 332 KB Ok
37 Correct 2 ms 332 KB Ok
38 Correct 2 ms 332 KB Ok
39 Correct 2 ms 340 KB Ok
40 Correct 2 ms 332 KB Ok
41 Correct 2 ms 332 KB Ok
42 Correct 3 ms 296 KB Ok
43 Correct 2 ms 332 KB Ok
44 Correct 3 ms 424 KB Ok
45 Correct 4 ms 460 KB Ok
46 Correct 3 ms 576 KB Ok
47 Correct 4 ms 464 KB Ok
48 Correct 4 ms 460 KB Ok
49 Correct 4 ms 460 KB Ok
50 Correct 4 ms 588 KB Ok
51 Correct 4 ms 460 KB Ok
52 Correct 3 ms 588 KB Ok
53 Correct 3 ms 552 KB Ok
54 Correct 57 ms 2764 KB Ok
55 Correct 58 ms 3128 KB Ok
56 Correct 61 ms 3208 KB Ok
57 Correct 48 ms 2380 KB Ok
58 Correct 57 ms 2960 KB Ok
59 Correct 66 ms 2904 KB Ok
60 Correct 45 ms 2592 KB Ok
61 Correct 45 ms 2548 KB Ok
62 Correct 62 ms 3312 KB Ok
63 Correct 64 ms 2756 KB Ok
64 Correct 58 ms 3172 KB Ok
65 Correct 67 ms 3208 KB Ok
66 Correct 54 ms 2732 KB Ok
67 Correct 50 ms 2500 KB Ok
68 Correct 56 ms 2852 KB Ok
69 Correct 127 ms 9812 KB Ok
70 Correct 143 ms 9796 KB Ok
71 Correct 87 ms 8336 KB Ok
72 Correct 104 ms 9748 KB Ok
73 Correct 90 ms 8648 KB Ok
74 Correct 87 ms 9076 KB Ok
75 Correct 90 ms 9508 KB Ok
76 Correct 90 ms 9800 KB Ok
77 Correct 96 ms 8900 KB Ok
78 Correct 93 ms 9736 KB Ok
79 Correct 99 ms 9284 KB Ok
80 Correct 88 ms 8476 KB Ok
81 Correct 91 ms 9792 KB Ok
82 Correct 98 ms 9120 KB Ok
83 Correct 89 ms 9804 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 0 ms 304 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 300 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 0 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 300 KB Ok
12 Correct 0 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 296 KB Ok
16 Correct 0 ms 204 KB Ok
17 Correct 0 ms 204 KB Ok
18 Correct 3 ms 332 KB Ok
19 Correct 8 ms 844 KB Ok
20 Correct 4 ms 460 KB Ok
21 Correct 14 ms 1004 KB Ok
22 Correct 6 ms 588 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 1 ms 204 KB Ok
25 Correct 1 ms 204 KB Ok
26 Correct 1 ms 204 KB Ok
27 Correct 0 ms 296 KB Ok
28 Correct 0 ms 204 KB Ok
29 Correct 0 ms 204 KB Ok
30 Correct 0 ms 204 KB Ok
31 Correct 0 ms 204 KB Ok
32 Correct 0 ms 296 KB Ok
33 Correct 1 ms 204 KB Ok
34 Correct 0 ms 204 KB Ok
35 Correct 1 ms 204 KB Ok
36 Correct 0 ms 204 KB Ok
37 Correct 0 ms 204 KB Ok
38 Correct 0 ms 204 KB Ok
39 Correct 73 ms 9092 KB Ok
40 Correct 79 ms 7652 KB Ok
41 Correct 112 ms 10876 KB Ok
42 Correct 94 ms 9288 KB Ok
43 Correct 60 ms 6340 KB Ok
44 Correct 91 ms 12232 KB Ok
45 Correct 2 ms 300 KB Ok
46 Correct 4 ms 332 KB Ok
47 Correct 2 ms 332 KB Ok
48 Correct 2 ms 332 KB Ok
49 Correct 2 ms 332 KB Ok
50 Correct 2 ms 340 KB Ok
51 Correct 2 ms 332 KB Ok
52 Correct 2 ms 332 KB Ok
53 Correct 3 ms 296 KB Ok
54 Correct 2 ms 332 KB Ok
55 Correct 3 ms 424 KB Ok
56 Correct 4 ms 460 KB Ok
57 Correct 3 ms 576 KB Ok
58 Correct 4 ms 464 KB Ok
59 Correct 4 ms 460 KB Ok
60 Correct 4 ms 460 KB Ok
61 Correct 4 ms 588 KB Ok
62 Correct 4 ms 460 KB Ok
63 Correct 3 ms 588 KB Ok
64 Correct 3 ms 552 KB Ok
65 Correct 57 ms 2764 KB Ok
66 Correct 58 ms 3128 KB Ok
67 Correct 61 ms 3208 KB Ok
68 Correct 48 ms 2380 KB Ok
69 Correct 57 ms 2960 KB Ok
70 Correct 66 ms 2904 KB Ok
71 Correct 45 ms 2592 KB Ok
72 Correct 45 ms 2548 KB Ok
73 Correct 62 ms 3312 KB Ok
74 Correct 64 ms 2756 KB Ok
75 Correct 58 ms 3172 KB Ok
76 Correct 67 ms 3208 KB Ok
77 Correct 54 ms 2732 KB Ok
78 Correct 50 ms 2500 KB Ok
79 Correct 56 ms 2852 KB Ok
80 Correct 127 ms 9812 KB Ok
81 Correct 143 ms 9796 KB Ok
82 Correct 87 ms 8336 KB Ok
83 Correct 104 ms 9748 KB Ok
84 Correct 90 ms 8648 KB Ok
85 Correct 87 ms 9076 KB Ok
86 Correct 90 ms 9508 KB Ok
87 Correct 90 ms 9800 KB Ok
88 Correct 96 ms 8900 KB Ok
89 Correct 93 ms 9736 KB Ok
90 Correct 99 ms 9284 KB Ok
91 Correct 88 ms 8476 KB Ok
92 Correct 91 ms 9792 KB Ok
93 Correct 98 ms 9120 KB Ok
94 Correct 89 ms 9804 KB Ok
95 Correct 133 ms 6888 KB Ok
96 Correct 185 ms 10180 KB Ok
97 Correct 190 ms 9180 KB Ok
98 Correct 141 ms 7492 KB Ok
99 Correct 176 ms 8000 KB Ok
100 Correct 164 ms 9052 KB Ok
101 Correct 166 ms 8484 KB Ok
102 Correct 174 ms 8696 KB Ok
103 Correct 162 ms 9028 KB Ok
104 Correct 185 ms 9968 KB Ok
105 Correct 178 ms 9824 KB Ok
106 Correct 155 ms 8260 KB Ok
107 Correct 180 ms 9156 KB Ok
108 Correct 187 ms 10368 KB Ok
109 Correct 166 ms 9252 KB Ok
110 Correct 371 ms 40260 KB Ok
111 Correct 385 ms 41304 KB Ok
112 Correct 351 ms 37060 KB Ok
113 Correct 390 ms 40256 KB Ok
114 Correct 367 ms 36300 KB Ok
115 Correct 412 ms 41332 KB Ok
116 Correct 372 ms 40728 KB Ok
117 Correct 401 ms 40980 KB Ok
118 Correct 365 ms 35320 KB Ok
119 Correct 376 ms 40348 KB Ok
120 Correct 367 ms 41140 KB Ok
121 Correct 353 ms 38668 KB Ok
122 Correct 357 ms 41028 KB Ok
123 Correct 365 ms 39144 KB Ok
124 Correct 356 ms 36760 KB Ok
125 Correct 312 ms 24444 KB Ok