QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#793071#4565. Rarest Insects_8_8_#25 81ms4252kbC++202.5kb2024-11-29 16:29:442024-11-29 16:29:45

Judging History

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

  • [2024-11-29 16:29:45]
  • 评测
  • 测评结果:25
  • 用时:81ms
  • 内存:4252kb
  • [2024-11-29 16:29:44]
  • 提交

answer

#include "insects.h"
#include <bits/stdc++.h> 

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
vector<int> p;
set<int> cur;

void add(int i) {
    cur.insert(i);
    i = p[i];
    move_inside(i);
}
void del(int i) {
    cur.erase(i);
    i = p[i];
    move_outside(i);
}
vector<vector<int>> solve(int l, int r) {
    if(l == r) {
        add(l);
        return {{l}};
    }
    int mid = (l + r) >> 1;
    auto L = solve(l, mid);
    while(!cur.empty()) {
        del(*cur.begin());
    }
    auto R = solve(mid + 1, r);
    vector<vector<int>> ret = R;
    for(auto v : L) {
        add(v[0]);
        if(press_button() == 1) {
            ret.push_back(v);
        } else {
            int it = 0;
            for(auto j : R) {
                del(j[0]);
                if(press_button() == 1) {
                    for(int f : v) {
                        ret[it].push_back(f);
                    }
                    add(j[0]);
                    break;
                }
                it++;
                add(j[0]);
            }
            del(v[0]);
        }
    }
    return ret;
}

int try_solve() {
    for(int i = 0; i < n; i++) {
        add(i);
    }
    int x = press_button();
    if(x < 35) {
        set<int> left;
        for(int i = 0; i < n; i++) {
            del(i);
        }
        for(int i = 0; i < n; i++) {
            left.insert(i);
        }
        int st = 0, prev = -1;
        while(!left.empty()) {
            int col = 0;
            vector<int> dd;
            for(int j : left) {
                add(j);
                if(press_button() == 2) {
                    del(j);
                } else {
                    dd.push_back(j);
                    col++;
                }
            }
            if(prev !=- 1 && col != prev) {
                return st;
            }
            st++;
            for(int j : dd) {
                del(j);
                left.erase(j);
            }
            prev = col;
        }
        return st;  
    }
    return -1;
}
int min_cardinality(int NN) {
    n = NN;
    int res = (int)1e9;
    p.resize(n);
    iota(p.begin(), p.end(), 0);
    shuffle(p.begin(), p.end(), rng);
    int val = try_solve();
    if(val != -1) return val;
    auto f = solve(0, n - 1);
    for(auto j : f) {
        res = min(res, (int)j.size());
    }
    return res;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

6
3
1
1
2
2
1
2
1
2
1

output:

8
0 4
8
0 1
8
0 2
8
0 5
8
0 0
8
0 3
8
2
8
1 4
8
1 1
8
1 2
8
1 5
8
1 0
8
1 3
8
0 4
8
2
8
0 1
8
2
8
0 2
8
2
8
1 2
8
0 5
8
2
8
1 5
8
0 0
8
2
8
0 3
8
2
8
1 3
8
1 4
8
1 1
8
1 0
8
0 2
8
2
8
0 5
8
2
8
1 5
8
0 3
8
2
8
3 1

result:

ok 

Test #2:

score: 10
Accepted
time: 1ms
memory: 3808kb

input:

2
2
1
2
1

output:

8
0 1
8
0 0
8
2
8
1 1
8
1 0
8
0 1
8
2
8
0 0
8
2
8
1 0
8
1 1
8
0 0
8
2
8
1 0
8
3 2

result:

ok 

Test #3:

score: 10
Accepted
time: 1ms
memory: 3780kb

input:

2
1
1
1

output:

8
0 1
8
0 0
8
2
8
1 1
8
1 0
8
0 1
8
2
8
0 0
8
2
8
1 1
8
1 0
8
3 1

result:

ok 

Test #4:

score: 10
Accepted
time: 1ms
memory: 4076kb

input:

3
2
1
1
2
1

output:

8
0 1
8
0 0
8
0 2
8
2
8
1 1
8
1 0
8
1 2
8
0 1
8
2
8
0 0
8
2
8
0 2
8
2
8
1 2
8
1 1
8
1 0
8
0 2
8
2
8
3 1

result:

ok 

Test #5:

score: 10
Accepted
time: 1ms
memory: 4076kb

input:

5
3
1
1
2
2
2
1
2
1
1

output:

8
0 3
8
0 1
8
0 4
8
0 0
8
0 2
8
2
8
1 3
8
1 1
8
1 4
8
1 0
8
1 2
8
0 3
8
2
8
0 1
8
2
8
0 4
8
2
8
1 4
8
0 0
8
2
8
1 0
8
0 2
8
2
8
1 2
8
1 3
8
1 1
8
0 4
8
2
8
0 0
8
2
8
1 0
8
0 2
8
2
8
1 4
8
1 2
8
0 0
8
2
8
3 2

result:

ok 

Test #6:

score: 10
Accepted
time: 1ms
memory: 3892kb

input:

8
5
1
1
2
2
2
1
2
2
1
1
2
2
2

output:

8
0 5
8
0 0
8
0 6
8
0 1
8
0 4
8
0 7
8
0 2
8
0 3
8
2
8
1 5
8
1 0
8
1 6
8
1 1
8
1 4
8
1 7
8
1 2
8
1 3
8
0 5
8
2
8
0 0
8
2
8
0 6
8
2
8
1 6
8
0 1
8
2
8
1 1
8
0 4
8
2
8
1 4
8
0 7
8
2
8
0 2
8
2
8
1 2
8
0 3
8
2
8
1 3
8
1 5
8
1 0
8
1 7
8
0 6
8
2
8
0 1
8
2
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 3
8
2
8
1 3
8
3 1

result:

ok 

Test #7:

score: 10
Accepted
time: 1ms
memory: 4132kb

input:

199
199
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
...

output:

8
0 190
8
0 24
8
0 67
8
0 2
8
0 133
8
0 115
8
0 98
8
0 22
8
0 64
8
0 40
8
0 197
8
0 27
8
0 100
8
0 83
8
0 99
8
0 171
8
0 180
8
0 50
8
0 194
8
0 21
8
0 56
8
0 153
8
0 116
8
0 48
8
0 132
8
0 55
8
0 41
8
0 52
8
0 13
8
0 175
8
0 182
8
0 184
8
0 186
8
0 165
8
0 87
8
0 152
8
0 139
8
0 38
8
0 159
8
0 188
8...

result:

ok 

Test #8:

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

input:

200
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 69
8
0 17
8
0 86
8
0 191
8
0 138
8
0 4
8
0 97
8
0 198
8
0 84
8
0 33
8
0 49
8
0 135
8
0 166
8
0 87
8
0 14
8
0 78
8
0 62
8
0 21
8
0 10
8
0 150
8
0 125
8
0 6
8
0 171
8
0 98
8
0 40
8
0 122
8
0 112
8
0 28
8
0 54
8
0 111
8
0 44
8
0 186
8
0 59
8
0 64
8
0 134
8
0 35
8
0 104
8
0 99
8
0 188
8
0 94
8
0 20
...

result:

ok 

Test #9:

score: 10
Accepted
time: 4ms
memory: 3888kb

input:

200
15
1
1
1
2
1
1
1
2
1
2
1
1
1
1
2
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 101
8
0 23
8
0 137
8
0 105
8
0 5
8
0 89
8
0 114
8
0 162
8
0 66
8
0 117
8
0 73
8
0 159
8
0 78
8
0 2
8
0 50
8
0 40
8
0 17
8
0 81
8
0 60
8
0 22
8
0 186
8
0 169
8
0 115
8
0 176
8
0 119
8
0 118
8
0 132
8
0 135
8
0 185
8
0 107
8
0 152
8
0 125
8
0 104
8
0 96
8
0 88
8
0 3
8
0 189
8
0 6
8
0 56
8
0 47
8
0...

result:

ok 

Test #10:

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

input:

198
21
1
1
1
1
1
2
1
2
1
2
1
1
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 197
8
0 99
8
0 93
8
0 23
8
0 68
8
0 125
8
0 151
8
0 0
8
0 164
8
0 143
8
0 192
8
0 145
8
0 101
8
0 14
8
0 150
8
0 152
8
0 22
8
0 31
8
0 191
8
0 133
8
0 161
8
0 173
8
0 160
8
0 86
8
0 8
8
0 69
8
0 122
8
0 153
8
0 190
8
0 10
8
0 12
8
0 94
8
0 180
8
0 97
8
0 42
8
0 194
8
0 187
8
0 157
8
0 7
8
0 55
8...

result:

ok 

Test #11:

score: 10
Accepted
time: 3ms
memory: 4124kb

input:

199
198
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
...

output:

8
0 173
8
0 4
8
0 97
8
0 12
8
0 52
8
0 64
8
0 10
8
0 167
8
0 141
8
0 156
8
0 102
8
0 41
8
0 143
8
0 180
8
0 139
8
0 37
8
0 42
8
0 191
8
0 174
8
0 98
8
0 169
8
0 144
8
0 150
8
0 61
8
0 178
8
0 198
8
0 104
8
0 135
8
0 43
8
0 36
8
0 164
8
0 116
8
0 163
8
0 60
8
0 123
8
0 148
8
0 87
8
0 120
8
0 18
8
0 1...

result:

ok 

Test #12:

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

input:

197
98
1
1
2
2
1
1
1
1
1
1
2
2
2
1
1
1
1
1
2
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
2
1
1
1
2
2
1
1
2
2
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
2
1
2
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 79
8
0 26
8
0 69
8
0 6
8
0 114
8
0 51
8
0 96
8
0 153
8
0 128
8
0 156
8
0 145
8
0 48
8
0 44
8
0 163
8
0 194
8
0 188
8
0 73
8
0 80
8
0 12
8
0 98
8
0 38
8
0 66
8
0 62
8
0 97
8
0 105
8
0 23
8
0 146
8
0 167
8
0 19
8
0 132
8
0 47
8
0 34
8
0 81
8
0 184
8
0 24
8
0 55
8
0 183
8
0 102
8
0 25
8
0 130
8
0 1...

result:

ok 

Test #13:

score: 10
Accepted
time: 2ms
memory: 4120kb

input:

197
49
1
1
1
2
1
1
2
1
1
2
1
1
2
2
1
1
1
1
1
2
1
1
2
1
2
2
1
1
2
1
1
2
2
2
1
1
2
1
1
1
1
1
2
1
1
1
2
1
1
1
2
1
1
2
2
1
1
2
2
1
1
2
2
2
1
2
1
2
2
2
1
2
2
2
2
1
2
2
1
2
1
1
1
2
2
1
1
1
1
1
1
2
2
2
1
2
1
1
1
1
1
1
2
1
1
2
1
1
2
1
2
2
2
1
2
2
2
2
1
1
1
1
1
2
1
1
1
2
1
1
1
2
1
1
2
1
1
2
1
2
2
1
1
1
2
2
1...

output:

8
0 121
8
0 147
8
0 187
8
0 101
8
0 190
8
0 128
8
0 148
8
0 131
8
0 162
8
0 67
8
0 9
8
0 117
8
0 4
8
0 102
8
0 59
8
0 29
8
0 81
8
0 87
8
0 46
8
0 85
8
0 158
8
0 196
8
0 0
8
0 49
8
0 31
8
0 92
8
0 16
8
0 143
8
0 125
8
0 98
8
0 13
8
0 53
8
0 136
8
0 112
8
0 69
8
0 12
8
0 144
8
0 138
8
0 156
8
0 45
8
0...

result:

ok 

Test #14:

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

input:

198
16
1
1
1
1
1
1
1
2
2
1
2
2
2
2
1
2
2
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 42
8
0 179
8
0 77
8
0 59
8
0 84
8
0 175
8
0 20
8
0 146
8
0 133
8
0 56
8
0 139
8
0 38
8
0 92
8
0 121
8
0 137
8
0 0
8
0 35
8
0 107
8
0 30
8
0 174
8
0 2
8
0 102
8
0 188
8
0 23
8
0 154
8
0 47
8
0 28
8
0 22
8
0 185
8
0 61
8
0 181
8
0 192
8
0 118
8
0 89
8
0 141
8
0 53
8
0 67
8
0 78
8
0 50
8
0 8
8
0 19...

result:

ok 

Test #15:

score: 10
Accepted
time: 5ms
memory: 4088kb

input:

200
45
1
2
1
1
1
1
2
1
1
2
1
2
2
1
1
1
1
1
1
2
1
1
2
2
1
1
2
1
1
2
1
1
2
1
1
1
2
1
1
1
2
2
1
1
1
2
1
1
1
1
1
2
2
1
2
2
1
1
2
2
2
1
2
2
2
1
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
1
2
1
1
1
1
1
1
2
2
1
2
1
2
2
2
1
1
2
1
1
1
1
1
1
1
2
2
2
1
2
2
2
2
2
1
2
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
2
1
2
2
1
2
2
2...

output:

8
0 13
8
0 110
8
0 85
8
0 18
8
0 111
8
0 141
8
0 195
8
0 145
8
0 197
8
0 149
8
0 50
8
0 25
8
0 26
8
0 180
8
0 20
8
0 182
8
0 15
8
0 191
8
0 87
8
0 82
8
0 75
8
0 80
8
0 139
8
0 4
8
0 44
8
0 179
8
0 186
8
0 148
8
0 128
8
0 124
8
0 88
8
0 112
8
0 60
8
0 36
8
0 126
8
0 52
8
0 74
8
0 81
8
0 164
8
0 198
8...

result:

ok 

Test #16:

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

input:

196
32
1
1
1
1
2
1
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 117
8
0 47
8
0 127
8
0 11
8
0 23
8
0 124
8
0 34
8
0 114
8
0 136
8
0 42
8
0 158
8
0 181
8
0 186
8
0 90
8
0 137
8
0 9
8
0 18
8
0 133
8
0 154
8
0 53
8
0 141
8
0 172
8
0 188
8
0 46
8
0 97
8
0 5
8
0 38
8
0 79
8
0 54
8
0 119
8
0 14
8
0 60
8
0 91
8
0 180
8
0 98
8
0 50
8
0 169
8
0 179
8
0 12
8
0 65
8
0 ...

result:

ok 

Test #17:

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

input:

199
34
1
1
1
1
1
1
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 108
8
0 157
8
0 81
8
0 111
8
0 154
8
0 80
8
0 9
8
0 106
8
0 30
8
0 89
8
0 7
8
0 137
8
0 5
8
0 186
8
0 50
8
0 62
8
0 4
8
0 116
8
0 143
8
0 38
8
0 71
8
0 101
8
0 165
8
0 125
8
0 159
8
0 36
8
0 172
8
0 152
8
0 97
8
0 61
8
0 67
8
0 141
8
0 77
8
0 13
8
0 70
8
0 120
8
0 85
8
0 74
8
0 145
8
0 17
8
0 12...

result:

ok 

Test #18:

score: 10
Accepted
time: 5ms
memory: 3832kb

input:

196
20
1
1
2
1
1
1
1
1
1
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 157
8
0 94
8
0 95
8
0 114
8
0 74
8
0 182
8
0 12
8
0 29
8
0 49
8
0 48
8
0 47
8
0 155
8
0 91
8
0 97
8
0 161
8
0 122
8
0 103
8
0 13
8
0 46
8
0 162
8
0 19
8
0 152
8
0 139
8
0 6
8
0 151
8
0 22
8
0 140
8
0 38
8
0 69
8
0 179
8
0 5
8
0 159
8
0 127
8
0 131
8
0 168
8
0 172
8
0 53
8
0 75
8
0 156
8
0 121
8
...

result:

ok 

Test #19:

score: 10
Accepted
time: 3ms
memory: 3856kb

input:

196
25
1
1
1
1
2
1
1
1
1
2
2
2
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 8
8
0 3
8
0 180
8
0 42
8
0 119
8
0 0
8
0 170
8
0 82
8
0 151
8
0 56
8
0 174
8
0 30
8
0 185
8
0 137
8
0 5
8
0 122
8
0 57
8
0 187
8
0 106
8
0 45
8
0 23
8
0 116
8
0 36
8
0 109
8
0 150
8
0 135
8
0 169
8
0 2
8
0 74
8
0 124
8
0 120
8
0 164
8
0 89
8
0 6
8
0 88
8
0 85
8
0 33
8
0 31
8
0 50
8
0 81
8
0 48
8...

result:

ok 

Test #20:

score: 10
Accepted
time: 2ms
memory: 3852kb

input:

196
19
1
1
1
1
2
2
1
2
1
1
2
1
1
2
2
2
1
1
1
2
1
1
2
2
1
2
2
1
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 132
8
0 49
8
0 54
8
0 186
8
0 179
8
0 138
8
0 139
8
0 86
8
0 119
8
0 12
8
0 43
8
0 195
8
0 121
8
0 166
8
0 100
8
0 53
8
0 29
8
0 44
8
0 104
8
0 24
8
0 193
8
0 144
8
0 1
8
0 131
8
0 162
8
0 171
8
0 3
8
0 147
8
0 76
8
0 94
8
0 67
8
0 111
8
0 184
8
0 4
8
0 98
8
0 187
8
0 146
8
0 156
8
0 170
8
0 22
...

result:

ok 

Test #21:

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

input:

200
10
1
1
1
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
1
2
2
2
1
1
2
2
2
2
2
1
1
2
1
2
1
1
1
1
2
2
2
2
2
2
2
2
1
1
2
1
2
1
1
2
1
2
1
1
2
1
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
1
1
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2...

output:

8
0 39
8
0 99
8
0 142
8
0 13
8
0 181
8
0 73
8
0 153
8
0 140
8
0 141
8
0 0
8
0 18
8
0 30
8
0 41
8
0 185
8
0 40
8
0 145
8
0 101
8
0 150
8
0 50
8
0 78
8
0 92
8
0 149
8
0 195
8
0 120
8
0 27
8
0 197
8
0 29
8
0 59
8
0 69
8
0 180
8
0 58
8
0 160
8
0 97
8
0 151
8
0 54
8
0 67
8
0 117
8
0 21
8
0 105
8
0 80
8
0...

result:

ok 

Test #22:

score: 10
Accepted
time: 2ms
memory: 4088kb

input:

199
6
1
1
1
2
1
1
1
2
2
1
1
2
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
1
1
1
1
1
1
1
1
1
1
2
2
1
2
1
2
1
1
1
2
2
1
2
2
2
1
1
2
1
2
1
2
2
1
1
1
2
1
1
2
2
1
2
1
2
2
1
1
1
2
2
2
2
1
2
1
2
2
1
2
1
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
2
1
1
1
1
1
2
1
2
2
1
2
2
2
2
1
2
2
1
2
2
2
2
1
2
1
2
2
2
2
2
2
1
2
...

output:

8
0 83
8
0 25
8
0 24
8
0 131
8
0 130
8
0 56
8
0 13
8
0 171
8
0 132
8
0 133
8
0 176
8
0 19
8
0 179
8
0 88
8
0 47
8
0 198
8
0 10
8
0 2
8
0 117
8
0 23
8
0 191
8
0 73
8
0 1
8
0 91
8
0 148
8
0 188
8
0 38
8
0 127
8
0 192
8
0 99
8
0 144
8
0 172
8
0 42
8
0 124
8
0 44
8
0 79
8
0 174
8
0 193
8
0 78
8
0 9
8
0 ...

result:

ok 

Test #23:

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

input:

198
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
1
2
2
1
1
2
1
2
1
1
2
1
1
1
2
1
2
2
2
1
1
2
2
2
1
1
2
2
2
1
1
1
2
2
2
1
1
2
1
1
1
2
2
1
1
1
1
1
2
2
1
1
1
1
2
1
2
1
1
2
1
2
2
2
2
1
2
2
1
1
...

output:

8
0 184
8
0 66
8
0 30
8
0 165
8
0 13
8
0 106
8
0 6
8
0 50
8
0 54
8
0 47
8
0 67
8
0 172
8
0 161
8
0 157
8
0 40
8
0 25
8
0 49
8
0 194
8
0 107
8
0 197
8
0 33
8
0 179
8
0 0
8
0 167
8
0 123
8
0 101
8
0 16
8
0 143
8
0 77
8
0 88
8
0 42
8
0 139
8
0 142
8
0 153
8
0 130
8
0 152
8
0 115
8
0 131
8
0 96
8
0 26
8...

result:

ok 

Subtask #2:

score: 15
Accepted

Test #24:

score: 15
Accepted
time: 3ms
memory: 3868kb

input:

1000
1000
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

output:

8
0 283
8
0 866
8
0 416
8
0 310
8
0 516
8
0 933
8
0 425
8
0 263
8
0 362
8
0 25
8
0 240
8
0 756
8
0 835
8
0 792
8
0 30
8
0 28
8
0 370
8
0 534
8
0 433
8
0 62
8
0 839
8
0 906
8
0 395
8
0 554
8
0 540
8
0 978
8
0 311
8
0 90
8
0 613
8
0 436
8
0 47
8
0 607
8
0 980
8
0 379
8
0 444
8
0 931
8
0 531
8
0 4
8
0 ...

result:

ok 

Test #25:

score: 15
Accepted
time: 0ms
memory: 3916kb

input:

1000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 191
8
0 707
8
0 535
8
0 540
8
0 700
8
0 747
8
0 825
8
0 774
8
0 138
8
0 236
8
0 711
8
0 762
8
0 143
8
0 900
8
0 538
8
0 737
8
0 556
8
0 770
8
0 180
8
0 146
8
0 140
8
0 978
8
0 543
8
0 871
8
0 61
8
0 157
8
0 207
8
0 683
8
0 171
8
0 989
8
0 977
8
0 47
8
0 464
8
0 486
8
0 948
8
0 288
8
0 330
8
0 88...

result:

ok 

Test #26:

score: 15
Accepted
time: 27ms
memory: 3940kb

input:

999
33
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
2
1
1
1
1
1
2
2
1
2
2
1
1
2
2
2
1
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 871
8
0 835
8
0 292
8
0 557
8
0 655
8
0 605
8
0 693
8
0 325
8
0 335
8
0 21
8
0 422
8
0 68
8
0 748
8
0 893
8
0 296
8
0 531
8
0 650
8
0 725
8
0 62
8
0 458
8
0 159
8
0 61
8
0 256
8
0 324
8
0 238
8
0 417
8
0 858
8
0 709
8
0 649
8
0 433
8
0 135
8
0 113
8
0 758
8
0 634
8
0 591
8
0 967
8
0 519
8
0 250
...

result:

ok 

Test #27:

score: 15
Accepted
time: 28ms
memory: 3924kb

input:

999
48
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
2
2
2
2
2
2
2
1
2
2
2
1
1
1
1
1
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
2
2
2
2
1
1
1
2
2
2
2
2
2
2
1
1
1
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2...

output:

8
0 884
8
0 580
8
0 349
8
0 909
8
0 46
8
0 464
8
0 142
8
0 938
8
0 207
8
0 49
8
0 421
8
0 333
8
0 603
8
0 19
8
0 703
8
0 203
8
0 452
8
0 60
8
0 315
8
0 598
8
0 40
8
0 149
8
0 211
8
0 754
8
0 589
8
0 830
8
0 947
8
0 481
8
0 227
8
0 653
8
0 749
8
0 44
8
0 26
8
0 140
8
0 314
8
0 226
8
0 893
8
0 526
8
0...

result:

ok 

Test #28:

score: 15
Accepted
time: 7ms
memory: 3928kb

input:

996
995
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
...

output:

8
0 811
8
0 184
8
0 741
8
0 137
8
0 238
8
0 516
8
0 869
8
0 880
8
0 605
8
0 518
8
0 559
8
0 907
8
0 313
8
0 582
8
0 522
8
0 574
8
0 228
8
0 222
8
0 841
8
0 875
8
0 904
8
0 237
8
0 369
8
0 581
8
0 692
8
0 799
8
0 936
8
0 296
8
0 986
8
0 555
8
0 834
8
0 180
8
0 229
8
0 565
8
0 444
8
0 181
8
0 205
8
0 ...

result:

ok 

Test #29:

score: 15
Accepted
time: 4ms
memory: 4020kb

input:

995
496
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
2
2
2
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
1
1
1
1
1
1
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
2
1
1
2
2
1
1
1
1
1
1
2
2
...

output:

8
0 912
8
0 677
8
0 404
8
0 88
8
0 781
8
0 37
8
0 946
8
0 18
8
0 287
8
0 830
8
0 492
8
0 338
8
0 6
8
0 503
8
0 594
8
0 460
8
0 539
8
0 779
8
0 311
8
0 693
8
0 550
8
0 314
8
0 116
8
0 428
8
0 780
8
0 812
8
0 179
8
0 582
8
0 364
8
0 200
8
0 700
8
0 928
8
0 284
8
0 603
8
0 274
8
0 792
8
0 186
8
0 678
8...

result:

ok 

Test #30:

score: 15
Accepted
time: 8ms
memory: 4124kb

input:

998
249
2
1
2
1
1
1
1
2
1
1
2
2
1
2
1
1
1
1
2
2
1
1
1
1
2
1
2
2
2
1
1
2
2
1
2
2
2
1
2
2
2
2
1
2
2
1
2
1
1
1
1
2
1
1
1
2
1
2
2
1
2
2
2
1
1
1
1
2
2
1
1
1
2
1
1
2
1
2
2
2
1
1
2
2
2
2
1
2
2
1
2
2
2
1
2
1
2
2
1
2
2
2
2
1
2
2
2
1
1
1
2
2
1
1
2
1
1
1
2
2
1
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
2
2
1
2
2
2
1
2
2
2
...

output:

8
0 525
8
0 726
8
0 679
8
0 905
8
0 170
8
0 997
8
0 611
8
0 688
8
0 663
8
0 958
8
0 774
8
0 589
8
0 158
8
0 588
8
0 387
8
0 491
8
0 221
8
0 104
8
0 929
8
0 876
8
0 360
8
0 897
8
0 764
8
0 772
8
0 504
8
0 353
8
0 870
8
0 227
8
0 466
8
0 913
8
0 602
8
0 791
8
0 778
8
0 641
8
0 681
8
0 31
8
0 505
8
0 6...

result:

ok 

Test #31:

score: 15
Accepted
time: 6ms
memory: 4008kb

input:

998
34
1
1
1
1
1
1
1
1
2
1
1
1
2
2
1
2
1
1
2
1
2
1
1
2
1
1
1
2
1
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 900
8
0 679
8
0 893
8
0 583
8
0 73
8
0 870
8
0 885
8
0 342
8
0 385
8
0 594
8
0 568
8
0 450
8
0 105
8
0 852
8
0 324
8
0 766
8
0 915
8
0 416
8
0 432
8
0 746
8
0 828
8
0 429
8
0 171
8
0 219
8
0 237
8
0 443
8
0 97
8
0 496
8
0 279
8
0 36
8
0 670
8
0 499
8
0 486
8
0 395
8
0 803
8
0 922
8
0 543
8
0 358...

result:

ok 

Test #32:

score: 15
Accepted
time: 19ms
memory: 3872kb

input:

1000
217
1
2
1
1
1
2
1
1
2
2
1
2
1
1
2
2
1
1
2
1
1
1
1
2
1
1
1
2
2
2
1
2
1
1
2
2
2
2
1
1
2
1
1
1
1
2
2
1
1
1
1
2
1
2
2
2
1
2
1
1
1
1
2
1
1
1
2
1
2
1
1
1
2
1
1
2
2
2
1
2
1
2
2
1
2
2
2
2
1
1
2
2
2
2
1
2
2
2
1
2
1
2
2
1
2
1
1
1
1
2
1
1
1
1
2
2
1
2
1
2
1
2
1
1
1
1
2
2
1
1
2
2
2
1
2
1
1
2
2
1
1
2
1
1
1
1...

output:

8
0 643
8
0 906
8
0 399
8
0 995
8
0 679
8
0 889
8
0 307
8
0 361
8
0 383
8
0 860
8
0 95
8
0 187
8
0 761
8
0 729
8
0 114
8
0 662
8
0 813
8
0 211
8
0 880
8
0 511
8
0 214
8
0 952
8
0 690
8
0 484
8
0 528
8
0 173
8
0 350
8
0 644
8
0 956
8
0 156
8
0 275
8
0 934
8
0 25
8
0 801
8
0 550
8
0 258
8
0 660
8
0 67...

result:

ok 

Test #33:

score: 15
Accepted
time: 16ms
memory: 3892kb

input:

996
141
1
2
1
2
1
1
1
1
1
1
2
2
2
1
1
1
1
1
2
1
1
1
2
2
1
1
1
2
2
1
2
2
2
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
2
1
1
1
2
2
2
1
1
1
1
2
2
1
1
1
2
1
1
1
2
2
2
1
1
1
2
2
1
2
2
2
1
1
2
2
2
2
2
1
2
2
2
2
1
1
2
2
2
2
2
2
1
2
1
1
2
2
2
2
1
2
2
2
2
2
1
2
2
1
2
2
2
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
2
2
1
1
1
...

output:

8
0 568
8
0 798
8
0 820
8
0 581
8
0 968
8
0 654
8
0 9
8
0 85
8
0 656
8
0 262
8
0 693
8
0 945
8
0 628
8
0 574
8
0 71
8
0 358
8
0 765
8
0 570
8
0 991
8
0 276
8
0 351
8
0 925
8
0 251
8
0 815
8
0 275
8
0 144
8
0 801
8
0 426
8
0 99
8
0 854
8
0 186
8
0 970
8
0 685
8
0 554
8
0 92
8
0 919
8
0 806
8
0 962
8
...

result:

ok 

Test #34:

score: 15
Accepted
time: 7ms
memory: 4004kb

input:

1000
125
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
2
2
2
1
2
2
1
2
2
2
2
1
1
2
1
2
2
2
2
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
1
1
1
1
1
2
2
1
1
1
1
2
2
2
1
2
1
2
2
1
1
1
1
1
2
2
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1...

output:

8
0 468
8
0 803
8
0 284
8
0 800
8
0 743
8
0 934
8
0 291
8
0 91
8
0 908
8
0 85
8
0 218
8
0 0
8
0 369
8
0 406
8
0 790
8
0 588
8
0 579
8
0 630
8
0 438
8
0 195
8
0 19
8
0 802
8
0 997
8
0 257
8
0 325
8
0 33
8
0 913
8
0 613
8
0 669
8
0 596
8
0 491
8
0 904
8
0 952
8
0 283
8
0 757
8
0 121
8
0 136
8
0 649
8
...

result:

ok 

Test #35:

score: 15
Accepted
time: 6ms
memory: 4124kb

input:

1000
93
1
1
1
1
1
1
1
1
1
2
1
2
2
2
1
1
1
2
1
1
1
2
1
2
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
1
2
2
2
2
2
2
2
1
1
1
1
1
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
1
1
1
1
2
2
1
1
1
1
1
1
2
...

output:

8
0 444
8
0 780
8
0 996
8
0 556
8
0 63
8
0 48
8
0 107
8
0 218
8
0 308
8
0 993
8
0 336
8
0 288
8
0 672
8
0 403
8
0 250
8
0 495
8
0 810
8
0 541
8
0 609
8
0 615
8
0 948
8
0 593
8
0 246
8
0 324
8
0 827
8
0 498
8
0 550
8
0 924
8
0 496
8
0 134
8
0 695
8
0 81
8
0 79
8
0 96
8
0 768
8
0 635
8
0 66
8
0 941
8
...

result:

ok 

Test #36:

score: 15
Accepted
time: 12ms
memory: 4164kb

input:

997
79
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
1
1
1
2
1
2
2
2
2
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
2
2
2
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
2
1
2
2
2
2
2
1
1
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
1
1
2
2
2
2
2
2
2
1
1
1
1
1
1
1...

output:

8
0 178
8
0 783
8
0 868
8
0 817
8
0 108
8
0 54
8
0 621
8
0 425
8
0 731
8
0 461
8
0 622
8
0 858
8
0 546
8
0 923
8
0 613
8
0 604
8
0 169
8
0 278
8
0 755
8
0 35
8
0 834
8
0 174
8
0 934
8
0 210
8
0 819
8
0 751
8
0 573
8
0 358
8
0 240
8
0 797
8
0 147
8
0 700
8
0 807
8
0 454
8
0 952
8
0 100
8
0 659
8
0 48...

result:

ok 

Test #37:

score: 15
Accepted
time: 11ms
memory: 3892kb

input:

995
65
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
1
2
2
2
2
2
1
1
2
2
2
2
2
2
1
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
2
2
2
1
2
1
1
1
2
2
1
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
1
2
1
1
1
1
2
2
2
2
2
2
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1...

output:

8
0 807
8
0 992
8
0 165
8
0 199
8
0 121
8
0 662
8
0 532
8
0 949
8
0 743
8
0 461
8
0 948
8
0 488
8
0 545
8
0 189
8
0 228
8
0 320
8
0 797
8
0 20
8
0 230
8
0 242
8
0 938
8
0 826
8
0 954
8
0 576
8
0 169
8
0 45
8
0 709
8
0 465
8
0 572
8
0 238
8
0 744
8
0 486
8
0 3
8
0 551
8
0 39
8
0 620
8
0 607
8
0 879
8...

result:

ok 

Test #38:

score: 15
Accepted
time: 8ms
memory: 3836kb

input:

997
28
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
2
1
1
1
1
2
1
1
1
2
1
2
2
1
1
2
2
1
1
2
2
2
1
2
1
2
2
2
1
1
1
2
2
2
1
2
1
2
2
1
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2...

output:

8
0 735
8
0 632
8
0 153
8
0 891
8
0 89
8
0 10
8
0 543
8
0 4
8
0 300
8
0 514
8
0 181
8
0 173
8
0 944
8
0 898
8
0 695
8
0 778
8
0 171
8
0 567
8
0 655
8
0 934
8
0 988
8
0 837
8
0 733
8
0 773
8
0 877
8
0 90
8
0 444
8
0 754
8
0 13
8
0 403
8
0 819
8
0 361
8
0 908
8
0 805
8
0 494
8
0 275
8
0 418
8
0 716
8
...

result:

ok 

Test #39:

score: 15
Accepted
time: 11ms
memory: 3876kb

input:

997
19
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
2
1
2
2
1
1
2
2
2
2
2
2
2
2
2
2
1
1
2
2
1
2
1
2
1
2
2
1
1
1
1
2
2
2
2
1
1
1
2
1
1
2
2
2
1
1
2
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
1
2
1
1
1
2
1
2
1
2
1
2
2
1
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
1
1
2
2
2
2
1
2...

output:

8
0 872
8
0 257
8
0 437
8
0 742
8
0 556
8
0 828
8
0 489
8
0 589
8
0 3
8
0 481
8
0 522
8
0 791
8
0 832
8
0 892
8
0 71
8
0 591
8
0 723
8
0 582
8
0 215
8
0 855
8
0 518
8
0 774
8
0 838
8
0 237
8
0 188
8
0 779
8
0 689
8
0 554
8
0 445
8
0 260
8
0 401
8
0 169
8
0 246
8
0 711
8
0 676
8
0 315
8
0 7
8
0 658
8...

result:

ok 

Test #40:

score: 15
Accepted
time: 0ms
memory: 3872kb

input:

996
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
2
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
2
1
1
2
2
2
1
2
2
2
2
1
1
1
2
2
1
1
2
1
1
1
1
1
1
2
1
1
1
1
2
1
1
2
1
1
2
1
2
2
1
1
2
1
2
2
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
2
1
1
2
1
1
2
2
2
2
2
1...

output:

8
0 168
8
0 669
8
0 367
8
0 549
8
0 500
8
0 811
8
0 628
8
0 240
8
0 665
8
0 78
8
0 475
8
0 200
8
0 111
8
0 848
8
0 777
8
0 185
8
0 53
8
0 84
8
0 662
8
0 129
8
0 215
8
0 703
8
0 216
8
0 675
8
0 65
8
0 713
8
0 220
8
0 873
8
0 192
8
0 787
8
0 875
8
0 227
8
0 296
8
0 410
8
0 568
8
0 478
8
0 434
8
0 201
...

result:

ok 

Test #41:

score: 15
Accepted
time: 7ms
memory: 4148kb

input:

995
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
2
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
2
1
1
1
1
1
2
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
2
1
1
2
1
2
1
2
1
1
1
1
1
1
1
2
2
2
1
2
1
1
2
1
2
...

output:

8
0 21
8
0 886
8
0 598
8
0 222
8
0 522
8
0 111
8
0 317
8
0 481
8
0 80
8
0 728
8
0 507
8
0 831
8
0 950
8
0 523
8
0 34
8
0 374
8
0 136
8
0 861
8
0 375
8
0 605
8
0 39
8
0 612
8
0 373
8
0 320
8
0 653
8
0 105
8
0 787
8
0 187
8
0 543
8
0 498
8
0 769
8
0 873
8
0 223
8
0 776
8
0 96
8
0 870
8
0 488
8
0 469
8...

result:

ok 

Test #42:

score: 15
Accepted
time: 0ms
memory: 3900kb

input:

995
6
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
2
1
2
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
...

output:

8
0 943
8
0 257
8
0 581
8
0 652
8
0 629
8
0 133
8
0 922
8
0 892
8
0 322
8
0 708
8
0 392
8
0 38
8
0 224
8
0 508
8
0 799
8
0 951
8
0 666
8
0 558
8
0 401
8
0 154
8
0 687
8
0 338
8
0 452
8
0 210
8
0 221
8
0 319
8
0 950
8
0 493
8
0 623
8
0 408
8
0 948
8
0 562
8
0 330
8
0 73
8
0 991
8
0 294
8
0 22
8
0 966...

result:

ok 

Subtask #3:

score: 0
Wrong Answer

Test #43:

score: 75
Accepted
time: 1ms
memory: 3816kb

input:

2
2
1
2
1

output:

8
0 1
8
0 0
8
2
8
1 1
8
1 0
8
0 1
8
2
8
0 0
8
2
8
1 0
8
1 1
8
0 0
8
2
8
1 0
8
3 2

result:

ok 

Test #44:

score: 75
Accepted
time: 1ms
memory: 4112kb

input:

2
1
1
1

output:

8
0 1
8
0 0
8
2
8
1 1
8
1 0
8
0 1
8
2
8
0 0
8
2
8
1 1
8
1 0
8
3 1

result:

ok 

Test #45:

score: 75
Accepted
time: 1ms
memory: 3828kb

input:

3
2
1
2
1
1

output:

8
0 1
8
0 2
8
0 0
8
2
8
1 1
8
1 2
8
1 0
8
0 1
8
2
8
0 2
8
2
8
1 2
8
0 0
8
2
8
1 1
8
1 0
8
0 2
8
2
8
3 1

result:

ok 

Test #46:

score: 75
Accepted
time: 1ms
memory: 4112kb

input:

6
5
1
2
2
2
2
1
1
2
2
2

output:

8
0 1
8
0 0
8
0 3
8
0 4
8
0 5
8
0 2
8
2
8
1 1
8
1 0
8
1 3
8
1 4
8
1 5
8
1 2
8
0 1
8
2
8
0 0
8
2
8
1 0
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 5
8
2
8
1 5
8
0 2
8
2
8
1 1
8
1 2
8
0 0
8
2
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 5
8
2
8
1 5
8
3 1

result:

ok 

Test #47:

score: 70.33
Acceptable Answer
time: 1ms
memory: 3812kb

input:

10
6
1
1
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
1
2
2
2
1
1
2
2
1
2

output:

8
0 0
8
0 2
8
0 4
8
0 5
8
0 1
8
0 8
8
0 7
8
0 3
8
0 9
8
0 6
8
2
8
1 0
8
1 2
8
1 4
8
1 5
8
1 1
8
1 8
8
1 7
8
1 3
8
1 9
8
1 6
8
0 0
8
2
8
0 2
8
2
8
0 4
8
2
8
1 4
8
0 5
8
2
8
1 5
8
0 1
8
2
8
1 1
8
0 8
8
2
8
1 8
8
0 7
8
2
8
1 7
8
0 3
8
2
8
1 3
8
0 9
8
2
8
1 9
8
0 6
8
2
8
1 6
8
1 0
8
1 2
8
0 4
8
2
8
0 5
...

result:

points 0.93773333330 points  0.93773333330

Test #48:

score: 70.34
Acceptable Answer
time: 3ms
memory: 3952kb

input:

2000
2000
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

output:

8
0 1327
8
0 543
8
0 1267
8
0 1170
8
0 1038
8
0 22
8
0 408
8
0 1692
8
0 258
8
0 56
8
0 831
8
0 1818
8
0 461
8
0 1069
8
0 1429
8
0 128
8
0 1585
8
0 477
8
0 521
8
0 1548
8
0 1849
8
0 341
8
0 959
8
0 611
8
0 1433
8
0 1519
8
0 1163
8
0 455
8
0 323
8
0 857
8
0 1737
8
0 1860
8
0 1271
8
0 1581
8
0 1606
8
0...

result:

points 0.93786666670 points  0.93786666670

Test #49:

score: 75
Accepted
time: 7ms
memory: 4092kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 943
8
0 1228
8
0 418
8
0 812
8
0 1613
8
0 925
8
0 997
8
0 609
8
0 1493
8
0 1294
8
0 1467
8
0 1484
8
0 1137
8
0 1062
8
0 1104
8
0 458
8
0 1048
8
0 188
8
0 159
8
0 1540
8
0 128
8
0 1836
8
0 172
8
0 872
8
0 341
8
0 1619
8
0 1556
8
0 1349
8
0 1646
8
0 1643
8
0 352
8
0 1668
8
0 421
8
0 1406
8
0 1312
...

result:

ok 

Test #50:

score: 13.01
Acceptable Answer
time: 42ms
memory: 4176kb

input:

2000
46
1
1
2
2
1
1
1
1
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 1818
8
0 1792
8
0 1809
8
0 1218
8
0 1772
8
0 829
8
0 237
8
0 1478
8
0 183
8
0 1253
8
0 315
8
0 1217
8
0 1716
8
0 79
8
0 1776
8
0 123
8
0 1158
8
0 678
8
0 963
8
0 1293
8
0 618
8
0 1100
8
0 1657
8
0 1720
8
0 573
8
0 1453
8
0 735
8
0 1779
8
0 1718
8
0 100
8
0 1184
8
0 1649
8
0 1039
8
0 732
8
0 611
...

result:

points 0.17346666670 points  0.17346666670

Test #51:

score: 13.34
Acceptable Answer
time: 40ms
memory: 3924kb

input:

2000
67
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
1
1
1
1
2
2
2
2
2
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 1073
8
0 589
8
0 1877
8
0 813
8
0 881
8
0 1600
8
0 95
8
0 411
8
0 734
8
0 1427
8
0 1836
8
0 1421
8
0 489
8
0 524
8
0 883
8
0 1568
8
0 1980
8
0 204
8
0 221
8
0 843
8
0 1339
8
0 1727
8
0 675
8
0 452
8
0 1450
8
0 1909
8
0 1353
8
0 1546
8
0 955
8
0 405
8
0 936
8
0 425
8
0 1581
8
0 1415
8
0 1949
8
0 ...

result:

points 0.17786666670 points  0.17786666670

Test #52:

score: 70.33
Acceptable Answer
time: 16ms
memory: 3952kb

input:

2000
1999
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
1
2
...

output:

8
0 1029
8
0 1653
8
0 463
8
0 138
8
0 526
8
0 522
8
0 1309
8
0 506
8
0 1061
8
0 558
8
0 842
8
0 403
8
0 130
8
0 436
8
0 1077
8
0 1885
8
0 1629
8
0 1613
8
0 1769
8
0 1215
8
0 1975
8
0 1700
8
0 1862
8
0 1839
8
0 672
8
0 544
8
0 1972
8
0 488
8
0 1418
8
0 582
8
0 1302
8
0 202
8
0 1222
8
0 1505
8
0 142
8...

result:

points 0.93773333330 points  0.93773333330

Test #53:

score: 53.62
Acceptable Answer
time: 5ms
memory: 4080kb

input:

2000
1001
1
1
1
2
2
1
1
1
1
1
1
2
2
1
1
1
1
1
2
2
1
1
1
1
2
2
1
1
2
2
1
1
1
2
2
1
1
1
1
1
1
2
1
2
1
1
1
1
2
2
1
1
2
2
1
1
2
1
1
2
2
1
2
1
1
1
1
2
2
2
1
1
2
2
2
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
2
1
1
2
2
1
1
2
1
1
2
1
1
2
1
1
1
1
1
1
2
1
1
2
1
1
2
1
1
1
2
1
1
1
1
2
1
2
1
1
1
1
2
2
1
1
2
2
1
1
2
1
2
1
...

output:

8
0 555
8
0 697
8
0 1393
8
0 1620
8
0 54
8
0 567
8
0 1640
8
0 347
8
0 1521
8
0 755
8
0 791
8
0 714
8
0 622
8
0 1855
8
0 1445
8
0 1181
8
0 433
8
0 368
8
0 507
8
0 207
8
0 1320
8
0 632
8
0 968
8
0 1279
8
0 768
8
0 1361
8
0 271
8
0 334
8
0 379
8
0 1879
8
0 560
8
0 17
8
0 255
8
0 662
8
0 116
8
0 1477
8
...

result:

points 0.71493333330 points  0.71493333330

Test #54:

score: 59.28
Acceptable Answer
time: 16ms
memory: 3996kb

input:

2000
500
1
1
1
1
1
1
2
2
1
1
2
1
2
2
1
1
2
2
2
1
1
1
2
2
1
1
1
2
1
1
2
1
1
2
2
1
1
2
1
2
2
2
2
1
2
2
1
2
2
2
1
1
1
1
2
2
1
1
2
1
2
1
1
1
2
2
1
2
1
2
1
2
1
2
1
1
1
2
2
1
1
2
1
1
2
2
2
1
2
1
2
2
2
2
1
2
1
2
2
1
2
2
2
1
1
1
1
1
2
1
1
2
2
1
1
2
2
1
1
2
1
1
1
1
1
1
2
1
2
1
1
1
2
1
1
2
2
1
2
2
2
1
2
2
2
2...

output:

8
0 1470
8
0 1845
8
0 1304
8
0 72
8
0 344
8
0 144
8
0 1394
8
0 827
8
0 1881
8
0 323
8
0 1218
8
0 1661
8
0 1786
8
0 1941
8
0 107
8
0 661
8
0 1395
8
0 491
8
0 841
8
0 1265
8
0 1718
8
0 934
8
0 1150
8
0 1164
8
0 189
8
0 242
8
0 1834
8
0 61
8
0 1142
8
0 1515
8
0 70
8
0 798
8
0 1532
8
0 936
8
0 1575
8
0 ...

result:

points 0.79040 points  0.79040

Test #55:

score: 13.26
Acceptable Answer
time: 55ms
memory: 3988kb

input:

2000
47
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
2
2
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 306
8
0 1550
8
0 299
8
0 1438
8
0 268
8
0 1063
8
0 1887
8
0 1956
8
0 1829
8
0 1827
8
0 1217
8
0 1
8
0 16
8
0 826
8
0 1616
8
0 1869
8
0 1303
8
0 270
8
0 911
8
0 95
8
0 1755
8
0 644
8
0 1032
8
0 139
8
0 1386
8
0 149
8
0 548
8
0 1258
8
0 1842
8
0 329
8
0 1589
8
0 738
8
0 577
8
0 1239
8
0 1588
8
0 2...

result:

points 0.17680 points  0.17680

Test #56:

score: 54.02
Acceptable Answer
time: 14ms
memory: 3936kb

input:

1998
438
1
1
2
2
1
1
1
1
1
2
2
1
1
2
1
1
1
1
2
2
1
2
1
1
1
2
1
2
2
1
2
1
1
1
1
2
1
2
2
1
2
2
2
1
1
1
1
1
2
1
1
2
2
1
1
1
2
1
1
2
1
1
1
1
1
2
1
1
2
1
1
1
2
1
2
2
2
2
1
2
2
2
1
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
1
2
2
2
2
1
2
2
1
2
1
1
1
1
2
1
1
1
1
1
2
2
2
2
1
2
2
1
1
1
1
1
2
1
1
1
1
1
2
2
2
2
1
2
1...

output:

8
0 1295
8
0 463
8
0 968
8
0 1179
8
0 1266
8
0 1092
8
0 771
8
0 1247
8
0 1804
8
0 847
8
0 1857
8
0 339
8
0 197
8
0 234
8
0 1289
8
0 266
8
0 1405
8
0 81
8
0 942
8
0 496
8
0 1256
8
0 253
8
0 1974
8
0 1040
8
0 404
8
0 1333
8
0 1786
8
0 1026
8
0 1777
8
0 1276
8
0 787
8
0 702
8
0 1211
8
0 593
8
0 621
8
0...

result:

points 0.72026666670 points  0.72026666670

Test #57:

score: 42.01
Acceptable Answer
time: 18ms
memory: 3944kb

input:

1999
283
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
2
2
2
1
2
2
2
2
2
1
2
2
2
2
1
1
2
1
2
2
2
1
1
2
2
1
1
2
1
1
1
1
1
1
2
2
1
1
1
2
2
2
1
1
1
1
1
1
1
1
2
1
2
2
2
1
1
1
1
2
2
2
2
1
2
1
2
2
2
2
2
1
1
1
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
2
1
2
2
1
2
1
1
2
1
1
1
1
1
2
1
1
1...

output:

8
0 1153
8
0 95
8
0 1504
8
0 1000
8
0 1478
8
0 387
8
0 1089
8
0 926
8
0 731
8
0 1459
8
0 1462
8
0 442
8
0 1640
8
0 1560
8
0 884
8
0 1906
8
0 1389
8
0 807
8
0 1117
8
0 194
8
0 703
8
0 111
8
0 1576
8
0 654
8
0 1132
8
0 1387
8
0 1014
8
0 424
8
0 695
8
0 14
8
0 1407
8
0 354
8
0 994
8
0 569
8
0 1766
8
0 ...

result:

points 0.56013333330 points  0.56013333330

Test #58:

score: 36.55
Acceptable Answer
time: 21ms
memory: 3968kb

input:

1997
217
1
1
1
1
1
1
2
2
1
1
1
2
1
1
1
1
1
1
2
2
1
1
1
1
1
1
2
1
2
2
2
2
1
1
1
2
1
1
2
2
2
1
2
2
1
1
1
2
1
2
2
1
2
1
1
1
1
2
1
1
1
2
2
1
1
1
1
1
1
1
1
2
1
2
2
2
1
1
1
1
2
2
2
2
1
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
2
2
1
2
2
2
1
1
1
1...

output:

8
0 85
8
0 1329
8
0 1555
8
0 87
8
0 484
8
0 768
8
0 805
8
0 1255
8
0 782
8
0 1642
8
0 1501
8
0 1849
8
0 591
8
0 773
8
0 291
8
0 299
8
0 1057
8
0 489
8
0 1780
8
0 1390
8
0 1252
8
0 1772
8
0 1363
8
0 687
8
0 1570
8
0 1340
8
0 175
8
0 353
8
0 945
8
0 42
8
0 1749
8
0 1921
8
0 688
8
0 1212
8
0 371
8
0 90...

result:

points 0.48733333330 points  0.48733333330

Test #59:

score: 32.8
Acceptable Answer
time: 23ms
memory: 3968kb

input:

1998
193
1
1
2
1
1
1
1
1
2
2
1
1
2
2
2
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
2
2
1
1
2
2
2
2
1
1
2
1
1
2
2
2
1
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
1
1
2
2
2
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 360
8
0 1230
8
0 6
8
0 697
8
0 1695
8
0 1049
8
0 401
8
0 302
8
0 1653
8
0 526
8
0 339
8
0 1011
8
0 72
8
0 1502
8
0 1661
8
0 1494
8
0 116
8
0 534
8
0 54
8
0 1570
8
0 473
8
0 186
8
0 1032
8
0 643
8
0 1724
8
0 250
8
0 1793
8
0 1637
8
0 1728
8
0 1307
8
0 617
8
0 1124
8
0 693
8
0 790
8
0 1868
8
0 931...

result:

points 0.43733333330 points  0.43733333330

Test #60:

score: 28.59
Acceptable Answer
time: 17ms
memory: 4252kb

input:

1996
147
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
1
1
1
1
2
1
2
1
1
1
2
2
2
1
1
2
1
1
1
1
2
1
1
1
2
2
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
1
1
1
2
2
2
2
2
2
2
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
1
1
1
1...

output:

8
0 1881
8
0 491
8
0 1037
8
0 467
8
0 1526
8
0 517
8
0 497
8
0 1211
8
0 1251
8
0 701
8
0 1821
8
0 1474
8
0 322
8
0 684
8
0 404
8
0 627
8
0 195
8
0 1877
8
0 1719
8
0 1196
8
0 1275
8
0 1383
8
0 979
8
0 1534
8
0 1076
8
0 649
8
0 785
8
0 1608
8
0 1691
8
0 1927
8
0 1554
8
0 1259
8
0 165
8
0 374
8
0 689
8...

result:

points 0.38120 points  0.38120

Test #61:

score: 23.61
Acceptable Answer
time: 42ms
memory: 4004kb

input:

2000
125
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
1
2
2
2
2
2
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
2
2
2
2
2
2
1
1
1
2
1
1
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
1
1
2
2
1
1
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
1...

output:

8
0 1905
8
0 526
8
0 1495
8
0 346
8
0 540
8
0 1915
8
0 289
8
0 534
8
0 370
8
0 1187
8
0 1328
8
0 1586
8
0 572
8
0 903
8
0 329
8
0 1664
8
0 714
8
0 173
8
0 794
8
0 1508
8
0 1481
8
0 79
8
0 1703
8
0 535
8
0 1834
8
0 834
8
0 803
8
0 1843
8
0 187
8
0 1574
8
0 1014
8
0 1462
8
0 1054
8
0 1762
8
0 254
8
0 ...

result:

points 0.31480 points  0.31480

Test #62:

score: 0
Wrong Answer
time: 81ms
memory: 4216kb

input:

1998
55
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 1209
8
0 873
8
0 72
8
0 1628
8
0 491
8
0 482
8
0 1214
8
0 1888
8
0 234
8
0 785
8
0 758
8
0 949
8
0 53
8
0 1895
8
0 1555
8
0 500
8
0 1592
8
0 551
8
0 678
8
0 1928
8
0 34
8
0 984
8
0 1102
8
0 1171
8
0 277
8
0 874
8
0 89
8
0 1636
8
0 940
8
0 70
8
0 1177
8
0 368
8
0 1759
8
0 480
8
0 1221
8
0 1229
8
...

result:

wrong answer Too many queries.