QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#143069#4565. Rarest Insectsbashkort#10 17ms4156kbC++175.1kb2023-08-20 15:06:272024-07-04 01:50:21

Judging History

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

  • [2024-07-04 01:50:21]
  • 评测
  • 测评结果:10
  • 用时:17ms
  • 内存:4156kb
  • [2023-08-20 15:06:27]
  • 提交

answer

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

using namespace std;
using ll = long long;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int min_cardinality(int N) {
    vector<int> a(N);
    iota(a.begin(), a.end(), 0);
    shuffle(a.begin(), a.end(), rnd);
    
    vector<int> leaders, inside(N);
    int maxSize = 0, T = 0, lastQueryT = 0;
    int queriesCnt[3]{};

    auto insert = [&](int x) -> void {
        if (inside[x]) {
            return;
        }
        move_inside(x);
        T += 1;
        queriesCnt[0] += 1;
        inside[x] = true;
    };

    auto erase = [&](int x) -> void {
        if (!inside[x]) {
            return;
        }
        move_outside(x);
        T += 1;
        queriesCnt[1] += 1;
        inside[x] = false;
    };

    auto query = [&]() -> int {
        if (T == lastQueryT) {
            return maxSize;
        }
        lastQueryT = T;
        queriesCnt[2] += 1;
        return maxSize = press_button();
    };

    vector<int> others, lo(N, -1), hi(N, -1);

    for (int x : a) {
        insert(x);
        if (query() == 1) {
            leaders.push_back(x);
        } else {
            others.push_back(x);
            lo[x] = -1, hi[x] = size(leaders) - 1;
            erase(x);
        }
    };

    int ans = N;

    int minPos = 0, maxPos = size(leaders), full = true;
    int m = size(leaders);
    vector<vector<int>> queries(m);
    vector<int> siz(m);

    while (true) {
        for (int i = 0; i < m; ++i) {
            queries[i].clear();
        }
        minPos = N, maxPos = 0;
        for (int i = 0; i < N; ++i) {
            if (lo[i] + 1 < hi[i]) {
                int mid = lo[i] + hi[i] >> 1;
                minPos = min(minPos, mid), maxPos = max(maxPos, mid);
                queries[lo[i] + hi[i] >> 1].push_back(i);
            }
        }
        if (minPos > maxPos) {
            break;
        }
        if (full) {
            for (int i = m - 1; i > maxPos; --i) {
                erase(leaders[i]);
            }
            for (int i = 0; i <= maxPos; ++i) {
                insert(leaders[i]);
            }
            for (int i = maxPos; i >= minPos; --i) {
                for (int x : queries[i]) {
                    insert(x);
                    if (query() == 2) {
                        hi[x] = i;
                        if (lo[x] + 1 < hi[x]) {
                            int mid = lo[x] + hi[x] >> 1;
                            if (mid >= minPos) {
                                queries[mid].push_back(x);
                            }
                        }
                    } else {
                        lo[x] = i;
                    }
                    erase(x);
                }
                if (i > minPos) {
                    erase(leaders[i]);
                }
            }
            full = false;
        } else {
            for (int i = m - 1; i > minPos; --i) {
                erase(leaders[i]);
            }
            for (int i = 0; i < minPos; ++i) {
                insert(leaders[i]);
            }
            for (int i = minPos; i <= maxPos; ++i) {
                insert(leaders[i]);
                for (int x : queries[i]) {
                    insert(x);
                    if (query() == 2) {
                        hi[x] = i;
                    } else {
                        lo[x] = i;
                        if (lo[x] + 1 < hi[x]) {
                            int mid = lo[x] + hi[x] >> 1;
                            if (mid <= maxPos) {
                                queries[mid].push_back(x);
                            }
                        }
                    }
                    erase(x);
                }
            }
            full = true;
        }
    }

    for (int i = 0; i < N; ++i) {
        if (hi[i] != -1) {
            siz[hi[i]] += 1;
        }
    }

    for (int i = 0; i < m; ++i) {
        ans = min(ans, 1 + siz[i]);
    }

    auto dfs = [&](auto dfs, vector<int> lead, vector<int> oth, int isFull) -> void {
        if (ans == 1) {
            return;
        }
        if (size(lead) == 1) {
            ans = min<int>(ans, 1 + size(oth));
            return;
        }
        if (size(lead) > size(oth)) {
            ans = 1;
            return;
        }
        int mid = size(lead) / 2;
        vector<int> leadLeft(lead.begin(), lead.begin() + mid);
        vector<int> leadRight(lead.begin() + mid, lead.end());
        vector<int> nxt[2];
        if (isFull) {
            for (int x : leadRight) {
                erase(x);
            }
        } else {
            for (int x : leadLeft) {
                insert(x);
            }
        }
        for (int x : oth) {
            insert(x);
            if (query() == 1) {
                nxt[1].push_back(x);
            } else {
                nxt[0].push_back(x);
            }
            erase(x);
        }
        dfs(dfs, leadLeft, nxt[0], true);
        dfs(dfs, leadRight, nxt[1], false);
    };

    // dfs(dfs, leaders, others, true);

    return ans;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

6
1
1
2
2
1
2
1
2
1
2

output:

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

result:

ok 

Test #2:

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

input:

2
1
2

output:

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

result:

ok 

Test #3:

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

input:

2
1
1

output:

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

result:

ok 

Test #4:

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

input:

3
1
2
1

output:

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

result:

ok 

Test #5:

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

input:

5
1
2
1
2
2
1
2

output:

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

result:

ok 

Test #6:

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

input:

8
1
1
1
2
2
2
2
2
2
1
1
1
1
1
1
1
1

output:

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

result:

ok 

Test #7:

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

input:

199
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
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 99
8
2
8
0 147
8
2
8
1 147
8
0 175
8
2
8
1 175
8
0 79
8
2
8
1 79
8
0 191
8
2
8
1 191
8
0 27
8
2
8
1 27
8
0 182
8
2
8
1 182
8
0 29
8
2
8
1 29
8
0 187
8
2
8
1 187
8
0 87
8
2
8
1 87
8
0 12
8
2
8
1 12
8
0 32
8
2
8
1 32
8
0 46
8
2
8
1 46
8
0 155
8
2
8
1 155
8
0 105
8
2
8
1 105
8
0 139
8
2
8
1 139
8
0...

result:

ok 

Test #8:

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

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 82
8
2
8
0 183
8
2
8
0 173
8
2
8
0 22
8
2
8
0 171
8
2
8
0 10
8
2
8
0 122
8
2
8
0 104
8
2
8
0 84
8
2
8
0 187
8
2
8
0 70
8
2
8
0 166
8
2
8
0 142
8
2
8
0 66
8
2
8
0 56
8
2
8
0 190
8
2
8
0 53
8
2
8
0 29
8
2
8
0 128
8
2
8
0 74
8
2
8
0 143
8
2
8
0 108
8
2
8
0 156
8
2
8
0 76
8
2
8
0 44
8
2
8
0 134
8
2
...

result:

ok 

Test #9:

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

input:

200
1
2
1
1
1
2
1
2
1
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
1
2
2
1
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 68
8
2
8
0 63
8
2
8
1 63
8
0 147
8
2
8
0 198
8
2
8
0 91
8
2
8
0 31
8
2
8
1 31
8
0 127
8
2
8
0 55
8
2
8
1 55
8
0 84
8
2
8
0 109
8
2
8
1 109
8
0 88
8
2
8
0 75
8
2
8
1 75
8
0 61
8
2
8
0 162
8
2
8
1 162
8
0 129
8
2
8
1 129
8
0 25
8
2
8
1 25
8
0 62
8
2
8
1 62
8
0 188
8
2
8
1 188
8
0 57
8
2
8
1 57
8
0...

result:

ok 

Test #10:

score: 0
Accepted
time: 5ms
memory: 3812kb

input:

198
1
1
1
1
2
1
1
1
1
1
2
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
1
2
2
2
2
2
2
2
2
2
2
2
2
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
...

output:

8
0 181
8
2
8
0 128
8
2
8
0 143
8
2
8
0 49
8
2
8
0 78
8
2
8
1 78
8
0 180
8
2
8
0 155
8
2
8
0 193
8
2
8
0 92
8
2
8
0 18
8
2
8
0 44
8
2
8
1 44
8
0 183
8
2
8
1 183
8
0 178
8
2
8
1 178
8
0 60
8
2
8
0 104
8
2
8
1 104
8
0 52
8
2
8
1 52
8
0 67
8
2
8
1 67
8
0 175
8
2
8
0 160
8
2
8
1 160
8
0 30
8
2
8
1 30
8
...

result:

ok 

Test #11:

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

input:

199
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
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 146
8
2
8
0 183
8
2
8
1 183
8
0 89
8
2
8
1 89
8
0 37
8
2
8
1 37
8
0 197
8
2
8
1 197
8
0 162
8
2
8
1 162
8
0 44
8
2
8
1 44
8
0 178
8
2
8
1 178
8
0 117
8
2
8
1 117
8
0 90
8
2
8
1 90
8
0 30
8
2
8
1 30
8
0 168
8
2
8
1 168
8
0 185
8
2
8
1 185
8
0 147
8
2
8
1 147
8
0 9
8
2
8
1 9
8
0 10
8
2
8
1 10
8
0 ...

result:

ok 

Test #12:

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

input:

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

output:

8
0 106
8
2
8
0 118
8
2
8
0 49
8
2
8
0 189
8
2
8
0 108
8
2
8
0 48
8
2
8
1 48
8
0 125
8
2
8
0 105
8
2
8
0 40
8
2
8
0 152
8
2
8
1 152
8
0 124
8
2
8
1 124
8
0 145
8
2
8
1 145
8
0 93
8
2
8
0 150
8
2
8
0 160
8
2
8
0 109
8
2
8
0 75
8
2
8
0 177
8
2
8
1 177
8
0 167
8
2
8
1 167
8
0 103
8
2
8
0 164
8
2
8
0 32...

result:

ok 

Test #13:

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

input:

197
1
1
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 141
8
2
8
0 12
8
2
8
0 174
8
2
8
1 174
8
0 72
8
2
8
1 72
8
0 151
8
2
8
0 182
8
2
8
1 182
8
0 20
8
2
8
1 20
8
0 47
8
2
8
1 47
8
0 153
8
2
8
1 153
8
0 118
8
2
8
1 118
8
0 149
8
2
8
1 149
8
0 125
8
2
8
0 93
8
2
8
1 93
8
0 17
8
2
8
1 17
8
0 110
8
2
8
0 191
8
2
8
1 191
8
0 136
8
2
8
1 136
8
0 92
8
2
...

result:

ok 

Test #14:

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

input:

198
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
2
2
1
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
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 2
8
2
8
0 72
8
2
8
0 134
8
2
8
0 122
8
2
8
0 119
8
2
8
0 179
8
2
8
0 185
8
2
8
0 176
8
2
8
0 144
8
2
8
0 113
8
2
8
0 131
8
2
8
1 131
8
0 26
8
2
8
1 26
8
0 33
8
2
8
1 33
8
0 43
8
2
8
1 43
8
0 190
8
2
8
1 190
8
0 49
8
2
8
1 49
8
0 117
8
2
8
1 117
8
0 110
8
2
8
1 110
8
0 102
8
2
8
1 102
8
0 66
8
2
...

result:

ok 

Test #15:

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

input:

200
1
1
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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
2
8
0 0
8
2
8
0 97
8
2
8
1 97
8
0 111
8
2
8
1 111
8
0 177
8
2
8
0 99
8
2
8
0 73
8
2
8
1 73
8
0 86
8
2
8
0 15
8
2
8
1 15
8
0 119
8
2
8
1 119
8
0 186
8
2
8
1 186
8
0 85
8
2
8
1 85
8
0 184
8
2
8
1 184
8
0 56
8
2
8
1 56
8
0 41
8
2
8
1 41
8
0 125
8
2
8
1 125
8
0 142
8
2
8
1 142
8
0 156
8
2
8
1 ...

result:

ok 

Test #16:

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

input:

196
1
1
1
1
2
2
2
1
2
2
1
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
2
2
...

output:

8
0 58
8
2
8
0 171
8
2
8
0 19
8
2
8
0 193
8
2
8
0 130
8
2
8
1 130
8
0 14
8
2
8
1 14
8
0 88
8
2
8
1 88
8
0 15
8
2
8
0 162
8
2
8
1 162
8
0 7
8
2
8
1 7
8
0 150
8
2
8
0 100
8
2
8
0 86
8
2
8
1 86
8
0 27
8
2
8
1 27
8
0 6
8
2
8
1 6
8
0 24
8
2
8
1 24
8
0 132
8
2
8
1 132
8
0 9
8
2
8
1 9
8
0 39
8
2
8
1 39
8
0...

result:

ok 

Test #17:

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

input:

199
1
1
1
1
1
2
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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
2
2
2
2
2
2
...

output:

8
0 33
8
2
8
0 158
8
2
8
0 166
8
2
8
0 76
8
2
8
0 41
8
2
8
0 38
8
2
8
1 38
8
0 196
8
2
8
0 45
8
2
8
0 78
8
2
8
0 95
8
2
8
1 95
8
0 140
8
2
8
1 140
8
0 79
8
2
8
1 79
8
0 159
8
2
8
1 159
8
0 124
8
2
8
1 124
8
0 96
8
2
8
1 96
8
0 114
8
2
8
1 114
8
0 29
8
2
8
1 29
8
0 160
8
2
8
1 160
8
0 109
8
2
8
1 109...

result:

ok 

Test #18:

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

input:

196
1
1
1
2
1
1
1
2
2
2
1
1
1
1
2
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 69
8
2
8
0 99
8
2
8
0 26
8
2
8
0 124
8
2
8
1 124
8
0 140
8
2
8
0 139
8
2
8
0 164
8
2
8
0 101
8
2
8
1 101
8
0 147
8
2
8
1 147
8
0 44
8
2
8
1 44
8
0 21
8
2
8
0 158
8
2
8
0 119
8
2
8
0 110
8
2
8
0 193
8
2
8
1 193
8
0 190
8
2
8
1 190
8
0 123
8
2
8
1 123
8
0 176
8
2
8
0 85
8
2
8
1 85
8
0 100
8
2
8
1 ...

result:

ok 

Test #19:

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

input:

196
1
1
1
2
2
1
1
2
1
1
2
1
1
1
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
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
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
...

output:

8
0 153
8
2
8
0 20
8
2
8
0 176
8
2
8
0 46
8
2
8
1 46
8
0 155
8
2
8
1 155
8
0 94
8
2
8
0 53
8
2
8
0 100
8
2
8
1 100
8
0 65
8
2
8
0 50
8
2
8
0 103
8
2
8
1 103
8
0 78
8
2
8
0 158
8
2
8
0 185
8
2
8
0 60
8
2
8
1 60
8
0 148
8
2
8
1 148
8
0 181
8
2
8
1 181
8
0 14
8
2
8
1 14
8
0 129
8
2
8
1 129
8
0 16
8
2
8...

result:

ok 

Test #20:

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

input:

196
1
1
1
1
1
2
1
1
1
2
1
2
1
2
1
1
2
2
2
2
2
2
1
2
2
1
2
2
1
2
2
1
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
1
2
1
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
...

output:

8
0 16
8
2
8
0 44
8
2
8
0 96
8
2
8
0 134
8
2
8
0 120
8
2
8
0 53
8
2
8
1 53
8
0 160
8
2
8
0 56
8
2
8
0 116
8
2
8
0 8
8
2
8
1 8
8
0 166
8
2
8
0 73
8
2
8
1 73
8
0 177
8
2
8
0 52
8
2
8
1 52
8
0 30
8
2
8
0 101
8
2
8
0 90
8
2
8
1 90
8
0 133
8
2
8
1 133
8
0 155
8
2
8
1 155
8
0 45
8
2
8
1 45
8
0 176
8
2
8
1...

result:

ok 

Test #21:

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

input:

200
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
2
2
1
2
1
1
1
1
1
2
1
2
1
1
1
2
1
2
1
2
1
2
2
1
1
1
2
1
2
2
1
2
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
1
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
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
...

output:

8
0 28
8
2
8
0 152
8
2
8
0 136
8
2
8
0 78
8
2
8
0 100
8
2
8
0 89
8
2
8
0 111
8
2
8
1 111
8
0 187
8
2
8
0 177
8
2
8
0 167
8
2
8
0 198
8
2
8
0 87
8
2
8
0 67
8
2
8
0 13
8
2
8
0 82
8
2
8
0 40
8
2
8
0 195
8
2
8
0 75
8
2
8
0 34
8
2
8
1 34
8
0 194
8
2
8
1 194
8
0 86
8
2
8
1 86
8
0 199
8
2
8
0 76
8
2
8
1 76...

result:

ok 

Test #22:

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

input:

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

output:

8
0 112
8
2
8
0 32
8
2
8
0 13
8
2
8
0 115
8
2
8
0 60
8
2
8
0 136
8
2
8
0 37
8
2
8
0 12
8
2
8
0 79
8
2
8
0 110
8
2
8
0 186
8
2
8
0 104
8
2
8
0 184
8
2
8
1 184
8
0 173
8
2
8
0 197
8
2
8
0 113
8
2
8
0 5
8
2
8
0 99
8
2
8
0 47
8
2
8
1 47
8
0 1
8
2
8
0 52
8
2
8
0 194
8
2
8
0 10
8
2
8
0 19
8
2
8
1 19
8
0 3...

result:

ok 

Test #23:

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

input:

198
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
2
2
1
1
2
1
1
2
1
1
1
1
1
2
1
2
1
2
1
1
1
1
2
2
1
1
1
2
1
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
2
2
1
2
1
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
2
2
1
2
2
1
1
1
1
1
2
1
1
2
2
1
1
2
1
1
2
2
1
2
1
1
2
2
2
1
1
2
2
2
1
2
2
2
1
1
1
2
...

output:

8
0 59
8
2
8
0 181
8
2
8
0 171
8
2
8
0 55
8
2
8
0 45
8
2
8
0 105
8
2
8
0 61
8
2
8
0 40
8
2
8
0 1
8
2
8
0 114
8
2
8
0 63
8
2
8
1 63
8
0 191
8
2
8
0 113
8
2
8
0 117
8
2
8
0 156
8
2
8
0 34
8
2
8
0 154
8
2
8
0 145
8
2
8
0 19
8
2
8
0 16
8
2
8
0 3
8
2
8
0 161
8
2
8
0 35
8
2
8
0 76
8
2
8
0 81
8
2
8
0 107
8...

result:

ok 

Subtask #2:

score: 0
Interactor Judgement Failed

Test #24:

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

input:

1000
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
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 309
8
2
8
0 312
8
2
8
1 312
8
0 78
8
2
8
1 78
8
0 335
8
2
8
1 335
8
0 946
8
2
8
1 946
8
0 959
8
2
8
1 959
8
0 548
8
2
8
1 548
8
0 690
8
2
8
1 690
8
0 620
8
2
8
1 620
8
0 930
8
2
8
1 930
8
0 208
8
2
8
1 208
8
0 218
8
2
8
1 218
8
0 241
8
2
8
1 241
8
0 913
8
2
8
1 913
8
0 503
8
2
8
1 503
8
0 771
8
...

result:

ok 

Test #25:

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

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 601
8
2
8
0 199
8
2
8
0 569
8
2
8
0 147
8
2
8
0 589
8
2
8
0 344
8
2
8
0 479
8
2
8
0 844
8
2
8
0 84
8
2
8
0 701
8
2
8
0 382
8
2
8
0 277
8
2
8
0 913
8
2
8
0 324
8
2
8
0 432
8
2
8
0 814
8
2
8
0 208
8
2
8
0 152
8
2
8
0 743
8
2
8
0 754
8
2
8
0 770
8
2
8
0 898
8
2
8
0 116
8
2
8
0 548
8
2
8
0 708
8
2
8...

result:

ok 

Test #26:

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

input:

999
1
1
1
1
1
1
1
2
1
2
1
2
2
1
1
1
1
2
2
1
1
1
2
1
2
1
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
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
...

output:

8
0 62
8
2
8
0 722
8
2
8
0 572
8
2
8
0 661
8
2
8
0 266
8
2
8
0 2
8
2
8
0 221
8
2
8
0 865
8
2
8
1 865
8
0 759
8
2
8
0 619
8
2
8
1 619
8
0 289
8
2
8
0 267
8
2
8
1 267
8
0 892
8
2
8
1 892
8
0 302
8
2
8
0 715
8
2
8
0 93
8
2
8
0 97
8
2
8
0 50
8
2
8
1 50
8
0 513
8
2
8
1 513
8
0 564
8
2
8
0 912
8
2
8
0 797...

result:

ok 

Test #27:

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

input:

999
1
1
1
1
2
2
1
1
1
2
2
1
1
1
1
1
1
2
2
2
2
2
1
1
1
2
2
1
2
1
1
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
1
2
1
2
1
2
2
1
2
1
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
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
1
2
2
2
...

output:

8
0 617
8
2
8
0 668
8
2
8
0 436
8
2
8
0 331
8
2
8
0 321
8
2
8
1 321
8
0 987
8
2
8
1 987
8
0 647
8
2
8
0 860
8
2
8
0 648
8
2
8
0 908
8
2
8
1 908
8
0 274
8
2
8
1 274
8
0 216
8
2
8
0 30
8
2
8
0 731
8
2
8
0 92
8
2
8
0 257
8
2
8
0 743
8
2
8
0 796
8
2
8
1 796
8
0 244
8
2
8
1 244
8
0 31
8
2
8
1 31
8
0 994
...

result:

ok 

Test #28:

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

input:

996
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
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 558
8
2
8
0 823
8
2
8
1 823
8
0 257
8
2
8
1 257
8
0 695
8
2
8
1 695
8
0 621
8
2
8
1 621
8
0 893
8
2
8
1 893
8
0 106
8
2
8
1 106
8
0 565
8
2
8
1 565
8
0 508
8
2
8
1 508
8
0 860
8
2
8
1 860
8
0 362
8
2
8
1 362
8
0 685
8
2
8
1 685
8
0 503
8
2
8
1 503
8
0 290
8
2
8
1 290
8
0 746
8
2
8
1 746
8
0 70
8...

result:

ok 

Test #29:

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

input:

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

output:

8
0 699
8
2
8
0 350
8
2
8
0 659
8
2
8
0 535
8
2
8
0 40
8
2
8
0 72
8
2
8
0 784
8
2
8
0 723
8
2
8
0 921
8
2
8
0 813
8
2
8
0 143
8
2
8
1 143
8
0 493
8
2
8
0 791
8
2
8
0 757
8
2
8
0 327
8
2
8
1 327
8
0 888
8
2
8
1 888
8
0 91
8
2
8
0 541
8
2
8
0 129
8
2
8
0 255
8
2
8
1 255
8
0 812
8
2
8
0 16
8
2
8
1 16
8...

result:

ok 

Test #30:

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

input:

998
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 478
8
2
8
0 886
8
2
8
0 687
8
2
8
0 946
8
2
8
1 946
8
0 798
8
2
8
1 798
8
0 575
8
2
8
0 356
8
2
8
1 356
8
0 820
8
2
8
1 820
8
0 975
8
2
8
1 975
8
0 403
8
2
8
1 403
8
0 320
8
2
8
1 320
8
0 931
8
2
8
1 931
8
0 405
8
2
8
1 405
8
0 639
8
2
8
1 639
8
0 882
8
2
8
1 882
8
0 481
8
2
8
1 481
8
0 462
8
2
...

result:

ok 

Test #31:

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

input:

998
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
2
1
2
1
2
2
1
2
2
1
2
2
2
2
2
1
1
2
2
2
1
2
1
2
1
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
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
1
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
...

output:

8
0 41
8
2
8
0 281
8
2
8
0 842
8
2
8
0 800
8
2
8
0 0
8
2
8
0 276
8
2
8
0 626
8
2
8
0 75
8
2
8
0 218
8
2
8
0 666
8
2
8
0 61
8
2
8
0 986
8
2
8
1 986
8
0 298
8
2
8
0 67
8
2
8
0 900
8
2
8
1 900
8
0 752
8
2
8
0 721
8
2
8
1 721
8
0 477
8
2
8
1 477
8
0 249
8
2
8
0 487
8
2
8
1 487
8
0 708
8
2
8
0 974
8
2
8
...

result:

ok 

Test #32:

score: 0
Accepted
time: 5ms
memory: 3920kb

input:

1000
1
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 112
8
2
8
0 895
8
2
8
0 72
8
2
8
0 460
8
2
8
1 460
8
0 615
8
2
8
1 615
8
0 918
8
2
8
1 918
8
0 612
8
2
8
1 612
8
0 213
8
2
8
1 213
8
0 179
8
2
8
0 209
8
2
8
1 209
8
0 646
8
2
8
1 646
8
0 834
8
2
8
1 834
8
0 305
8
2
8
1 305
8
0 972
8
2
8
1 972
8
0 479
8
2
8
1 479
8
0 466
8
2
8
1 466
8
0 491
8
2
8...

result:

ok 

Test #33:

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

input:

996
1
1
2
1
2
1
1
2
1
2
2
2
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 217
8
2
8
0 526
8
2
8
0 789
8
2
8
1 789
8
0 819
8
2
8
0 264
8
2
8
1 264
8
0 12
8
2
8
0 34
8
2
8
0 242
8
2
8
1 242
8
0 53
8
2
8
0 726
8
2
8
1 726
8
0 318
8
2
8
1 318
8
0 763
8
2
8
1 763
8
0 901
8
2
8
0 243
8
2
8
0 247
8
2
8
1 247
8
0 785
8
2
8
1 785
8
0 87
8
2
8
1 87
8
0 698
8
2
8
1 698
8
0 168
8...

result:

ok 

Test #34:

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

input:

1000
1
1
1
1
1
2
2
2
1
2
2
2
1
2
2
2
1
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
2
2...

output:

8
0 919
8
2
8
0 729
8
2
8
0 932
8
2
8
0 848
8
2
8
0 313
8
2
8
0 66
8
2
8
1 66
8
0 531
8
2
8
1 531
8
0 500
8
2
8
1 500
8
0 837
8
2
8
0 175
8
2
8
1 175
8
0 367
8
2
8
1 367
8
0 976
8
2
8
1 976
8
0 832
8
2
8
0 725
8
2
8
1 725
8
0 967
8
2
8
1 967
8
0 865
8
2
8
1 865
8
0 545
8
2
8
0 538
8
2
8
1 538
8
0 85...

result:

ok 

Test #35:

score: 0
Accepted
time: 5ms
memory: 3824kb

input:

1000
1
1
1
2
1
1
1
1
1
2
1
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 654
8
2
8
0 417
8
2
8
0 795
8
2
8
0 261
8
2
8
1 261
8
0 256
8
2
8
0 695
8
2
8
0 611
8
2
8
0 660
8
2
8
0 188
8
2
8
0 548
8
2
8
1 548
8
0 741
8
2
8
0 108
8
2
8
0 385
8
2
8
0 0
8
2
8
1 0
8
0 829
8
2
8
0 78
8
2
8
1 78
8
0 761
8
2
8
1 761
8
0 786
8
2
8
1 786
8
0 35
8
2
8
1 35
8
0 623
8
2
8
1 623
8
0 ...

result:

ok 

Test #36:

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

input:

997
1
1
1
2
2
1
2
1
1
2
1
2
1
1
1
1
2
2
2
2
2
1
2
1
2
2
2
2
2
1
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
...

output:

8
0 104
8
2
8
0 274
8
2
8
0 903
8
2
8
0 11
8
2
8
1 11
8
0 245
8
2
8
1 245
8
0 670
8
2
8
0 549
8
2
8
1 549
8
0 91
8
2
8
0 215
8
2
8
0 0
8
2
8
1 0
8
0 302
8
2
8
0 80
8
2
8
1 80
8
0 642
8
2
8
0 394
8
2
8
0 981
8
2
8
0 73
8
2
8
0 389
8
2
8
1 389
8
0 832
8
2
8
1 832
8
0 689
8
2
8
1 689
8
0 223
8
2
8
1 22...

result:

ok 

Test #37:

score: 0
Accepted
time: 17ms
memory: 4112kb

input:

995
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
2
2
1
2
1
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
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
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
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 685
8
2
8
0 102
8
2
8
0 720
8
2
8
0 928
8
2
8
0 7
8
2
8
0 918
8
2
8
0 483
8
2
8
0 131
8
2
8
0 906
8
2
8
0 274
8
2
8
0 978
8
2
8
0 619
8
2
8
0 513
8
2
8
1 513
8
0 138
8
2
8
0 316
8
2
8
1 316
8
0 431
8
2
8
1 431
8
0 512
8
2
8
1 512
8
0 239
8
2
8
1 239
8
0 271
8
2
8
0 818
8
2
8
1 818
8
0 232
8
2
8
...

result:

ok 

Test #38:

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

input:


output:


result:

ok 

Test #39:

score: -15
Interactor Judgement Failed

input:


output:


result:


Subtask #3:

score: 0
Interactor Judgement Failed

Test #43:

score: 0
Interactor Judgement Failed

input:


output:


result: