답안 #91323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91323 2018-12-27T06:07:50 Z toloraia Nice sequence (IZhO18_sequence) C++14
76 / 100
219 ms 11296 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;
const int N = 1e6 + 5, NN = 2e5;

int F[N];
int n, m, M;
bool ok;

void dfs (int k, int p){
    //cout<<k<<" "<<p<<" "<<M<<" "<<n<<" "<<m<<" "<<F[k]<<endl;
    if (ok == 0)
        return;
    if (F[k] == p){
        ok = 0;
        return;
    }
    if (F[k])
        return;
    F[k] = p;
    if (k + m <= M)
        dfs (k + m, p);
    if (k - n >= 0)
        dfs (k - n, p);
}

int nn;
int a[N], b[N];

void go (int k){
    if (F[k])
        return;
    F[k] = 1;
    if (k + n <= M)
        go (k + n);
    if (k - m >= 0)
        go (k - m);
    a[++nn] = k;
}

int main()
{
    ios::sync_with_stdio(false);
    int T;
    cin>>T;
    while (T--){
        cin>>n>>m;
        int l = 0, r = NN;
        while (l < r){
            M = (l + r + 1) / 2;
            ok = 1;
            for (int i = 0; i <= M; i++)
                F[i] = 0;
            for (int i = 0; i <= M && ok == 1; i++)
                if (F[i] == 0)
                    dfs (i, i + 1);
            if (ok)
                l = M;
            else
                r = M - 1;
            //cout<<M<<" "<<ok<<endl;
        }
        M = l;
        nn = -1;
        for (int i = 0; i <= M; i++)
            F[i] = 0;
        for (int i = 0; i <= M; i++)
            if (F[i] == 0)
                go (i);
        for (int i = 0; i <= M; i++)
            b[a[i]] = i;
        cout<<M<<endl;
        for (int i = 1; i <= M; i++)
            cout<<b[i] - b[i - 1]<<" ";
        cout<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3832 KB Ok
2 Correct 14 ms 3956 KB Ok
3 Correct 4 ms 3956 KB Ok
4 Correct 3 ms 3956 KB Ok
5 Correct 3 ms 3956 KB Ok
6 Correct 4 ms 3956 KB Ok
7 Correct 3 ms 3956 KB Ok
8 Correct 8 ms 3956 KB Ok
9 Correct 3 ms 3956 KB Ok
10 Correct 3 ms 3956 KB Ok
11 Correct 3 ms 3956 KB Ok
12 Correct 3 ms 3956 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 3956 KB Ok
2 Correct 11 ms 3956 KB Ok
3 Correct 7 ms 3956 KB Ok
4 Correct 9 ms 3956 KB Ok
5 Correct 9 ms 3956 KB Ok
6 Correct 10 ms 3956 KB Ok
7 Correct 18 ms 3956 KB Ok
8 Correct 11 ms 3956 KB Ok
9 Correct 23 ms 3956 KB Ok
10 Correct 14 ms 3956 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4140 KB Ok
2 Correct 16 ms 4140 KB Ok
3 Correct 11 ms 4140 KB Ok
4 Correct 11 ms 4140 KB Ok
5 Correct 8 ms 4140 KB Ok
6 Correct 9 ms 4140 KB Ok
7 Correct 6 ms 4140 KB Ok
8 Correct 7 ms 4140 KB Ok
9 Correct 7 ms 4140 KB Ok
10 Correct 9 ms 4332 KB Ok
11 Correct 9 ms 4332 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4332 KB Ok
2 Correct 5 ms 4332 KB Ok
3 Correct 4 ms 4332 KB Ok
4 Correct 5 ms 4332 KB Ok
5 Correct 4 ms 4332 KB Ok
6 Correct 126 ms 8364 KB Ok
7 Correct 109 ms 8364 KB Ok
8 Correct 219 ms 11296 KB Ok
9 Correct 153 ms 11296 KB Ok
10 Correct 92 ms 11296 KB Ok
11 Correct 158 ms 11296 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3832 KB Ok
2 Correct 14 ms 3956 KB Ok
3 Correct 4 ms 3956 KB Ok
4 Correct 3 ms 3956 KB Ok
5 Correct 3 ms 3956 KB Ok
6 Correct 4 ms 3956 KB Ok
7 Correct 3 ms 3956 KB Ok
8 Correct 8 ms 3956 KB Ok
9 Correct 3 ms 3956 KB Ok
10 Correct 3 ms 3956 KB Ok
11 Correct 3 ms 3956 KB Ok
12 Correct 3 ms 3956 KB Ok
13 Correct 8 ms 4140 KB Ok
14 Correct 16 ms 4140 KB Ok
15 Correct 11 ms 4140 KB Ok
16 Correct 11 ms 4140 KB Ok
17 Correct 8 ms 4140 KB Ok
18 Correct 9 ms 4140 KB Ok
19 Correct 6 ms 4140 KB Ok
20 Correct 7 ms 4140 KB Ok
21 Correct 7 ms 4140 KB Ok
22 Correct 9 ms 4332 KB Ok
23 Correct 9 ms 4332 KB Ok
24 Correct 5 ms 11296 KB Ok
25 Correct 4 ms 11296 KB Ok
26 Correct 4 ms 11296 KB Ok
27 Correct 4 ms 11296 KB Ok
28 Correct 4 ms 11296 KB Ok
29 Correct 4 ms 11296 KB Ok
30 Correct 4 ms 11296 KB Ok
31 Correct 5 ms 11296 KB Ok
32 Correct 5 ms 11296 KB Ok
33 Correct 4 ms 11296 KB Ok
34 Correct 7 ms 11296 KB Ok
35 Correct 8 ms 11296 KB Ok
36 Correct 8 ms 11296 KB Ok
37 Correct 8 ms 11296 KB Ok
38 Correct 8 ms 11296 KB Ok
39 Correct 7 ms 11296 KB Ok
40 Correct 8 ms 11296 KB Ok
41 Correct 8 ms 11296 KB Ok
42 Correct 7 ms 11296 KB Ok
43 Correct 11 ms 11296 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3832 KB Ok
2 Correct 14 ms 3956 KB Ok
3 Correct 4 ms 3956 KB Ok
4 Correct 3 ms 3956 KB Ok
5 Correct 3 ms 3956 KB Ok
6 Correct 4 ms 3956 KB Ok
7 Correct 3 ms 3956 KB Ok
8 Correct 8 ms 3956 KB Ok
9 Correct 3 ms 3956 KB Ok
10 Correct 3 ms 3956 KB Ok
11 Correct 3 ms 3956 KB Ok
12 Correct 3 ms 3956 KB Ok
13 Correct 10 ms 3956 KB Ok
14 Correct 11 ms 3956 KB Ok
15 Correct 7 ms 3956 KB Ok
16 Correct 9 ms 3956 KB Ok
17 Correct 9 ms 3956 KB Ok
18 Correct 10 ms 3956 KB Ok
19 Correct 18 ms 3956 KB Ok
20 Correct 11 ms 3956 KB Ok
21 Correct 23 ms 3956 KB Ok
22 Correct 14 ms 3956 KB Ok
23 Correct 8 ms 4140 KB Ok
24 Correct 16 ms 4140 KB Ok
25 Correct 11 ms 4140 KB Ok
26 Correct 11 ms 4140 KB Ok
27 Correct 8 ms 4140 KB Ok
28 Correct 9 ms 4140 KB Ok
29 Correct 6 ms 4140 KB Ok
30 Correct 7 ms 4140 KB Ok
31 Correct 7 ms 4140 KB Ok
32 Correct 9 ms 4332 KB Ok
33 Correct 9 ms 4332 KB Ok
34 Correct 5 ms 11296 KB Ok
35 Correct 4 ms 11296 KB Ok
36 Correct 4 ms 11296 KB Ok
37 Correct 4 ms 11296 KB Ok
38 Correct 4 ms 11296 KB Ok
39 Correct 4 ms 11296 KB Ok
40 Correct 4 ms 11296 KB Ok
41 Correct 5 ms 11296 KB Ok
42 Correct 5 ms 11296 KB Ok
43 Correct 4 ms 11296 KB Ok
44 Correct 7 ms 11296 KB Ok
45 Correct 8 ms 11296 KB Ok
46 Correct 8 ms 11296 KB Ok
47 Correct 8 ms 11296 KB Ok
48 Correct 8 ms 11296 KB Ok
49 Correct 7 ms 11296 KB Ok
50 Correct 8 ms 11296 KB Ok
51 Correct 8 ms 11296 KB Ok
52 Correct 7 ms 11296 KB Ok
53 Correct 11 ms 11296 KB Ok
54 Correct 76 ms 11296 KB Ok
55 Correct 89 ms 11296 KB Ok
56 Correct 92 ms 11296 KB Ok
57 Correct 70 ms 11296 KB Ok
58 Correct 76 ms 11296 KB Ok
59 Correct 75 ms 11296 KB Ok
60 Correct 65 ms 11296 KB Ok
61 Correct 70 ms 11296 KB Ok
62 Correct 84 ms 11296 KB Ok
63 Correct 66 ms 11296 KB Ok
64 Correct 83 ms 11296 KB Ok
65 Correct 82 ms 11296 KB Ok
66 Correct 72 ms 11296 KB Ok
67 Correct 69 ms 11296 KB Ok
68 Correct 75 ms 11296 KB Ok
69 Correct 194 ms 11296 KB Ok
70 Correct 201 ms 11296 KB Ok
71 Correct 173 ms 11296 KB Ok
72 Correct 198 ms 11296 KB Ok
73 Correct 180 ms 11296 KB Ok
74 Correct 170 ms 11296 KB Ok
75 Correct 189 ms 11296 KB Ok
76 Correct 215 ms 11296 KB Ok
77 Correct 165 ms 11296 KB Ok
78 Correct 200 ms 11296 KB Ok
79 Correct 185 ms 11296 KB Ok
80 Correct 180 ms 11296 KB Ok
81 Correct 195 ms 11296 KB Ok
82 Correct 176 ms 11296 KB Ok
83 Correct 178 ms 11296 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3832 KB Ok
2 Correct 14 ms 3956 KB Ok
3 Correct 4 ms 3956 KB Ok
4 Correct 3 ms 3956 KB Ok
5 Correct 3 ms 3956 KB Ok
6 Correct 4 ms 3956 KB Ok
7 Correct 3 ms 3956 KB Ok
8 Correct 8 ms 3956 KB Ok
9 Correct 3 ms 3956 KB Ok
10 Correct 3 ms 3956 KB Ok
11 Correct 3 ms 3956 KB Ok
12 Correct 3 ms 3956 KB Ok
13 Correct 10 ms 3956 KB Ok
14 Correct 11 ms 3956 KB Ok
15 Correct 7 ms 3956 KB Ok
16 Correct 9 ms 3956 KB Ok
17 Correct 9 ms 3956 KB Ok
18 Correct 10 ms 3956 KB Ok
19 Correct 18 ms 3956 KB Ok
20 Correct 11 ms 3956 KB Ok
21 Correct 23 ms 3956 KB Ok
22 Correct 14 ms 3956 KB Ok
23 Correct 8 ms 4140 KB Ok
24 Correct 16 ms 4140 KB Ok
25 Correct 11 ms 4140 KB Ok
26 Correct 11 ms 4140 KB Ok
27 Correct 8 ms 4140 KB Ok
28 Correct 9 ms 4140 KB Ok
29 Correct 6 ms 4140 KB Ok
30 Correct 7 ms 4140 KB Ok
31 Correct 7 ms 4140 KB Ok
32 Correct 9 ms 4332 KB Ok
33 Correct 9 ms 4332 KB Ok
34 Correct 7 ms 4332 KB Ok
35 Correct 5 ms 4332 KB Ok
36 Correct 4 ms 4332 KB Ok
37 Correct 5 ms 4332 KB Ok
38 Correct 4 ms 4332 KB Ok
39 Correct 126 ms 8364 KB Ok
40 Correct 109 ms 8364 KB Ok
41 Correct 219 ms 11296 KB Ok
42 Correct 153 ms 11296 KB Ok
43 Correct 92 ms 11296 KB Ok
44 Correct 158 ms 11296 KB Ok
45 Correct 5 ms 11296 KB Ok
46 Correct 4 ms 11296 KB Ok
47 Correct 4 ms 11296 KB Ok
48 Correct 4 ms 11296 KB Ok
49 Correct 4 ms 11296 KB Ok
50 Correct 4 ms 11296 KB Ok
51 Correct 4 ms 11296 KB Ok
52 Correct 5 ms 11296 KB Ok
53 Correct 5 ms 11296 KB Ok
54 Correct 4 ms 11296 KB Ok
55 Correct 7 ms 11296 KB Ok
56 Correct 8 ms 11296 KB Ok
57 Correct 8 ms 11296 KB Ok
58 Correct 8 ms 11296 KB Ok
59 Correct 8 ms 11296 KB Ok
60 Correct 7 ms 11296 KB Ok
61 Correct 8 ms 11296 KB Ok
62 Correct 8 ms 11296 KB Ok
63 Correct 7 ms 11296 KB Ok
64 Correct 11 ms 11296 KB Ok
65 Correct 76 ms 11296 KB Ok
66 Correct 89 ms 11296 KB Ok
67 Correct 92 ms 11296 KB Ok
68 Correct 70 ms 11296 KB Ok
69 Correct 76 ms 11296 KB Ok
70 Correct 75 ms 11296 KB Ok
71 Correct 65 ms 11296 KB Ok
72 Correct 70 ms 11296 KB Ok
73 Correct 84 ms 11296 KB Ok
74 Correct 66 ms 11296 KB Ok
75 Correct 83 ms 11296 KB Ok
76 Correct 82 ms 11296 KB Ok
77 Correct 72 ms 11296 KB Ok
78 Correct 69 ms 11296 KB Ok
79 Correct 75 ms 11296 KB Ok
80 Correct 194 ms 11296 KB Ok
81 Correct 201 ms 11296 KB Ok
82 Correct 173 ms 11296 KB Ok
83 Correct 198 ms 11296 KB Ok
84 Correct 180 ms 11296 KB Ok
85 Correct 170 ms 11296 KB Ok
86 Correct 189 ms 11296 KB Ok
87 Correct 215 ms 11296 KB Ok
88 Correct 165 ms 11296 KB Ok
89 Correct 200 ms 11296 KB Ok
90 Correct 185 ms 11296 KB Ok
91 Correct 180 ms 11296 KB Ok
92 Correct 195 ms 11296 KB Ok
93 Correct 176 ms 11296 KB Ok
94 Correct 178 ms 11296 KB Ok
95 Incorrect 197 ms 11296 KB Jury has the better answer : jans = 239234, pans = 200000
96 Halted 0 ms 0 KB -