답안 #91322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91322 2018-12-27T06:05:07 Z toloraia Nice sequence (IZhO18_sequence) C++14
61 / 100
197 ms 10704 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 = 1e5;

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 10 ms 2168 KB Ok
2 Correct 8 ms 2364 KB Ok
3 Correct 3 ms 2364 KB Ok
4 Correct 3 ms 2364 KB Ok
5 Correct 3 ms 2364 KB Ok
6 Correct 3 ms 2364 KB Ok
7 Correct 3 ms 2364 KB Ok
8 Correct 3 ms 2364 KB Ok
9 Correct 3 ms 2364 KB Ok
10 Correct 3 ms 2364 KB Ok
11 Correct 2 ms 2364 KB Ok
12 Correct 2 ms 2364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2364 KB Ok
2 Correct 5 ms 2364 KB Ok
3 Correct 4 ms 2364 KB Ok
4 Correct 5 ms 2364 KB Ok
5 Correct 5 ms 2364 KB Ok
6 Correct 7 ms 2364 KB Ok
7 Correct 16 ms 2452 KB Ok
8 Correct 10 ms 2452 KB Ok
9 Correct 19 ms 2624 KB Ok
10 Correct 11 ms 2624 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2660 KB Ok
2 Correct 8 ms 2792 KB Ok
3 Correct 6 ms 2792 KB Ok
4 Correct 6 ms 2792 KB Ok
5 Correct 4 ms 2792 KB Ok
6 Correct 5 ms 2792 KB Ok
7 Correct 4 ms 2792 KB Ok
8 Correct 4 ms 2792 KB Ok
9 Correct 4 ms 2792 KB Ok
10 Correct 5 ms 2792 KB Ok
11 Correct 5 ms 2792 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2792 KB Ok
2 Correct 3 ms 2792 KB Ok
3 Correct 3 ms 2792 KB Ok
4 Correct 3 ms 2792 KB Ok
5 Correct 3 ms 2792 KB Ok
6 Incorrect 97 ms 5176 KB Jury has the better answer : jans = 166803, pans = 100000
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2168 KB Ok
2 Correct 8 ms 2364 KB Ok
3 Correct 3 ms 2364 KB Ok
4 Correct 3 ms 2364 KB Ok
5 Correct 3 ms 2364 KB Ok
6 Correct 3 ms 2364 KB Ok
7 Correct 3 ms 2364 KB Ok
8 Correct 3 ms 2364 KB Ok
9 Correct 3 ms 2364 KB Ok
10 Correct 3 ms 2364 KB Ok
11 Correct 2 ms 2364 KB Ok
12 Correct 2 ms 2364 KB Ok
13 Correct 5 ms 2660 KB Ok
14 Correct 8 ms 2792 KB Ok
15 Correct 6 ms 2792 KB Ok
16 Correct 6 ms 2792 KB Ok
17 Correct 4 ms 2792 KB Ok
18 Correct 5 ms 2792 KB Ok
19 Correct 4 ms 2792 KB Ok
20 Correct 4 ms 2792 KB Ok
21 Correct 4 ms 2792 KB Ok
22 Correct 5 ms 2792 KB Ok
23 Correct 5 ms 2792 KB Ok
24 Correct 4 ms 5176 KB Ok
25 Correct 4 ms 5176 KB Ok
26 Correct 4 ms 5176 KB Ok
27 Correct 4 ms 5176 KB Ok
28 Correct 2 ms 5176 KB Ok
29 Correct 4 ms 5176 KB Ok
30 Correct 4 ms 5176 KB Ok
31 Correct 4 ms 5176 KB Ok
32 Correct 4 ms 5176 KB Ok
33 Correct 4 ms 5176 KB Ok
34 Correct 6 ms 5176 KB Ok
35 Correct 7 ms 5176 KB Ok
36 Correct 7 ms 5176 KB Ok
37 Correct 7 ms 5176 KB Ok
38 Correct 7 ms 5176 KB Ok
39 Correct 7 ms 5176 KB Ok
40 Correct 8 ms 5176 KB Ok
41 Correct 7 ms 5176 KB Ok
42 Correct 7 ms 5176 KB Ok
43 Correct 8 ms 5176 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2168 KB Ok
2 Correct 8 ms 2364 KB Ok
3 Correct 3 ms 2364 KB Ok
4 Correct 3 ms 2364 KB Ok
5 Correct 3 ms 2364 KB Ok
6 Correct 3 ms 2364 KB Ok
7 Correct 3 ms 2364 KB Ok
8 Correct 3 ms 2364 KB Ok
9 Correct 3 ms 2364 KB Ok
10 Correct 3 ms 2364 KB Ok
11 Correct 2 ms 2364 KB Ok
12 Correct 2 ms 2364 KB Ok
13 Correct 6 ms 2364 KB Ok
14 Correct 5 ms 2364 KB Ok
15 Correct 4 ms 2364 KB Ok
16 Correct 5 ms 2364 KB Ok
17 Correct 5 ms 2364 KB Ok
18 Correct 7 ms 2364 KB Ok
19 Correct 16 ms 2452 KB Ok
20 Correct 10 ms 2452 KB Ok
21 Correct 19 ms 2624 KB Ok
22 Correct 11 ms 2624 KB Ok
23 Correct 5 ms 2660 KB Ok
24 Correct 8 ms 2792 KB Ok
25 Correct 6 ms 2792 KB Ok
26 Correct 6 ms 2792 KB Ok
27 Correct 4 ms 2792 KB Ok
28 Correct 5 ms 2792 KB Ok
29 Correct 4 ms 2792 KB Ok
30 Correct 4 ms 2792 KB Ok
31 Correct 4 ms 2792 KB Ok
32 Correct 5 ms 2792 KB Ok
33 Correct 5 ms 2792 KB Ok
34 Correct 4 ms 5176 KB Ok
35 Correct 4 ms 5176 KB Ok
36 Correct 4 ms 5176 KB Ok
37 Correct 4 ms 5176 KB Ok
38 Correct 2 ms 5176 KB Ok
39 Correct 4 ms 5176 KB Ok
40 Correct 4 ms 5176 KB Ok
41 Correct 4 ms 5176 KB Ok
42 Correct 4 ms 5176 KB Ok
43 Correct 4 ms 5176 KB Ok
44 Correct 6 ms 5176 KB Ok
45 Correct 7 ms 5176 KB Ok
46 Correct 7 ms 5176 KB Ok
47 Correct 7 ms 5176 KB Ok
48 Correct 7 ms 5176 KB Ok
49 Correct 7 ms 5176 KB Ok
50 Correct 8 ms 5176 KB Ok
51 Correct 7 ms 5176 KB Ok
52 Correct 7 ms 5176 KB Ok
53 Correct 8 ms 5176 KB Ok
54 Correct 72 ms 5176 KB Ok
55 Correct 87 ms 5176 KB Ok
56 Correct 89 ms 5176 KB Ok
57 Correct 66 ms 5176 KB Ok
58 Correct 77 ms 5176 KB Ok
59 Correct 77 ms 5176 KB Ok
60 Correct 64 ms 5176 KB Ok
61 Correct 66 ms 5176 KB Ok
62 Correct 87 ms 5176 KB Ok
63 Correct 68 ms 5176 KB Ok
64 Correct 84 ms 5176 KB Ok
65 Correct 86 ms 5176 KB Ok
66 Correct 74 ms 5176 KB Ok
67 Correct 65 ms 5176 KB Ok
68 Correct 73 ms 5176 KB Ok
69 Correct 179 ms 10104 KB Ok
70 Correct 194 ms 10704 KB Ok
71 Correct 168 ms 10704 KB Ok
72 Correct 177 ms 10704 KB Ok
73 Correct 185 ms 10704 KB Ok
74 Correct 167 ms 10704 KB Ok
75 Correct 179 ms 10704 KB Ok
76 Correct 197 ms 10704 KB Ok
77 Correct 158 ms 10704 KB Ok
78 Correct 192 ms 10704 KB Ok
79 Correct 174 ms 10704 KB Ok
80 Correct 183 ms 10704 KB Ok
81 Correct 184 ms 10704 KB Ok
82 Correct 177 ms 10704 KB Ok
83 Correct 160 ms 10704 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2168 KB Ok
2 Correct 8 ms 2364 KB Ok
3 Correct 3 ms 2364 KB Ok
4 Correct 3 ms 2364 KB Ok
5 Correct 3 ms 2364 KB Ok
6 Correct 3 ms 2364 KB Ok
7 Correct 3 ms 2364 KB Ok
8 Correct 3 ms 2364 KB Ok
9 Correct 3 ms 2364 KB Ok
10 Correct 3 ms 2364 KB Ok
11 Correct 2 ms 2364 KB Ok
12 Correct 2 ms 2364 KB Ok
13 Correct 6 ms 2364 KB Ok
14 Correct 5 ms 2364 KB Ok
15 Correct 4 ms 2364 KB Ok
16 Correct 5 ms 2364 KB Ok
17 Correct 5 ms 2364 KB Ok
18 Correct 7 ms 2364 KB Ok
19 Correct 16 ms 2452 KB Ok
20 Correct 10 ms 2452 KB Ok
21 Correct 19 ms 2624 KB Ok
22 Correct 11 ms 2624 KB Ok
23 Correct 5 ms 2660 KB Ok
24 Correct 8 ms 2792 KB Ok
25 Correct 6 ms 2792 KB Ok
26 Correct 6 ms 2792 KB Ok
27 Correct 4 ms 2792 KB Ok
28 Correct 5 ms 2792 KB Ok
29 Correct 4 ms 2792 KB Ok
30 Correct 4 ms 2792 KB Ok
31 Correct 4 ms 2792 KB Ok
32 Correct 5 ms 2792 KB Ok
33 Correct 5 ms 2792 KB Ok
34 Correct 5 ms 2792 KB Ok
35 Correct 3 ms 2792 KB Ok
36 Correct 3 ms 2792 KB Ok
37 Correct 3 ms 2792 KB Ok
38 Correct 3 ms 2792 KB Ok
39 Incorrect 97 ms 5176 KB Jury has the better answer : jans = 166803, pans = 100000
40 Halted 0 ms 0 KB -