QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#473420#7119. Longest Tripivan_alexeev15 12ms4308kbC++234.3kb2024-07-12 03:23:542024-07-12 03:24:01

Judging History

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

  • [2024-07-12 03:24:01]
  • 评测
  • 测评结果:15
  • 用时:12ms
  • 内存:4308kb
  • [2024-07-12 03:23:54]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "longesttrip.h"

using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>

#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,bmi2,fma")


#ifdef lisie_bimbi
#define debug(x) cout << #x << " : " << x << endl;
#else
#define debug(x) ;
#define endl '\n'
#endif

//#define int long long
#define inf 1000000000000000000
#define double long double
typedef long long ll;
vector<vector<int>> v;
vector<int> per;

bool get(int a, int b){
    a = per[a];
    b = per[b];
    if(v[a][b] != -1){
        return v[a][b];
    }
    if(a == b){
        return 0;
    }
    if(are_connected({a}, {b})){
        v[a][b] = 1;
        v[b][a] = 1;
    }else{
        v[a][b] = 0;
        v[b][a] = 0;
    }
    return v[a][b];
}

void dfs(int u, vector<int> &used, int x, int &cnt){
    used[u] = 1;
    cnt++;
    for(int i = 0; i <= x; i++){
        if(!used[i] && get(u, i)){
            dfs(i, used, x, cnt);
        }
    }
}

deque<int> solve(int n){
    if(n == 2) {
        return {0, 1};
    }
    vector<int> used(n);
    int cnt = 0;
    dfs(0, used, n - 2, cnt);
    if(cnt == n - 1){
        deque<int> ans = solve(n - 1);
        if(get(n - 1, ans[0])){
            ans.push_front(n - 1);
            return ans;
        }else if(get(n - 1, ans.back())){
            ans.push_back(n - 1);
            return ans;
        }else{
            deque<int> ans1;
            int ind = -1;
            for(int i = 0; i < n - 1; i++){
                if(get(ans[i], n - 1)){
                    ind = i;
                    break;
                }
            }
            ans1.push_back(n - 1);
            for(int i = ind; i < n - 1; i++){
                ans1.push_back(ans[i]);
            }
            for(int i = 0; i < ind; i++){
                ans1.push_back(ans[i]);
            }
            return ans1;
        }
    }else{
        deque<int> ans;
        int a, b;
        for(int i = 0; i < n - 1; i++){
            if(used[i]) {
                if (get(i, n - 1)){
                    a = i;
                }
            }else {
                if (get(i, n - 1)) {
                    b = i;
                }
            }
        }
        for(int i = 0; i < n - 1; i++){
            if(used[i] && (i != a)){
                ans.push_back(i);
            }
        }
        ans.push_back(a);
        ans.push_back(n - 1);
        ans.push_back(b);
        for(int i = 0; i < n - 1; i++){
            if(!used[i] && (i != b)){
                ans.push_back(i);
            }
        }
        return ans;
    }
}

mt19937 rnd(239);

vector<int> longest_trip(int n, int d){
    v.clear();
    per.clear();
    per.resize(n);
    for(int i = 0; i < n; i++){
        per[i] = i;
    }
    std::shuffle(per.begin(), per.end(), rnd);
    if(d == 3){
        vector<int> ans(n);
        for(int i = 0; i < n; i++){
            ans[i] = i;
        }
        return ans;
    }else if(d == 2){
        deque<int> ans;
        int x;
        if(are_connected({0}, {1})){
            x = 1;
            ans = {0, 1};
        }else{
            ans = {0, 2};
            x = 2;
        }
        for(int i = 1; i < n; i++){
            if(i == x){
                continue;
            }
            if(are_connected({i}, {ans.back()})){
                ans.push_back(i);
            }else{
                ans.push_front(i);
            }
        }
        vector<int> ans1;
        for(auto i : ans){
            ans1.push_back(i);
        }
        return ans1;
    }
    v.resize(n, vector<int>(n, -1));
    vector<int> used(n, 0);
    int cnt = 0;
    dfs(0, used, n - 1, cnt);
    if(cnt != n){
        if(cnt * 2 >= n){
            vector<int> ans;
            for(int i = 0; i < n; i++){
                if(used[i]){
                    ans.push_back(i);
                }
            }
            return ans;
        }else{
            vector<int> ans;
            for(int i = 0; i < n; i++){
                if(!used[i]){
                    ans.push_back(i);
                }
            }
            return ans;
        }
    }
    auto ans = solve(n);
    vector<int> ans1;
    for(auto i : ans){
        ans1.push_back(i);
    }
    return ans1;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

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

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: 0ms
memory: 3988kb

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: 0ms
memory: 3744kb

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: 0ms
memory: 3776kb

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: 4056kb

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1...

result:

ok 

Test #7:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #8:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #9:

score: 0
Accepted
time: 3ms
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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #10:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #11:

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

input:

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

output:

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

result:

ok 

Test #12:

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

input:

103
10 2
0
1
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
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
...

output:

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

result:

ok 

Test #13:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #14:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #15:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #16:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #17:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Test #18:

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

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 2 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 4 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 5 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 6 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 7 6...

result:

ok 

Subtask #3:

score: 0
Wrong Answer

Test #19:

score: 25
Accepted
time: 4ms
memory: 4028kb

input:

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

output:

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

result:

ok 

Test #20:

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

input:

103
10 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
10 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
10 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
10 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
10 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
10 1
1
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok 

Test #21:

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

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
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
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
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 26 19
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 19 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 46 32
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 32 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
...

result:

ok 

Test #22:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 75 19
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 19 54
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 54 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 46 63
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 63 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 4
3kC2Ia2048BfyJVGojMUKKtilctlZKc...

result:

ok 

Test #23:

score: 0
Accepted
time: 12ms
memory: 4308kb

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 75 169
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 169 54
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 54 161
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 161 63
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 63 223
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 223 4
3kC2Ia2048BfyJVGojMUKKtil...

result:

ok 

Test #24:

score: -25
Wrong Answer
time: 1ms
memory: 3972kb

input:

341
3 1
0
1
1

output:

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

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #83:

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

input:

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

output:

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

result:

ok 

Test #84:

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

input:

103
10 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
10 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
10 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
10 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
10 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
10 1
1
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok 

Test #85:

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

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
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
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
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 26 19
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 19 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 3 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 46 32
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 32 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
...

result:

ok 

Test #86:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 75 19
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 19 54
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 54 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 46 63
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 63 18
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 18 4
3kC2Ia2048BfyJVGojMUKKtilctlZKc...

result:

ok 

Test #87:

score: 60
Accepted
time: 12ms
memory: 4228kb

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 75 169
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 169 54
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 54 161
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 161 63
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 63 223
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 223 4
3kC2Ia2048BfyJVGojMUKKtil...

result:

ok 

Test #88:

score: 0
Wrong Answer
time: 1ms
memory: 3772kb

input:

341
3 1
0
1
1

output:

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

result:

wrong answer