답안 #133837

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133837 2019-07-21T13:58:27 Z Kastanda Nice sequence (IZhO18_sequence) C++11
76 / 100
127 ms 9108 KB
// ItnoE
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m, q, k, ts, A[N];
void DFS(int v)
{
    if (v - n >= 0 && !A[v - n])
        DFS(v - n);
    if (v + m <= k && !A[v + m])
        DFS(v + m);
    A[v] = ++ ts;
}
int main()
{
    scanf("%d", &q);
    for (; q; q --)
    {
        scanf("%d%d", &n, &m);
        k = n + m - __gcd(n, m) - 1;
        for (int i = 0; i <= k; i ++)
            if (!A[i]) DFS(i);
        printf("%d\n", k);
        for (int i = 0; i < k; i ++)
            printf("%d ", A[i] - A[i + 1]);
        printf("\n");
        for (int i = 0; i <= k; i ++)
            A[i] = 0;
        ts = 0;
    }
    return 0;
}

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
sequence.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &n, &m);
         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 252 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 256 KB Ok
11 Correct 2 ms 256 KB Ok
12 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 4 ms 376 KB Ok
7 Correct 10 ms 764 KB Ok
8 Correct 6 ms 504 KB Ok
9 Correct 11 ms 1016 KB Ok
10 Correct 7 ms 616 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 256 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 256 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 256 KB Ok
8 Correct 2 ms 376 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 376 KB Ok
11 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 81 ms 7052 KB Ok
7 Correct 66 ms 5496 KB Ok
8 Correct 127 ms 8368 KB Ok
9 Correct 102 ms 8056 KB Ok
10 Correct 62 ms 4984 KB Ok
11 Correct 103 ms 9108 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 252 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 256 KB Ok
11 Correct 2 ms 256 KB Ok
12 Correct 2 ms 376 KB Ok
13 Correct 2 ms 256 KB Ok
14 Correct 2 ms 376 KB Ok
15 Correct 2 ms 256 KB Ok
16 Correct 2 ms 256 KB Ok
17 Correct 2 ms 256 KB Ok
18 Correct 2 ms 256 KB Ok
19 Correct 2 ms 256 KB Ok
20 Correct 2 ms 376 KB Ok
21 Correct 2 ms 376 KB Ok
22 Correct 2 ms 376 KB Ok
23 Correct 2 ms 376 KB Ok
24 Correct 4 ms 504 KB Ok
25 Correct 4 ms 376 KB Ok
26 Correct 4 ms 376 KB Ok
27 Correct 3 ms 376 KB Ok
28 Correct 3 ms 504 KB Ok
29 Correct 3 ms 376 KB Ok
30 Correct 3 ms 376 KB Ok
31 Correct 4 ms 376 KB Ok
32 Correct 4 ms 376 KB Ok
33 Correct 3 ms 376 KB Ok
34 Correct 5 ms 508 KB Ok
35 Correct 5 ms 504 KB Ok
36 Correct 6 ms 572 KB Ok
37 Correct 5 ms 504 KB Ok
38 Correct 5 ms 504 KB Ok
39 Correct 5 ms 504 KB Ok
40 Correct 6 ms 632 KB Ok
41 Correct 5 ms 504 KB Ok
42 Correct 6 ms 632 KB Ok
43 Correct 5 ms 504 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 252 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 256 KB Ok
11 Correct 2 ms 256 KB Ok
12 Correct 2 ms 376 KB Ok
13 Correct 2 ms 256 KB Ok
14 Correct 2 ms 376 KB Ok
15 Correct 2 ms 376 KB Ok
16 Correct 2 ms 376 KB Ok
17 Correct 2 ms 376 KB Ok
18 Correct 4 ms 376 KB Ok
19 Correct 10 ms 764 KB Ok
20 Correct 6 ms 504 KB Ok
21 Correct 11 ms 1016 KB Ok
22 Correct 7 ms 616 KB Ok
23 Correct 2 ms 256 KB Ok
24 Correct 2 ms 376 KB Ok
25 Correct 2 ms 256 KB Ok
26 Correct 2 ms 256 KB Ok
27 Correct 2 ms 256 KB Ok
28 Correct 2 ms 256 KB Ok
29 Correct 2 ms 256 KB Ok
30 Correct 2 ms 376 KB Ok
31 Correct 2 ms 376 KB Ok
32 Correct 2 ms 376 KB Ok
33 Correct 2 ms 376 KB Ok
34 Correct 4 ms 504 KB Ok
35 Correct 4 ms 376 KB Ok
36 Correct 4 ms 376 KB Ok
37 Correct 3 ms 376 KB Ok
38 Correct 3 ms 504 KB Ok
39 Correct 3 ms 376 KB Ok
40 Correct 3 ms 376 KB Ok
41 Correct 4 ms 376 KB Ok
42 Correct 4 ms 376 KB Ok
43 Correct 3 ms 376 KB Ok
44 Correct 5 ms 508 KB Ok
45 Correct 5 ms 504 KB Ok
46 Correct 6 ms 572 KB Ok
47 Correct 5 ms 504 KB Ok
48 Correct 5 ms 504 KB Ok
49 Correct 5 ms 504 KB Ok
50 Correct 6 ms 632 KB Ok
51 Correct 5 ms 504 KB Ok
52 Correct 6 ms 632 KB Ok
53 Correct 5 ms 504 KB Ok
54 Correct 61 ms 2788 KB Ok
55 Correct 71 ms 3304 KB Ok
56 Correct 69 ms 3192 KB Ok
57 Correct 55 ms 2372 KB Ok
58 Correct 64 ms 3108 KB Ok
59 Correct 62 ms 2936 KB Ok
60 Correct 56 ms 2680 KB Ok
61 Correct 54 ms 2552 KB Ok
62 Correct 72 ms 3420 KB Ok
63 Correct 58 ms 2936 KB Ok
64 Correct 69 ms 3324 KB Ok
65 Correct 69 ms 3064 KB Ok
66 Correct 60 ms 2936 KB Ok
67 Correct 53 ms 2536 KB Ok
68 Correct 62 ms 2936 KB Ok
69 Correct 118 ms 8312 KB Ok
70 Correct 119 ms 8568 KB Ok
71 Correct 115 ms 7804 KB Ok
72 Correct 113 ms 8312 KB Ok
73 Correct 118 ms 7908 KB Ok
74 Correct 117 ms 8032 KB Ok
75 Correct 125 ms 8184 KB Ok
76 Correct 120 ms 8312 KB Ok
77 Correct 113 ms 7900 KB Ok
78 Correct 120 ms 8408 KB Ok
79 Correct 125 ms 8312 KB Ok
80 Correct 114 ms 7672 KB Ok
81 Correct 118 ms 8568 KB Ok
82 Correct 115 ms 8024 KB Ok
83 Correct 116 ms 8440 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Ok
2 Correct 2 ms 256 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 376 KB Ok
5 Correct 2 ms 252 KB Ok
6 Correct 2 ms 256 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 256 KB Ok
9 Correct 2 ms 376 KB Ok
10 Correct 2 ms 256 KB Ok
11 Correct 2 ms 256 KB Ok
12 Correct 2 ms 376 KB Ok
13 Correct 2 ms 256 KB Ok
14 Correct 2 ms 376 KB Ok
15 Correct 2 ms 376 KB Ok
16 Correct 2 ms 376 KB Ok
17 Correct 2 ms 376 KB Ok
18 Correct 4 ms 376 KB Ok
19 Correct 10 ms 764 KB Ok
20 Correct 6 ms 504 KB Ok
21 Correct 11 ms 1016 KB Ok
22 Correct 7 ms 616 KB Ok
23 Correct 2 ms 256 KB Ok
24 Correct 2 ms 376 KB Ok
25 Correct 2 ms 256 KB Ok
26 Correct 2 ms 256 KB Ok
27 Correct 2 ms 256 KB Ok
28 Correct 2 ms 256 KB Ok
29 Correct 2 ms 256 KB Ok
30 Correct 2 ms 376 KB Ok
31 Correct 2 ms 376 KB Ok
32 Correct 2 ms 376 KB Ok
33 Correct 2 ms 376 KB Ok
34 Correct 2 ms 376 KB Ok
35 Correct 2 ms 256 KB Ok
36 Correct 2 ms 376 KB Ok
37 Correct 2 ms 256 KB Ok
38 Correct 2 ms 376 KB Ok
39 Correct 81 ms 7052 KB Ok
40 Correct 66 ms 5496 KB Ok
41 Correct 127 ms 8368 KB Ok
42 Correct 102 ms 8056 KB Ok
43 Correct 62 ms 4984 KB Ok
44 Correct 103 ms 9108 KB Ok
45 Correct 4 ms 504 KB Ok
46 Correct 4 ms 376 KB Ok
47 Correct 4 ms 376 KB Ok
48 Correct 3 ms 376 KB Ok
49 Correct 3 ms 504 KB Ok
50 Correct 3 ms 376 KB Ok
51 Correct 3 ms 376 KB Ok
52 Correct 4 ms 376 KB Ok
53 Correct 4 ms 376 KB Ok
54 Correct 3 ms 376 KB Ok
55 Correct 5 ms 508 KB Ok
56 Correct 5 ms 504 KB Ok
57 Correct 6 ms 572 KB Ok
58 Correct 5 ms 504 KB Ok
59 Correct 5 ms 504 KB Ok
60 Correct 5 ms 504 KB Ok
61 Correct 6 ms 632 KB Ok
62 Correct 5 ms 504 KB Ok
63 Correct 6 ms 632 KB Ok
64 Correct 5 ms 504 KB Ok
65 Correct 61 ms 2788 KB Ok
66 Correct 71 ms 3304 KB Ok
67 Correct 69 ms 3192 KB Ok
68 Correct 55 ms 2372 KB Ok
69 Correct 64 ms 3108 KB Ok
70 Correct 62 ms 2936 KB Ok
71 Correct 56 ms 2680 KB Ok
72 Correct 54 ms 2552 KB Ok
73 Correct 72 ms 3420 KB Ok
74 Correct 58 ms 2936 KB Ok
75 Correct 69 ms 3324 KB Ok
76 Correct 69 ms 3064 KB Ok
77 Correct 60 ms 2936 KB Ok
78 Correct 53 ms 2536 KB Ok
79 Correct 62 ms 2936 KB Ok
80 Correct 118 ms 8312 KB Ok
81 Correct 119 ms 8568 KB Ok
82 Correct 115 ms 7804 KB Ok
83 Correct 113 ms 8312 KB Ok
84 Correct 118 ms 7908 KB Ok
85 Correct 117 ms 8032 KB Ok
86 Correct 125 ms 8184 KB Ok
87 Correct 120 ms 8312 KB Ok
88 Correct 113 ms 7900 KB Ok
89 Correct 120 ms 8408 KB Ok
90 Correct 125 ms 8312 KB Ok
91 Correct 114 ms 7672 KB Ok
92 Correct 118 ms 8568 KB Ok
93 Correct 115 ms 8024 KB Ok
94 Correct 116 ms 8440 KB Ok
95 Runtime error 58 ms 3660 KB Execution killed with signal 11 (could be triggered by violating memory limits)
96 Halted 0 ms 0 KB -