QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#154351#7119. Longest Trip1kri#5 14ms4264kbC++143.4kb2023-08-31 16:46:382024-04-28 06:40:49

Judging History

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

  • [2024-04-28 06:40:49]
  • 管理员手动重测本题所有提交记录
  • 测评结果:5
  • 用时:14ms
  • 内存:4264kb
  • [2023-08-31 16:46:38]
  • 评测
  • 测评结果:5
  • 用时:35ms
  • 内存:3988kb
  • [2023-08-31 16:46:38]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <random>
#include <vector>
#include "longesttrip.h"
using namespace std;
mt19937 rnd(114514);
vector<int> make_vec(int x){
    vector<int> ans;
    ans.push_back(x);
    return ans;
}
pair<int,int> find(vector<int> a,vector<int> b){
    if (a.size()==1&&b.size()==1)return make_pair(a[0],b[0]);
    if (a.size()<b.size())swap(a,b);
    int la=a.size();
    vector<int> al,ar;
    for (int i=0;i<la/2;i++)al.push_back(a[i]);
    for (int i=la/2;i<la;i++)ar.push_back(a[i]);
    if (are_connected(al,b))return find(al,b);
    return find(ar,b);
}
vector<int> work(vector<vector<int>> c){
    int l=(int)c.size();
    if (l==1)return c[0];
    if (l==2){
        if (are_connected(c[0],c[1])){
            int l0=c[0].size(),l1=c[1].size();
            vector<int> ans;
            if (are_connected(make_vec(c[0][0]),make_vec(c[1][0]))){
                for (int i=l1-1;i>=0;i--)ans.push_back(c[1][i]);
                for (int i=0;i<l0;i++)ans.push_back(c[0][i]);
                return ans;
            }
            else if (are_connected(make_vec(c[0][0]),make_vec(c[1][l1-1]))){
                for (int i=0;i<l1;i++)ans.push_back(c[1][i]);
                for (int i=0;i<l0;i++)ans.push_back(c[0][i]);
                return ans;
            }
            swap(c[0],c[1]);
            if (are_connected(make_vec(c[0][0]),make_vec(c[1][0]))){
                for (int i=l1-1;i>=0;i--)ans.push_back(c[1][i]);
                for (int i=0;i<l0;i++)ans.push_back(c[0][i]);
                return ans;
            }
            else if (are_connected(make_vec(c[0][0]),make_vec(c[1][l1-1]))){
                for (int i=0;i<l1;i++)ans.push_back(c[1][i]);
                for (int i=0;i<l0;i++)ans.push_back(c[0][i]);
                return ans;
            }
            pair<int,int> qwq=find(c[0],c[1]);
            int x=qwq.first,y=qwq.second;
            for (int i=1;i<=l0;i++)ans.push_back(c[0][(x+i)%l0]);
            for (int i=0;i<l1;i++)ans.push_back(c[1][(y+i)%l1]);
            return ans;
        }
        else{
            if (c[0].size()>c[1].size())return c[0];
            return c[1];
        }
    }
    vector<vector<int>> qwq(l);
    int o=0;
    for (int i=0;i<l;i++){
        qwq[i]=c[i];
        if (i>0){
            if (are_connected(qwq[i-1],qwq[i])){
                vector<int> ovo;
                for (int j=(int)qwq[i-1].size()-1;j>=0;j--)ovo.push_back(qwq[i-1][j]);
                for (int j=0;j<(int)qwq[i].size();j++)ovo.push_back(qwq[i][j]);
                qwq[i]=ovo;
                qwq[i-1].clear();
                o=0;
            }
            else{
                if (o==1&&qwq[i-2].size()>0){
                    vector<int> ovo;
                    for (int j=(int)qwq[i-2].size()-1;j>=0;j--)ovo.push_back(qwq[i-2][j]);
                    for (int j=0;j<(int)qwq[i].size();j++)ovo.push_back(qwq[i][j]);
                    qwq[i]=ovo;
                    qwq[i-2].clear();
                    o=0;    
                }
                else o=1;
            }
        }
    }
    vector<vector<int>> awa;
    for (int i=0;i<l;i++)
        if (qwq[i].size()>0)awa.push_back(qwq[i]);
    return work(awa);
}
vector<int> longest_trip(int n,int d){
    vector<vector<int>> c;
    for (int i=0;i<n;i++)c.push_back(make_vec(i));
    shuffle(c.begin(),c.end(),rnd);
    return work(c);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

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

output:

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

result:

ok 

Test #2:

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

input:

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

output:

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

result:

ok 

Test #3:

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

input:

22
50 3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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 3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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 3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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 41 39
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 41 39 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 39 41 46 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 46 41 39 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 39 41 46 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 46 41 ...

result:

ok 

Test #4:

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

input:

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 125 92 99 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 9...

result:

ok 

Test #5:

score: 0
Accepted
time: 14ms
memory: 4264kb

input:

4
256 3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 248
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 248 207
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 248 125 92 99 207 230
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0...

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Test #6:

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

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

result:

ok 

Test #7:

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

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

result:

ok 

Test #8:

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

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 41 39
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 41 39 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 39 41 46 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 46 41 39 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 39 41 46 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 46 41 ...

result:

ok 

Test #9:

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

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 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 125 92 99 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 9...

result:

ok 

Test #10:

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

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 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 248
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 248 207
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 248 125 92 99 207 230
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0...

result:

ok 

Test #11:

score: -10
Wrong Answer
time: 1ms
memory: 3844kb

input:

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

output:

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

result:

wrong answer 

Subtask #3:

score: 0
Wrong Answer

Test #19:

score: 25
Accepted
time: 3ms
memory: 3776kb

input:

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

output:

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

result:

ok 

Test #20:

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

input:

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

output:

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

result:

ok 

Test #21:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 41 39
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 41 39 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 39 41 46 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 46 41 39 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 39 41 46 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 46 41 ...

result:

ok 

Test #22:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 125 92 99 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 9...

result:

ok 

Test #23:

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

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 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 248
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 248 207
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 248 125 92 99 207 230
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0...

result:

ok 

Test #24:

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

input:

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

output:

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

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #83:

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

input:

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

output:

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

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

output:

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

result:

ok 

Test #85:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 41 39
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 41 39 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 39 41 46 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 46 41 39 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 39 41 46 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 46 41 ...

result:

ok 

Test #86:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 35 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 35 125 92 99 1 22
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 6 1 1 9...

result:

ok 

Test #87:

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

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 92 125
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 2 1 92 125 99
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 3 1 125 92 99 248
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 4 1 99 92 125 248 207
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 5 1 248 125 92 99 207 230
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0...

result:

ok 

Test #88:

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

input:

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

output:

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

result:

wrong answer