QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#271223#7119. Longest TripLeticiaFCS15 10ms4524kbC++204.5kb2023-12-02 07:18:062024-04-28 09:10:28

Judging History

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

  • [2024-04-28 09:10:28]
  • 管理员手动重测本题所有提交记录
  • 测评结果:15
  • 用时:10ms
  • 内存:4524kb
  • [2023-12-02 07:18:07]
  • 评测
  • 测评结果:15
  • 用时:11ms
  • 内存:4176kb
  • [2023-12-02 07:18:06]
  • 提交

answer

#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;



vector<vector<int>> memo;

int point_query(int a, int b){
    if(memo[a][b] != -1) return memo[a][b];
    for(int c = 0; c < memo.size(); c++){
        if(a == c) continue;
        if(b == c) continue;
        if(memo[a][c] == 0 && memo[b][c] == 0)
            return memo[a][b] = memo[b][a] = 1;
    }
    return memo[a][b] = memo[b][a] = are_connected({a}, {b});
}


bool merge_paths(vector<int> p1, vector<int> p2, vector<int> &path){
    if(p1.size() < p2.size()) swap(p1, p2);
    int a = p1[0], b = p1.back();
    int c = p2[0], d = p2.back();
    vector<int> ends_p1, ends_p2;
    if(a == b) ends_p1 = {a};
    else ends_p1 = {a,b};
    if(c == d) ends_p2 = {c};
    else ends_p2 = {c,d};
    if(!are_connected(ends_p1, ends_p2)) return false;
    if(point_query(a, d)){
        path = p2;
        path.insert(path.end(), p1.begin(), p1.end());
        return true;
    }
    if(point_query(b, d)){
        path = p1;
        path.insert(path.end(), p2.rbegin(), p2.rend());
        return true;
    }
    reverse(p2.begin(), p2.end());

    d = p2.back();
    if(point_query(a, d)){
        path = p2;
        path.insert(path.end(), p1.begin(), p1.end());
        return true;
    }
    return false;
}
bool merge_cycles(vector<int> c1, vector<int> c2, vector<int> &path){
    using pii = pair<int, int>;
    int a, b;
    {
        vector<int> x = c1, y = c2;
        while(x.size() != 1 || y.size() != 1){
            if(x.size() > y.size()) swap(x, y);
            if(x.size() == 1){
                int mid = y.size() / 2;
                vector<int> ly(y.begin(), y.begin() + mid);
                vector<int> ry(y.begin() + mid, y.end());
                if(are_connected(x, ly)) y = ly;
                else y = ry;
                continue;
            }  
            int mid1 = y.size() / 2;
            vector<int> ly(y.begin(), y.begin() + mid1);
            int mid2 = x.size() / 2;
            vector<int> lx(x.begin(), x.begin() + mid2);
            if(are_connected(lx, ly)){ tie(x, y) = {lx, ly}; continue;}
            vector<int> ry(y.begin() + mid1, y.end());
            if(are_connected(lx, ry)){ tie(x, y) = {lx, ry}; continue;}
            lx.clear();
            ry.clear();
            vector<int> rx(x.begin() + mid2, x.end());
            if(are_connected(rx, ly)){ tie(x, y) = {rx, ly}; continue;}
            tie(x, y) = {rx, ry};
        }
    }
    int n = c1.size(), m = c2.size();
    int x, y;
    tie(x, y) = {a,b};
    for(a = 0; a<n; a++) if(c1[a] == x) break;
    for(b = 0; b<m; b++) if(c2[b] == y) break;

    for(int i = (a + 1) % n; i != a; i = (i+1)%n) path.push_back(c1[i]);
    path.push_back(c1[a]);
    path.push_back(c2[b]);
    for(int i = (b + 1) % m; i != b; i = (i+1)%m) path.push_back(c2[i]);
    return true;
}

std::vector<int> longest_trip(int N, int D)
{
    if(D == 3){
        vector<int> ans(N);
        iota(ans.begin(), ans.end(), 0);
        return ans;
    }
    if(D == 2){
        deque<int> ans;
        int start = 3;
        if(are_connected({0}, {1}))
            ans = {0, 1}, start = 2; 
        else
            ans = {0, 2, 1};
        
        for(int v = start; v < N; v++){
            if(are_connected({ans.front()}, {v})) ans.push_front(v);
            else ans.push_back(v);
        }
        return {ans.begin(), ans.end()};
    }
    if(D == 1){ 
        memo = vector<vector<int>>(N, vector<int>(N, -1));
        vector<vector<int>> ans = {{0}, {1}};
        mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
        vector<int> vert(N-2); iota(vert.begin(), vert.end(), 2);
        shuffle(vert.begin(), vert.end(), rng);
        for(int v : vert){
            int a = ans[0].back();
            int b = ans[1].back();
            if(point_query(a, v)){
                ans[0].push_back(v);
            } else if(point_query(b, v))
                ans[1].push_back(v);
            else{
                ans[0].insert(ans[0].end(), ans[1].rbegin(), ans[1].rend());
                ans[1] = {v};
            }          
        }
        vector<int> path;
        if(!are_connected(ans[0], ans[1])){
            if(ans[0].size() > ans[1].size()) return ans[0];
                return ans[1];
        }
            
        if(merge_paths(ans[0], ans[1], path))
            return path;
        if(merge_cycles(ans[0], ans[1], path))
            return path;
        
    }
    return {};
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

341
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 3
1
3 ...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2...

result:

ok 

Test #2:

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

input:

103
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10 3
1
10...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 10 0 1 2 3 4 5 6 7 8 9
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 10 0 1 2 3 4 5 6 7 8 9
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 10 0 1 2 3 4 5 6 7 8 9
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 10 0 1 2 3 4 5 6 7 8 9
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 10 0 1 2 3 4 5 6 7 8 9
3kC2Ia2048...

result:

ok 

Test #3:

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

input:

22
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
50 3
1
12 3
1
12 3
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 50 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 50 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3...

result:

ok 

Test #4:

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

input:

8
128 3
1
128 3
1
128 3
1
128 3
1
128 3
1
128 3
1
128 3
1
128 3
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 128 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 9...

result:

ok 

Test #5:

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

input:

4
256 3
1
256 3
1
256 3
1
256 3
1

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 256 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 9...

result:

ok 

Subtask #2:

score: 10
Accepted

Test #6:

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

input:

341
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
1
1
3 2
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 2 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 2 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1...

result:

ok 

Test #7:

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

input:

103
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #8:

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

input:

22
50 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
1
1
1
1
1
1
1
50 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
1
1
1
1
1
1
1
50 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
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #9:

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

input:

8
128 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
128 2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #10:

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

input:

4
256 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #11:

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

input:

341
3 2
1
1
1
3 2
1
0
1
3 2
1
0
1
3 2
1
0
1
3 2
1
1
1
3 2
1
0
1
3 2
1
0
1
3 2
0
1
3 2
0
1
3 2
1
0
1
3 2
0
1
3 2
1
0
1
3 2
1
1
1
3 2
0
1
3 2
1
0
1
3 2
1
0
1
3 2
0
1
3 2
1
0
1
3 2
0
1
3 2
1
0
1
3 2
0
1
3 2
1
0
1
3 2
1
1
1
3 2
0
1
3 2
1
1
1
3 2
1
1
1
3 2
0
1
3 2
0
1
3 2
1
0
1
3 2
0
1
3 2
0
1
3 2
0
1
3 ...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 2 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1...

result:

ok 

Test #12:

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

input:

103
10 2
0
1
0
1
1
0
1
1
1
10 2
1
1
0
1
1
0
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
0
1
1
1
10 2
1
1
1
1
1
1
0
1
1
1
10 2
0
1
1
1
0
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
0
1
1
1
1
0
1
1
10 2
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 8...

result:

ok 

Test #13:

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

input:

22
50 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
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 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
1
1
1
1
1
1
1
50 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
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #14:

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

input:

11
101 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
101 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...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #15:

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

input:

4
256 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #16:

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

input:

4
256 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #17:

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

input:

4
256 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Test #18:

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

input:

4
256 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7...

result:

ok 

Subtask #3:

score: 0
Memory Limit Exceeded

Test #19:

score: 25
Accepted
time: 1ms
memory: 4116kb

input:

341
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 ...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1...

result:

ok 

Test #20:

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

input:

103
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1...

output:

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

result:

ok 

Test #21:

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

input:

22
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 20
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 20 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 22 24
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 24 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 31
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 31 42
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
...

result:

ok 

Test #22:

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

input:

8
128 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
128 1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 117
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 117 28
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 28 36
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 36 111
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 111 27
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 27 98
3kC2Ia2048BfyJVGojMUKKtilct...

result:

ok 

Test #23:

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

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 148
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 148 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 198
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 198 209
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 209 230
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 230 156
3kC2Ia2048BfyJVGojMUKKti...

result:

ok 

Test #24:

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

input:

341
3 1
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1...

result:

ok 

Test #25:

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

input:

103
10 1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
0
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
0
1
1
1
0
1
1
1
1
0
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
10 1
1
1
1
1
0
1
1
0
1
1
1
1
1
1
10 1
1
1
1
1
1
1
0
1
1
1
1
1
1
10 1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 9
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 9
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 2...

result:

ok 

Test #26:

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

input:

22
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
0
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 39
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 39 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 21
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 21 41
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 41 17
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
...

result:

ok 

Test #27:

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

input:

11
101 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
101 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 8
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 8 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 12
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 12 51
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 51 62
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 62 40
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 ...

result:

ok 

Test #28:

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

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 107
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 107 120
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 120 69
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 69 97
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 97 24
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 24 129
3kC2Ia2048BfyJVGojMUKKtilc...

result:

ok 

Test #29:

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

input:

4
256 1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 151
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 151 76
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 76 239
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 239 92
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 92 23
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 23
3kC2Ia2048BfyJVGojMUKKtilctl...

result:

ok 

Test #30:

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

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 32
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 32 244
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 244 112
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 112 217
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 217 52
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 52 188
3kC2Ia2048BfyJVGojMUKKti...

result:

ok 

Test #31:

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

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 247
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 247 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 180
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 180 137
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 137 215
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 215 175
3kC2Ia2048BfyJVGojMUKKti...

result:

ok 

Test #32:

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

input:

341
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
0
0
0
1
3 1
0
1
0
1
3 1
0
1
0
1
3 1
0
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
0
0
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 2 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 2 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2...

result:

ok 

Test #33:

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

input:

205
5 1
1
1
0
1
0
1
5 1
0
0
0
1
0
1
5 1
1
0
0
0
0
1
5 1
0
1
0
1
0
1
5 1
0
1
1
0
1
0
1
5 1
0
1
1
1
0
1
5 1
0
0
0
0
0
1
5 1
0
0
1
0
1
0
1
5 1
0
0
0
1
0
1
5 1
0
1
0
1
0
1
5 1
0
0
1
0
1
0
1
5 1
1
0
1
0
0
1
5 1
0
0
1
0
1
0
1
5 1
1
0
1
1
0
1
5 1
1
0
0
0
0
1
5 1
0
0
1
0
1
0
1
5 1
1
0
0
0
0
1
5 1
0
1
1
1
0
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 2 0 4 2 1 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 4 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1...

result:

ok 

Test #34:

score: -25
Memory Limit Exceeded

input:

64
16 1
0
1
1
1
1
0
1
1
0
1
1
1
0
0
1
0
1
1
1
1
1
1
1
16 1
0
1
1
0
1
0
1
0
1
1
1
0
0
1
0
1
0
1
0
1
1
1
1
1
16 1
1
1
1
0
1
1
1
0
1
1
1
1
0
0
1
1
0
1
1
1
1
1
16 1
0
1
1
1
1
1
0
0
0
1
0
1
1
0
1
1
1
0
1
1
1
1
1
16 1
1
0
0
0
1
0
0
1
0
1
1
0
1
1
1
0
1
1
0
1
1
1
0
1
1
16 1
1
1
1
0
1
0
0
1
0
1
1
1
0
0
1
1
1...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 7
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 7
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 13
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 13 14
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 14 12
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 12 15
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 ...

result:


Subtask #4:

score: 0
Memory Limit Exceeded

Test #83:

score: 60
Accepted
time: 10ms
memory: 3904kb

input:

341
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
1
1
3 ...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1...

result:

ok 

Test #84:

score: 60
Accepted
time: 6ms
memory: 3864kb

input:

103
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1...

output:

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

result:

ok 

Test #85:

score: 60
Accepted
time: 2ms
memory: 3920kb

input:

22
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 41
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 41 37
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 37 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 36
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 36 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0...

result:

ok 

Test #86:

score: 60
Accepted
time: 2ms
memory: 4032kb

input:

8
128 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
128 1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 20
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 20 118
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 118 13
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 13 98
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 98 85
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 85 113
3kC2Ia2048BfyJVGojMUKKtilctl...

result:

ok 

Test #87:

score: 60
Accepted
time: 0ms
memory: 4304kb

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 83
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 83 249
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 249 166
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 166 123
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 123 199
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 199 71
3kC2Ia2048BfyJVGojMUKKt...

result:

ok 

Test #88:

score: 60
Accepted
time: 2ms
memory: 3892kb

input:

341
3 1
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
1
3 1
0
1
1
1
1
1
3 1
1
1
1
0
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1...

result:

ok 

Test #89:

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

input:

103
10 1
1
1
1
1
1
1
1
1
1
1
0
1
1
10 1
1
1
0
1
1
0
1
1
0
1
1
1
1
1
1
10 1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
0
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
0
1
1
10 1
1
1
1
1
1
1
1
0
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
...

output:

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

result:

ok 

Test #90:

score: 60
Accepted
time: 0ms
memory: 3860kb

input:

22
50 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
50 1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 28
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 28 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 47
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 47 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 45
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 45 40
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 ...

result:

ok 

Test #91:

score: 60
Accepted
time: 2ms
memory: 4204kb

input:

11
101 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
101 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 58
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 58 72
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 72 63
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 63 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 98
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 98 78
3kC2Ia2048BfyJVGojMUKKtilctlZKc...

result:

ok 

Test #92:

score: 60
Accepted
time: 8ms
memory: 4232kb

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 142
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 142 148
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 148 55
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 55 53
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 53 201
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 201 117
3kC2Ia2048BfyJVGojMUKKti...

result:

ok 

Test #93:

score: 60
Accepted
time: 0ms
memory: 4368kb

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 206
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 206 97
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 97 220
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 220 53
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 53 222
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 222 232
3kC2Ia2048BfyJVGojMUKKti...

result:

ok 

Test #94:

score: 60
Accepted
time: 5ms
memory: 4288kb

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 13
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 13 231
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 231 102
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 102 89
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 89 32
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 32 177
3kC2Ia2048BfyJVGojMUKKtilc...

result:

ok 

Test #95:

score: 60
Accepted
time: 0ms
memory: 4224kb

input:

4
256 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 209
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 209 33
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 33 118
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 118 34
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 34 229
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 229 23
3kC2Ia2048BfyJVGojMUKKtil...

result:

ok 

Test #96:

score: 60
Accepted
time: 0ms
memory: 4092kb

input:

341
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
0
0
0
1
3 1
0
1
0
1
3 1
0
1
0
1
3 1
0
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
0
1
0
1
3 1
0
0
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
1
0
1
3 1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 2 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 0 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 2 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2...

result:

ok 

Test #97:

score: 60
Accepted
time: 4ms
memory: 3900kb

input:

205
5 1
1
1
0
1
0
1
5 1
0
0
1
0
1
0
1
5 1
1
0
0
0
0
1
5 1
1
0
1
0
0
1
5 1
1
0
1
0
0
1
5 1
1
1
0
1
0
1
5 1
0
0
0
0
0
1
5 1
0
0
0
1
0
1
5 1
0
0
1
0
1
0
1
5 1
0
1
0
1
0
1
5 1
0
0
0
1
0
1
5 1
1
0
1
0
0
1
5 1
0
0
1
0
1
0
1
5 1
1
0
1
1
0
1
5 1
0
0
0
1
0
1
5 1
0
0
0
1
0
1
5 1
0
0
1
0
1
0
1
5 1
0
1
1
1
0
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 2 0 2 4 1 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 2 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1...

result:

ok 

Test #98:

score: 0
Memory Limit Exceeded

input:

64
16 1
0
1
1
0
1
0
1
0
1
1
1
1
1
0
1
1
1
0
0
1
1
0
1
1
16 1
1
0
1
1
0
1
1
0
0
1
1
1
0
1
0
1
0
1
1
1
1
0
1
1
16 1
0
1
0
1
1
0
0
1
1
0
1
1
1
0
1
0
0
1
1
1
1
1
16 1
1
1
0
1
0
1
0
1
0
1
1
1
0
1
0
1
0
0
1
1
1
1
16 1
0
0
0
1
1
1
1
0
1
1
1
0
1
0
0
1
1
1
1
1
1
16 1
0
1
1
0
1
1
1
1
0
1
1
1
0
1
1
0
1
1
1
1
1...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 7
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 7
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 13
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 ...

result: