QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736397#2411. Balanced CutserverrepairmanAC ✓58ms15596kbC++172.3kb2024-11-12 10:44:222024-11-12 10:44:24

Judging History

你现在查看的是最新测评结果

  • [2024-11-12 10:44:24]
  • 评测
  • 测评结果:AC
  • 用时:58ms
  • 内存:15596kb
  • [2024-11-12 10:44:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n, k;
int p[510000], ja[510000][2], root, cnt;
int nhei[510000], hei[510000], mh[100];
int dap[510000];
int dfs(int now){
    int l = ja[now][0];
    int r = ja[now][1];
    hei[now] = 1;
    if(l)
        hei[now] = max(hei[now], dfs(l)+1);
    if(r)
        hei[now] = max(hei[now], dfs(r)+1);
    return hei[now];
}
int chk(int now){
    int ncnt = cnt;
    int phei = 1;
    while(p[now] != -1){
        phei = max(phei+1, nhei[p[now]]);
        int l = ja[p[now]][0];
        int r = ja[p[now]][1];
        if(p[now]>now){
            if(r && phei-2>nhei[r])
                ncnt += mh[phei-2] - mh[nhei[p[now]]-2];
        }
        else if(l && phei>nhei[p[now]]+2)
            return -1;
        now = p[now];
    }
    return ncnt+1;
}
void update(int now){
    nhei[now] = 1;
    while(p[now] != -1){
        nhei[p[now]] = max(nhei[now]+1, nhei[p[now]]);
        int r = ja[p[now]][1];
        if(p[now]>now && r)
            nhei[r] = max(nhei[r], nhei[p[now]]-2);
        now = p[now];
    }
}
void solve(int now){
    int l = ja[now][0];
    int r = ja[now][1];
    if(nhei[now]){
        // Propagation
        if(nhei[now]>1){
            if(!l || hei[l]<nhei[now]-1){
                if(l)
                    nhei[l] = nhei[now]-2;
                nhei[r] = nhei[now]-1;
            }
            else{
                if(r)
                    nhei[r] = nhei[now]-2;
                nhei[l] = nhei[now]-1;
            }
        }
        
        dap[now] = 1;
    }
    else{
        int kk = chk(now);
        if(kk<=k && kk>0){
            dap[now] = 1;
            update(now);
            cnt = kk;
        }
    }
    if(l)
        solve(l);
    if(r)
        solve(r);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> k;
    for(int i=1;i<=n;i++)
        cin >> p[i];
    for(int i=1;i<=n;i++){
        if(p[i]==-1)
            root = i;
        else
            ja[p[i]][p[i]<i] = i;
    }

    mh[1] = 1;
    mh[2] = 2;
    for(int i=3;i<=40;i++)
        mh[i] = mh[i-1] + mh[i-2] + 1;
    
    dfs(root);
    solve(root);

    for(int i=1;i<=n;i++)
        cout << dap[i];
    cout << "\n";

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9696kb

input:

2 1
-1
1

output:

10

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 9740kb

input:

2 1
2
-1

output:

01

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 9736kb

input:

24 16
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
-1
18
19
21
19
16
23
21
23

output:

111111110101010101101010

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 7652kb

input:

12 6
2
3
5
3
8
7
5
-1
10
11
8
11

output:

001010110110

result:

ok correct

Test #5:

score: 0
Accepted
time: 1ms
memory: 9828kb

input:

24 12
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
-1
18
19
21
19
16
23
21
23

output:

110101010101000101101010

result:

ok correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 9800kb

input:

54 38
2
3
5
3
8
7
5
13
10
11
8
11
21
15
16
18
16
13
20
18
34
23
24
26
24
29
28
26
21
31
32
29
32
-1
36
37
39
37
42
41
39
47
44
45
42
45
34
49
50
52
50
47
54
52

output:

011111111111101111011011010110110101101011011010110101

result:

ok correct

Test #7:

score: 0
Accepted
time: 1ms
memory: 9680kb

input:

25 21
2
3
5
3
9
7
5
7
-1
11
12
14
12
18
16
14
16
9
20
22
20
18
24
22
24

output:

1111111111111111011101010

result:

ok correct

Test #8:

score: 0
Accepted
time: 1ms
memory: 9800kb

input:

40 20
2
4
2
8
6
4
6
19
10
13
10
11
8
16
14
13
16
17
-1
21
23
21
28
25
23
25
26
19
30
33
30
31
28
36
34
33
38
36
38
39

output:

1111111111101101101010100001000010000000

result:

ok correct

Test #9:

score: 0
Accepted
time: 1ms
memory: 9704kb

input:

609 399
2
3
5
3
8
7
5
13
10
11
8
11
21
15
16
18
16
13
20
18
34
23
24
26
24
29
28
26
21
31
32
29
32
55
36
37
39
37
42
41
39
47
44
45
42
45
34
49
50
52
50
47
54
52
89
57
58
60
58
63
62
60
68
65
66
63
66
76
70
71
73
71
68
75
73
55
78
79
81
79
84
83
81
76
86
87
84
87
144
91
92
94
92
97
96
94
102
99
100
...

output:

011111111111111111111111111111111111111111111111111111101111111011110110101101101011011010110101101101011010110110101101101011010110110101101011011010110110101101011011010110110101101011011010110101101101011011010110101101101011011010110101101101011010110110101101101011010110110101101011011010110110...

result:

ok correct

Test #10:

score: 0
Accepted
time: 1ms
memory: 9764kb

input:

609 326
2
5
2
3
13
8
6
5
10
8
10
11
34
16
14
21
18
16
18
19
13
23
26
23
24
21
29
27
26
31
29
31
32
89
37
35
42
39
37
39
40
55
44
47
44
45
42
50
48
47
52
50
52
53
34
57
60
57
58
68
63
61
60
65
63
65
66
55
71
69
76
73
71
73
74
68
78
81
78
79
76
84
82
81
86
84
86
87
233
92
90
97
94
92
94
95
110
99
102
...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111101101010010100100000001111111010000...

result:

ok correct

Test #11:

score: 0
Accepted
time: 3ms
memory: 9836kb

input:

16383 4134
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #12:

score: 0
Accepted
time: 1ms
memory: 9800kb

input:

7 5
2
3
5
3
-1
7
5

output:

0111101

result:

ok correct

Test #13:

score: 0
Accepted
time: 0ms
memory: 9700kb

input:

13 3
2
3
5
3
9
7
5
7
-1
11
9
13
11

output:

0000100010100

result:

ok correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 9780kb

input:

13 8
2
3
5
3
9
7
5
7
-1
11
9
13
11

output:

0111101011100

result:

ok correct

Test #15:

score: 0
Accepted
time: 0ms
memory: 9800kb

input:

13 11
2
3
5
3
9
7
5
7
-1
11
9
13
11

output:

0111111111101

result:

ok correct

Test #16:

score: 0
Accepted
time: 1ms
memory: 9704kb

input:

13 12
2
3
5
3
9
7
5
7
-1
11
9
13
11

output:

1111111011111

result:

ok correct

Test #17:

score: 0
Accepted
time: 1ms
memory: 9700kb

input:

20 18
3
1
8
5
3
5
6
-1
10
13
10
11
8
16
14
13
18
16
18
19

output:

11111111111111111100

result:

ok correct

Test #18:

score: 0
Accepted
time: 1ms
memory: 9700kb

input:

21 20
2
3
5
3
8
5
6
13
11
9
8
11
-1
15
17
15
13
19
17
19
20

output:

111111111111111011111

result:

ok correct

Test #19:

score: 0
Accepted
time: 7ms
memory: 10516kb

input:

98539 5880
3
1
7
5
3
5
15
9
11
9
7
13
11
13
37
17
19
17
21
19
24
21
22
15
26
28
26
30
28
24
32
33
30
35
33
35
86
39
40
42
40
49
44
45
42
47
45
47
60
51
55
53
51
53
49
57
55
57
58
37
62
66
64
62
64
74
68
70
68
66
72
70
72
60
77
75
81
79
77
79
74
83
84
81
84
194
88
89
91
89
94
91
92
110
96
99
98
96
94...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101110110101111111101011101111010101011111111111111111011110111111111111111111111111111101101110111111...

result:

ok correct

Test #20:

score: 0
Accepted
time: 9ms
memory: 10420kb

input:

75024 31079
2
3
8
5
3
5
6
13
10
8
10
11
21
16
14
13
18
19
16
19
34
24
22
26
24
21
28
31
28
29
26
31
32
89
37
35
42
39
37
39
40
55
44
47
44
45
42
50
48
47
53
51
50
53
34
57
58
60
58
68
62
63
60
66
64
63
66
55
70
71
76
73
71
73
74
68
78
81
80
78
76
84
82
81
86
84
88
86
144
91
94
93
91
102
96
99
98
96
...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #21:

score: 0
Accepted
time: 7ms
memory: 10356kb

input:

75024 67888
3
1
5
3
13
8
6
5
10
8
12
10
21
16
14
18
16
13
20
18
55
23
26
23
24
34
29
27
31
29
26
33
31
42
36
37
39
37
34
39
40
21
45
43
47
45
50
47
48
42
52
53
50
53
144
57
60
59
57
63
62
60
68
66
64
63
66
76
70
71
68
74
72
71
74
89
78
79
81
79
76
84
82
86
84
81
86
87
55
91
92
97
94
95
92
95
102
99
...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #22:

score: 0
Accepted
time: 8ms
memory: 10292kb

input:

75024 42503
2
3
5
3
13
7
10
7
8
5
10
11
21
16
14
13
18
16
18
19
55
23
26
23
24
29
26
27
34
31
29
31
32
21
37
35
42
39
37
39
40
34
45
43
47
45
42
50
48
47
52
50
52
53
144
57
60
57
58
68
62
63
60
65
63
65
66
76
70
73
70
71
68
73
74
110
78
81
78
79
89
84
82
86
84
81
86
87
76
91
94
93
91
102
96
97
94
99...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #23:

score: 0
Accepted
time: 7ms
memory: 12488kb

input:

94006 20626
3
1
9
5
3
7
5
7
25
11
13
11
17
15
13
15
9
19
21
19
17
23
21
23
75
28
26
34
30
28
32
30
32
47
36
38
36
42
40
38
40
34
44
42
44
45
25
50
48
54
52
50
52
61
57
55
54
59
57
59
47
64
62
68
66
64
66
61
70
72
70
68
72
73
162
77
79
77
86
82
80
79
84
82
84
99
89
87
93
91
89
91
86
95
93
97
95
97
12...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #24:

score: 0
Accepted
time: 9ms
memory: 10912kb

input:

96435 66971
2
3
9
5
3
7
5
7
22
12
10
15
12
13
9
17
18
15
20
18
20
55
24
26
24
29
28
26
40
32
30
29
34
36
34
32
38
36
38
22
43
41
46
45
43
40
49
47
52
49
50
46
52
53
97
57
60
59
57
71
62
64
62
68
66
64
66
60
70
68
55
73
76
73
74
82
79
77
76
79
80
71
84
88
86
84
86
82
90
92
90
88
95
93
92
95
303
99
10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #25:

score: 0
Accepted
time: 7ms
memory: 10352kb

input:

69723 58512
2
4
2
8
6
4
6
15
10
12
10
8
12
13
27
17
19
17
15
21
23
21
19
25
23
25
74
29
31
29
35
33
31
33
40
37
35
37
38
55
43
41
47
45
43
45
40
49
51
49
47
53
51
53
27
57
59
57
64
61
59
61
62
55
66
68
66
64
70
68
72
70
72
176
76
78
76
82
80
78
80
90
84
86
84
82
88
86
88
121
92
94
92
98
96
94
96
105...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #26:

score: 0
Accepted
time: 8ms
memory: 14008kb

input:

69723 512
2
4
2
8
6
4
6
15
10
12
10
8
12
13
27
17
19
17
15
21
23
21
19
25
23
25
74
29
31
29
35
33
31
33
40
37
35
37
38
55
43
41
47
45
43
45
40
49
51
49
47
53
51
53
27
57
59
57
64
61
59
61
62
55
66
68
66
64
70
68
72
70
72
176
76
78
76
82
80
78
80
90
84
86
84
82
88
86
88
121
92
94
92
98
96
94
96
105
1...

output:

000100010001001010100010001000000010000100000010000000100010000100010000010001000100010001000000010000001000000010000000100010001000000010000000100000001000000010000000100000010000000100000001000001000000010000000100000001000000100000001001000100010001000001000000100000001000000010000001000001000000...

result:

ok correct

Test #27:

score: 0
Accepted
time: 10ms
memory: 13808kb

input:

100000 3
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100
98
...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok correct

Test #28:

score: 0
Accepted
time: 4ms
memory: 9772kb

input:

100000 3
2
6
4
2
4
15
9
7
6
11
9
13
11
13
79
17
19
17
23
21
19
21
31
25
27
25
23
29
27
29
47
33
35
33
39
37
35
37
31
41
43
41
39
45
43
45
15
49
51
49
55
53
51
53
63
57
59
57
55
61
59
61
47
65
67
65
71
69
67
69
63
73
75
73
71
77
75
77
228
82
80
87
84
82
84
85
100
89
92
89
90
87
95
93
92
97
95
97
98
7...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok correct

Test #29:

score: 0
Accepted
time: 11ms
memory: 10572kb

input:

100000 99999
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #30:

score: 0
Accepted
time: 8ms
memory: 13968kb

input:

100000 99999
2
6
4
2
4
15
9
7
6
11
9
13
11
13
79
17
19
17
23
21
19
21
31
25
27
25
23
29
27
29
47
33
35
33
39
37
35
37
31
41
43
41
39
45
43
45
15
49
51
49
55
53
51
53
63
57
59
57
55
61
59
61
47
65
67
65
71
69
67
69
63
73
75
73
71
77
75
77
228
82
80
87
84
82
84
85
100
89
92
89
90
87
95
93
92
97
95
97
...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #31:

score: 0
Accepted
time: 3ms
memory: 10472kb

input:

98303 4179
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100
9...

output:

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...

result:

ok correct

Test #32:

score: 0
Accepted
time: 7ms
memory: 10468kb

input:

100000 6763
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100
...

output:

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...

result:

ok correct

Test #33:

score: 0
Accepted
time: 7ms
memory: 12584kb

input:

100000 4181
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100
...

output:

010101010001000100010001000000010001000100000001000000010000000100010001000000010000000100000001000000010000000100000000000000010001000100000001000000010000000100000001000000010000000000000001000000010000000100000000000000010000000000000001000000000000000100010001000000010000000100000001000000010000...

result:

ok correct

Test #34:

score: 0
Accepted
time: 13ms
memory: 10436kb

input:

88552 46366
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100
...

output:

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...

result:

ok correct

Test #35:

score: 0
Accepted
time: 43ms
memory: 15392kb

input:

483784 48000
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
24
18
20
18
16
22
20
22
50
26
27
30
27
28
36
32
30
34
32
34
24
39
37
43
41
39
41
36
45
47
45
43
47
48
95
52
54
52
58
56
54
56
64
61
59
58
63
61
50
66
68
66
72
70
68
70
79
75
73
72
77
75
77
64
81
83
81
87
85
83
85
79
89
91
89
87
93
91
93
208
97
101
99...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #36:

score: 0
Accepted
time: 34ms
memory: 14556kb

input:

483784 206
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
24
18
20
18
16
22
20
22
50
26
27
30
27
28
36
32
30
34
32
34
24
39
37
43
41
39
41
36
45
47
45
43
47
48
95
52
54
52
58
56
54
56
64
61
59
58
63
61
50
66
68
66
72
70
68
70
79
75
73
72
77
75
77
64
81
83
81
87
85
83
85
79
89
91
89
87
93
91
93
208
97
101
99
9...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok correct

Test #37:

score: 0
Accepted
time: 35ms
memory: 15396kb

input:

483611 483610
2
3
5
3
10
7
8
5
8
15
12
13
10
13
23
17
18
20
18
15
22
20
39
25
26
28
26
34
30
31
28
33
31
23
36
37
34
37
68
41
42
44
42
47
46
44
52
49
50
47
50
39
54
55
57
55
63
59
60
57
62
60
52
65
66
63
66
102
70
71
73
71
76
75
73
81
78
79
76
79
89
83
84
86
84
81
88
86
68
91
92
94
92
97
96
94
89
99...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #38:

score: 0
Accepted
time: 38ms
memory: 15444kb

input:

483611 3948
2
3
5
3
10
7
8
5
8
15
12
13
10
13
23
17
18
20
18
15
22
20
39
25
26
28
26
34
30
31
28
33
31
23
36
37
34
37
68
41
42
44
42
47
46
44
52
49
50
47
50
39
54
55
57
55
63
59
60
57
62
60
52
65
66
63
66
102
70
71
73
71
76
75
73
81
78
79
76
79
89
83
84
86
84
81
88
86
68
91
92
94
92
97
96
94
89
99
1...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000...

result:

ok correct

Test #39:

score: 0
Accepted
time: 55ms
memory: 15544kb

input:

500000 499999
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #40:

score: 0
Accepted
time: 22ms
memory: 14240kb

input:

317810 317809
2
3
5
3
8
7
5
13
10
11
8
11
21
15
16
18
16
13
20
18
34
23
24
26
24
29
28
26
21
31
32
29
32
55
36
37
39
37
42
41
39
47
44
45
42
45
34
49
50
52
50
47
54
52
89
57
58
60
58
63
62
60
68
65
66
63
66
76
70
71
73
71
68
75
73
55
78
79
81
79
84
83
81
76
86
87
84
87
144
91
92
94
92
97
96
94
102
9...

output:

011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #41:

score: 0
Accepted
time: 58ms
memory: 15448kb

input:

500000 499999
2
5
2
3
13
8
6
5
10
8
10
11
34
15
18
15
16
21
18
19
13
24
22
26
24
21
29
27
31
29
26
31
32
89
36
37
39
37
42
41
39
47
45
43
42
45
55
50
48
52
50
47
54
52
34
57
58
60
58
63
62
60
68
65
63
65
66
76
71
69
73
71
68
73
74
55
78
81
78
79
76
83
84
81
87
85
84
87
233
91
94
91
92
97
96
94
102
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #42:

score: 0
Accepted
time: 38ms
memory: 15460kb

input:

479953 479000
2
4
2
9
6
4
6
7
22
11
14
11
12
9
17
15
14
19
17
19
20
60
24
28
26
24
26
37
31
29
28
33
31
35
33
35
22
40
38
45
42
40
42
43
37
47
50
47
48
45
52
55
52
53
50
57
55
57
58
158
62
65
62
63
73
68
66
65
70
68
70
71
95
76
74
81
78
76
78
79
73
83
86
83
84
81
89
87
86
92
90
89
92
93
60
97
100
97...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #43:

score: 0
Accepted
time: 40ms
memory: 15436kb

input:

479953 29967
2
4
2
9
6
4
6
7
22
11
14
11
12
9
17
15
14
19
17
19
20
60
24
28
26
24
26
37
31
29
28
33
31
35
33
35
22
40
38
45
42
40
42
43
37
47
50
47
48
45
52
55
52
53
50
57
55
57
58
158
62
65
62
63
73
68
66
65
70
68
70
71
95
76
74
81
78
76
78
79
73
83
86
83
84
81
89
87
86
92
90
89
92
93
60
97
100
97
...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #44:

score: 0
Accepted
time: 29ms
memory: 14764kb

input:

317810 317809
3
1
8
5
3
5
6
21
10
13
10
11
8
16
14
13
18
16
18
19
55
23
26
23
24
34
29
27
26
31
29
31
32
21
37
35
42
39
37
39
40
34
44
47
44
45
42
50
48
47
52
50
52
53
144
57
60
57
58
68
63
61
60
65
63
65
66
89
71
69
76
73
71
73
74
68
78
81
78
79
76
84
82
81
86
84
86
87
55
92
90
97
94
92
94
95
110
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #45:

score: 0
Accepted
time: 56ms
memory: 15492kb

input:

495864 414255
2
3
9
6
4
3
6
7
24
11
13
11
16
15
13
9
18
21
20
18
16
21
22
46
26
28
26
33
30
28
30
31
24
36
34
40
38
36
38
33
42
43
40
45
43
90
49
47
53
51
49
51
58
55
53
55
56
72
60
61
66
63
61
65
63
58
68
70
68
66
70
46
74
77
76
74
72
79
81
79
83
81
77
85
87
85
83
89
87
268
92
95
92
93
101
97
98
95...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #46:

score: 0
Accepted
time: 16ms
memory: 14812kb

input:

317810 317809
2
3
8
5
3
5
6
21
10
11
13
11
16
13
14
8
18
16
20
18
34
23
26
23
24
21
28
31
28
29
26
33
31
55
36
39
38
36
42
39
40
47
44
45
42
45
34
50
48
47
52
53
50
53
89
57
58
63
60
58
62
60
68
66
64
63
66
55
71
69
73
71
76
75
73
68
79
77
81
79
76
83
84
86
84
81
88
86
233
91
94
91
92
102
96
97
94
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #47:

score: 0
Accepted
time: 25ms
memory: 14768kb

input:

317810 276074
2
5
4
2
8
7
5
13
11
9
8
11
34
16
14
21
18
19
16
19
13
23
24
29
26
27
24
27
21
31
29
33
31
55
37
35
39
37
47
41
42
39
45
43
42
45
34
49
52
51
49
47
52
53
89
57
58
60
58
68
63
61
65
63
60
67
65
55
71
69
76
73
74
71
74
68
78
81
80
78
76
84
82
86
84
81
88
86
233
91
92
94
92
102
96
97
94
99...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #48:

score: 0
Accepted
time: 44ms
memory: 15548kb

input:

500000 17709
2
3
8
6
4
3
6
13
10
8
10
11
34
15
16
21
18
19
16
19
13
23
24
26
24
21
28
31
30
28
26
31
32
55
36
39
36
37
47
41
42
39
44
45
42
45
34
49
52
51
49
47
52
53
89
58
56
63
60
58
62
60
68
65
66
63
66
55
71
69
73
71
81
76
74
73
78
76
78
79
68
83
84
86
84
81
86
87
233
91
92
97
95
93
92
95
102
10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #49:

score: 0
Accepted
time: 37ms
memory: 15500kb

input:

500000 17709
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
100...

output:

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...

result:

ok correct

Test #50:

score: 0
Accepted
time: 45ms
memory: 15104kb

input:

392833 196416
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
10...

output:

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...

result:

ok correct

Test #51:

score: 0
Accepted
time: 51ms
memory: 15596kb

input:

500000 317809
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
10...

output:

010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...

result:

ok correct

Test #52:

score: 0
Accepted
time: 39ms
memory: 15096kb

input:

392833 196417
2
6
4
2
4
10
8
6
8
16
12
10
14
12
14
42
18
22
20
18
20
26
24
22
24
32
28
26
30
28
30
16
34
38
36
34
36
32
40
38
40
68
44
46
44
48
46
58
50
52
50
48
54
56
54
52
56
42
60
62
60
58
64
66
64
62
66
110
70
74
72
70
72
78
76
74
76
84
80
82
80
78
82
68
86
88
86
90
88
100
92
96
94
92
94
90
98
9...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #53:

score: 0
Accepted
time: 30ms
memory: 14600kb

input:

392833 207363
2
4
2
10
6
8
6
4
8
26
12
16
14
12
14
20
18
16
18
10
22
20
24
22
24
42
28
32
30
28
30
26
34
38
36
34
36
32
40
38
40
110
44
46
44
48
46
52
50
48
50
68
54
58
56
54
56
62
60
58
60
52
64
66
64
62
66
42
70
72
70
74
72
84
76
78
76
74
80
82
80
78
82
94
86
88
86
84
90
88
92
90
92
68
96
98
96
10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #54:

score: 0
Accepted
time: 45ms
memory: 14876kb

input:

392833 207362
2
4
2
10
6
8
6
4
8
26
12
16
14
12
14
20
18
16
18
10
22
20
24
22
24
42
28
32
30
28
30
26
34
38
36
34
36
32
40
38
40
110
44
46
44
48
46
52
50
48
50
68
54
58
56
54
56
62
60
58
60
52
64
66
64
62
66
42
70
72
70
74
72
84
76
78
76
74
80
82
80
78
82
94
86
88
86
84
90
88
92
90
92
68
96
98
96
10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #55:

score: 0
Accepted
time: 51ms
memory: 15476kb

input:

500000 499999
2
4
2
8
6
4
6
16
10
12
10
8
14
12
14
32
18
20
18
24
22
20
22
16
26
28
26
24
30
28
30
64
34
36
34
40
38
36
38
48
42
44
42
40
46
44
46
32
50
52
50
56
54
52
54
48
58
60
58
56
62
60
62
128
66
68
66
72
70
68
70
80
74
76
74
72
78
76
78
96
82
84
82
88
86
84
86
80
90
92
90
88
94
92
94
64
98
10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct

Test #56:

score: 0
Accepted
time: 58ms
memory: 15520kb

input:

500000 499999
3
1
8
5
6
3
6
21
10
11
13
11
8
15
18
15
16
13
20
18
34
23
26
25
23
29
26
27
21
31
29
31
32
89
37
35
42
39
40
37
40
55
45
43
47
45
42
49
52
51
49
47
54
52
34
57
60
57
58
68
62
63
60
65
63
65
66
55
71
69
73
71
81
76
74
73
78
76
78
79
68
83
86
85
83
81
88
86
233
91
92
94
92
97
96
94
102
1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok correct