Submission #58667

# Submission time Handle Problem Language Result Execution time Memory
58667 2018-07-18T18:09:07 Z alenam0161 Nice sequence (IZhO18_sequence) C++17
100 / 100
1137 ms 44448 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int n,m,len,t=0;
vector<int> ans,used;
int Try(int x){
    used[x]=true;
    if(x-n>=0&&used[x-n]==false)Try(x-n);
    if(x+m<=len&&used[x+m]==false)Try(x+m);
    ans[x]=++t;
}
int main(){
    int test;
    scanf("%d",&test);
    for(int i=1;i<=test;++i){
        scanf("%d %d",&n,&m);
        len = n + m - 1 -__gcd(n,m);t=0;
        if(n==m){
            printf("%d\n",n-1);for(int i=1;i<n;++i)printf("%d ",i);printf("\n");
        }
        else{
            ans.resize(0);used.resize(0);
            ans.resize(len+1,0);
            used.resize(len+1,0);
            for(int i=0;i<=len;++i){
                if(used[i])continue;
                Try(i);
            }
            printf("%d\n",len);for(int i=1;i<=len;++i)printf("%d ",-ans[i]+ans[i-1]);printf("\n");
        }
    }
    return 0;
}

Compilation message

sequence.cpp: In function 'int Try(int)':
sequence.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
sequence.cpp: In function 'int main()':
sequence.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&test);
     ~~~~~^~~~~~~~~~~~
sequence.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&n,&m);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Ok
2 Correct 4 ms 400 KB Ok
3 Correct 3 ms 484 KB Ok
4 Correct 3 ms 504 KB Ok
5 Correct 2 ms 504 KB Ok
6 Correct 2 ms 504 KB Ok
7 Correct 3 ms 504 KB Ok
8 Correct 2 ms 556 KB Ok
9 Correct 3 ms 556 KB Ok
10 Correct 3 ms 580 KB Ok
11 Correct 3 ms 580 KB Ok
12 Correct 3 ms 580 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 580 KB Ok
2 Correct 2 ms 580 KB Ok
3 Correct 3 ms 580 KB Ok
4 Correct 3 ms 580 KB Ok
5 Correct 3 ms 580 KB Ok
6 Correct 7 ms 688 KB Ok
7 Correct 20 ms 1356 KB Ok
8 Correct 12 ms 1356 KB Ok
9 Correct 23 ms 1520 KB Ok
10 Correct 20 ms 1520 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1520 KB Ok
2 Correct 2 ms 1520 KB Ok
3 Correct 3 ms 1520 KB Ok
4 Correct 3 ms 1520 KB Ok
5 Correct 3 ms 1520 KB Ok
6 Correct 5 ms 1520 KB Ok
7 Correct 4 ms 1520 KB Ok
8 Correct 3 ms 1520 KB Ok
9 Correct 2 ms 1520 KB Ok
10 Correct 3 ms 1520 KB Ok
11 Correct 2 ms 1520 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1520 KB Ok
2 Correct 2 ms 1520 KB Ok
3 Correct 3 ms 1520 KB Ok
4 Correct 3 ms 1520 KB Ok
5 Correct 3 ms 1520 KB Ok
6 Correct 120 ms 10292 KB Ok
7 Correct 96 ms 10292 KB Ok
8 Correct 208 ms 12112 KB Ok
9 Correct 169 ms 12112 KB Ok
10 Correct 87 ms 12112 KB Ok
11 Correct 217 ms 13424 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Ok
2 Correct 4 ms 400 KB Ok
3 Correct 3 ms 484 KB Ok
4 Correct 3 ms 504 KB Ok
5 Correct 2 ms 504 KB Ok
6 Correct 2 ms 504 KB Ok
7 Correct 3 ms 504 KB Ok
8 Correct 2 ms 556 KB Ok
9 Correct 3 ms 556 KB Ok
10 Correct 3 ms 580 KB Ok
11 Correct 3 ms 580 KB Ok
12 Correct 3 ms 580 KB Ok
13 Correct 3 ms 1520 KB Ok
14 Correct 2 ms 1520 KB Ok
15 Correct 3 ms 1520 KB Ok
16 Correct 3 ms 1520 KB Ok
17 Correct 3 ms 1520 KB Ok
18 Correct 5 ms 1520 KB Ok
19 Correct 4 ms 1520 KB Ok
20 Correct 3 ms 1520 KB Ok
21 Correct 2 ms 1520 KB Ok
22 Correct 3 ms 1520 KB Ok
23 Correct 2 ms 1520 KB Ok
24 Correct 8 ms 13424 KB Ok
25 Correct 5 ms 13424 KB Ok
26 Correct 5 ms 13424 KB Ok
27 Correct 6 ms 13424 KB Ok
28 Correct 5 ms 13424 KB Ok
29 Correct 5 ms 13424 KB Ok
30 Correct 6 ms 13424 KB Ok
31 Correct 5 ms 13424 KB Ok
32 Correct 6 ms 13424 KB Ok
33 Correct 8 ms 13424 KB Ok
34 Correct 8 ms 13424 KB Ok
35 Correct 8 ms 13424 KB Ok
36 Correct 8 ms 13424 KB Ok
37 Correct 9 ms 13424 KB Ok
38 Correct 8 ms 13424 KB Ok
39 Correct 9 ms 13424 KB Ok
40 Correct 12 ms 13424 KB Ok
41 Correct 3 ms 13424 KB Ok
42 Correct 9 ms 13424 KB Ok
43 Correct 12 ms 13424 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Ok
2 Correct 4 ms 400 KB Ok
3 Correct 3 ms 484 KB Ok
4 Correct 3 ms 504 KB Ok
5 Correct 2 ms 504 KB Ok
6 Correct 2 ms 504 KB Ok
7 Correct 3 ms 504 KB Ok
8 Correct 2 ms 556 KB Ok
9 Correct 3 ms 556 KB Ok
10 Correct 3 ms 580 KB Ok
11 Correct 3 ms 580 KB Ok
12 Correct 3 ms 580 KB Ok
13 Correct 2 ms 580 KB Ok
14 Correct 2 ms 580 KB Ok
15 Correct 3 ms 580 KB Ok
16 Correct 3 ms 580 KB Ok
17 Correct 3 ms 580 KB Ok
18 Correct 7 ms 688 KB Ok
19 Correct 20 ms 1356 KB Ok
20 Correct 12 ms 1356 KB Ok
21 Correct 23 ms 1520 KB Ok
22 Correct 20 ms 1520 KB Ok
23 Correct 3 ms 1520 KB Ok
24 Correct 2 ms 1520 KB Ok
25 Correct 3 ms 1520 KB Ok
26 Correct 3 ms 1520 KB Ok
27 Correct 3 ms 1520 KB Ok
28 Correct 5 ms 1520 KB Ok
29 Correct 4 ms 1520 KB Ok
30 Correct 3 ms 1520 KB Ok
31 Correct 2 ms 1520 KB Ok
32 Correct 3 ms 1520 KB Ok
33 Correct 2 ms 1520 KB Ok
34 Correct 8 ms 13424 KB Ok
35 Correct 5 ms 13424 KB Ok
36 Correct 5 ms 13424 KB Ok
37 Correct 6 ms 13424 KB Ok
38 Correct 5 ms 13424 KB Ok
39 Correct 5 ms 13424 KB Ok
40 Correct 6 ms 13424 KB Ok
41 Correct 5 ms 13424 KB Ok
42 Correct 6 ms 13424 KB Ok
43 Correct 8 ms 13424 KB Ok
44 Correct 8 ms 13424 KB Ok
45 Correct 8 ms 13424 KB Ok
46 Correct 8 ms 13424 KB Ok
47 Correct 9 ms 13424 KB Ok
48 Correct 8 ms 13424 KB Ok
49 Correct 9 ms 13424 KB Ok
50 Correct 12 ms 13424 KB Ok
51 Correct 3 ms 13424 KB Ok
52 Correct 9 ms 13424 KB Ok
53 Correct 12 ms 13424 KB Ok
54 Correct 100 ms 13424 KB Ok
55 Correct 128 ms 13424 KB Ok
56 Correct 117 ms 13424 KB Ok
57 Correct 81 ms 13424 KB Ok
58 Correct 143 ms 13424 KB Ok
59 Correct 152 ms 13424 KB Ok
60 Correct 82 ms 13424 KB Ok
61 Correct 118 ms 13424 KB Ok
62 Correct 135 ms 13424 KB Ok
63 Correct 110 ms 13424 KB Ok
64 Correct 110 ms 13424 KB Ok
65 Correct 151 ms 13424 KB Ok
66 Correct 126 ms 13424 KB Ok
67 Correct 96 ms 13424 KB Ok
68 Correct 97 ms 13424 KB Ok
69 Correct 203 ms 13424 KB Ok
70 Correct 178 ms 13424 KB Ok
71 Correct 210 ms 13424 KB Ok
72 Correct 184 ms 13424 KB Ok
73 Correct 197 ms 13424 KB Ok
74 Correct 252 ms 13424 KB Ok
75 Correct 183 ms 13424 KB Ok
76 Correct 173 ms 13424 KB Ok
77 Correct 223 ms 13424 KB Ok
78 Correct 214 ms 13424 KB Ok
79 Correct 237 ms 13424 KB Ok
80 Correct 212 ms 13424 KB Ok
81 Correct 213 ms 13424 KB Ok
82 Correct 171 ms 13424 KB Ok
83 Correct 183 ms 13424 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Ok
2 Correct 4 ms 400 KB Ok
3 Correct 3 ms 484 KB Ok
4 Correct 3 ms 504 KB Ok
5 Correct 2 ms 504 KB Ok
6 Correct 2 ms 504 KB Ok
7 Correct 3 ms 504 KB Ok
8 Correct 2 ms 556 KB Ok
9 Correct 3 ms 556 KB Ok
10 Correct 3 ms 580 KB Ok
11 Correct 3 ms 580 KB Ok
12 Correct 3 ms 580 KB Ok
13 Correct 2 ms 580 KB Ok
14 Correct 2 ms 580 KB Ok
15 Correct 3 ms 580 KB Ok
16 Correct 3 ms 580 KB Ok
17 Correct 3 ms 580 KB Ok
18 Correct 7 ms 688 KB Ok
19 Correct 20 ms 1356 KB Ok
20 Correct 12 ms 1356 KB Ok
21 Correct 23 ms 1520 KB Ok
22 Correct 20 ms 1520 KB Ok
23 Correct 3 ms 1520 KB Ok
24 Correct 2 ms 1520 KB Ok
25 Correct 3 ms 1520 KB Ok
26 Correct 3 ms 1520 KB Ok
27 Correct 3 ms 1520 KB Ok
28 Correct 5 ms 1520 KB Ok
29 Correct 4 ms 1520 KB Ok
30 Correct 3 ms 1520 KB Ok
31 Correct 2 ms 1520 KB Ok
32 Correct 3 ms 1520 KB Ok
33 Correct 2 ms 1520 KB Ok
34 Correct 3 ms 1520 KB Ok
35 Correct 2 ms 1520 KB Ok
36 Correct 3 ms 1520 KB Ok
37 Correct 3 ms 1520 KB Ok
38 Correct 3 ms 1520 KB Ok
39 Correct 120 ms 10292 KB Ok
40 Correct 96 ms 10292 KB Ok
41 Correct 208 ms 12112 KB Ok
42 Correct 169 ms 12112 KB Ok
43 Correct 87 ms 12112 KB Ok
44 Correct 217 ms 13424 KB Ok
45 Correct 8 ms 13424 KB Ok
46 Correct 5 ms 13424 KB Ok
47 Correct 5 ms 13424 KB Ok
48 Correct 6 ms 13424 KB Ok
49 Correct 5 ms 13424 KB Ok
50 Correct 5 ms 13424 KB Ok
51 Correct 6 ms 13424 KB Ok
52 Correct 5 ms 13424 KB Ok
53 Correct 6 ms 13424 KB Ok
54 Correct 8 ms 13424 KB Ok
55 Correct 8 ms 13424 KB Ok
56 Correct 8 ms 13424 KB Ok
57 Correct 8 ms 13424 KB Ok
58 Correct 9 ms 13424 KB Ok
59 Correct 8 ms 13424 KB Ok
60 Correct 9 ms 13424 KB Ok
61 Correct 12 ms 13424 KB Ok
62 Correct 3 ms 13424 KB Ok
63 Correct 9 ms 13424 KB Ok
64 Correct 12 ms 13424 KB Ok
65 Correct 100 ms 13424 KB Ok
66 Correct 128 ms 13424 KB Ok
67 Correct 117 ms 13424 KB Ok
68 Correct 81 ms 13424 KB Ok
69 Correct 143 ms 13424 KB Ok
70 Correct 152 ms 13424 KB Ok
71 Correct 82 ms 13424 KB Ok
72 Correct 118 ms 13424 KB Ok
73 Correct 135 ms 13424 KB Ok
74 Correct 110 ms 13424 KB Ok
75 Correct 110 ms 13424 KB Ok
76 Correct 151 ms 13424 KB Ok
77 Correct 126 ms 13424 KB Ok
78 Correct 96 ms 13424 KB Ok
79 Correct 97 ms 13424 KB Ok
80 Correct 203 ms 13424 KB Ok
81 Correct 178 ms 13424 KB Ok
82 Correct 210 ms 13424 KB Ok
83 Correct 184 ms 13424 KB Ok
84 Correct 197 ms 13424 KB Ok
85 Correct 252 ms 13424 KB Ok
86 Correct 183 ms 13424 KB Ok
87 Correct 173 ms 13424 KB Ok
88 Correct 223 ms 13424 KB Ok
89 Correct 214 ms 13424 KB Ok
90 Correct 237 ms 13424 KB Ok
91 Correct 212 ms 13424 KB Ok
92 Correct 213 ms 13424 KB Ok
93 Correct 171 ms 13424 KB Ok
94 Correct 183 ms 13424 KB Ok
95 Correct 259 ms 13424 KB Ok
96 Correct 341 ms 13424 KB Ok
97 Correct 387 ms 13424 KB Ok
98 Correct 306 ms 13424 KB Ok
99 Correct 409 ms 13424 KB Ok
100 Correct 352 ms 13424 KB Ok
101 Correct 297 ms 13424 KB Ok
102 Correct 344 ms 13424 KB Ok
103 Correct 262 ms 13424 KB Ok
104 Correct 380 ms 13424 KB Ok
105 Correct 426 ms 13424 KB Ok
106 Correct 253 ms 13424 KB Ok
107 Correct 362 ms 13424 KB Ok
108 Correct 336 ms 13424 KB Ok
109 Correct 294 ms 13424 KB Ok
110 Correct 956 ms 42108 KB Ok
111 Correct 1012 ms 43024 KB Ok
112 Correct 989 ms 43024 KB Ok
113 Correct 1137 ms 43024 KB Ok
114 Correct 959 ms 43024 KB Ok
115 Correct 948 ms 43092 KB Ok
116 Correct 1000 ms 43092 KB Ok
117 Correct 670 ms 43092 KB Ok
118 Correct 675 ms 43092 KB Ok
119 Correct 696 ms 43556 KB Ok
120 Correct 641 ms 44448 KB Ok
121 Correct 612 ms 44448 KB Ok
122 Correct 592 ms 44448 KB Ok
123 Correct 634 ms 44448 KB Ok
124 Correct 1073 ms 44448 KB Ok
125 Correct 394 ms 44448 KB Ok