QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#164045#7119. Longest Tripnitrousoxide#5 20ms4120kbC++145.0kb2023-09-04 18:58:292024-04-28 08:33:08

Judging History

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

  • [2024-04-28 08:33:08]
  • 管理员手动重测本题所有提交记录
  • 测评结果:5
  • 用时:20ms
  • 内存:4120kb
  • [2023-09-04 18:58:30]
  • 评测
  • 测评结果:5
  • 用时:22ms
  • 内存:4256kb
  • [2023-09-04 18:58:29]
  • 提交

answer

#include "longesttrip.h"

#include <cstring>
#include <cassert>
#include <algorithm>

using namespace std;

const int maxn = 300;

int col[maxn];
bool vis[maxn];
bool g[maxn][maxn];
int p[maxn];
vector<int> t[maxn];
int n;
int component_size = 0;
int components = 0;

int recursive_find(int u,vector<int> candidates){
    if (candidates.size() == 1){
        return candidates[0];
    }
    // Double each time
    int i = 0;
    for (;(1 << i) < candidates.size();i++){
        // Search for first [1 << i] elements
        vector<int> t;
        for (int j = (i == 0) ? 0 : (1 << (i-1));j < (1 << i);j++){
            t.push_back(candidates[j]);
        }
        if (are_connected(t, vector<int>(1,u))){
            return recursive_find(u, t);
        }
        else{
          for (int i = 0;i < t.size();i++){
              for (int j = i+1;j < t.size();j++){
                  g[t[i]][t[j]] = g[t[j]][t[i]] = true;
              }
          }
        }
    }
    vector<int> t;
    for (int j = (1 << i);j < candidates.size();j++){
        t.push_back(candidates[j]);
    }
    return recursive_find(u, t);
}

int find_a_nonvis_edge(int u){
    vector<int> candidates;
    for (int i = 0;i < n;i++){
        if (!vis[i]){
            candidates.push_back(i);
            if (g[u][i]) return i;
        }
    }
    if (candidates.size() == 0){
        return -1;
    }
    if (!are_connected(candidates, vector<int>(1,u))){
        // no between u and candidates; candidates form a clique
        for (int i = 0;i < candidates.size();i++){
            for (int j = i+1;j < candidates.size();j++){
                g[candidates[i]][candidates[j]] = g[candidates[j]][candidates[i]] = true;
            }
        }
        return -1;
    }
    else{
        return recursive_find(u, candidates);
    }
}

void dfs(int u){
    vis[u] = true;
    col[u] = components;
    ++component_size;
    int i;
    while ((i = find_a_nonvis_edge(u)) != -1){
            p[i] = u;
            t[u].push_back(i);
            t[i].push_back(u);
            dfs(i);
    }
}

vector<int> path;

void find_path(int u){
    vis[u] = true;
    path.push_back(u);
    for (auto v : t[u]){
        if (!vis[v]){
            find_path(v);
            return;
        }
    }
}

void dfs2(int u){
    vis[u] = true;
    for (auto v : t[u]){
        if (!vis[v]){
            p[v] = u;
            dfs2(v);
        }
    }
}

std::vector<int> longest_trip(int N, int D)
{
    n = N;
    for (int i = 0;i < n;i++){
      for (int j = 0;j < n;j++){
        g[i][j] = false;
      }
        t[i].clear();
        col[i] = -1;
    }
    memset(vis,false,sizeof vis);
    int max_size = -1;
    int max_id = 0;
    components = 0;

    for (int i = 0;i < n;i++){
        if (!vis[i]){
            component_size = 0;
            ++components;
            dfs(i);
            if (component_size > max_size){
                max_size = component_size;
                max_id = i;
            }
        }
    }
    // Find dfs tree from vertex max_id
    memset(vis,false,sizeof vis);
    memset(p,0,sizeof p);

    int max_deg = 0;
    for (int i = 0;i < n;i++){
        if (col[i] == col[max_id]) max_deg = max(max_deg, (int)t[i].size());
    }
    assert(max_deg <= 3);
    path.clear();

    if (max_deg <= 2){
        // Starting from a deg one vertex then go from there
        memset(vis,false,sizeof vis);
        for (int i = 0;i < n;i++){
            if (t[i].size() == 1 && col[i] == col[max_id]){
                find_path(i);
                return path;
            }
        }
    }
    else{
        // The vertex with max degree 3 shall be unique, and there must be 3 deg 1 vertices
        int root = 0;
        for (int i = 0;i < n;i++){
            if (t[i].size() == 3 && col[i] == col[max_id]){
                assert(root == 0);
                root = i;
            }
        }
        assert(root != 0);
        memset(vis,false,sizeof vis);
        dfs2(root);

        int deg_1[4];
        int count_1 = 0;
        for (int i = 0;i < n;i++){
            if (t[i].size() == 1 && col[i] == col[max_id]){
                deg_1[++count_1] = i;
            }
        }
        assert(count_1 == 3);

        for (int i = 1;i <= 3;i++){
            for (int j = i+1;j <= 3;j++){
                if (are_connected(vector<int>(1,deg_1[i]), vector<int>(1,deg_1[j]))){
                    memset(vis,false,sizeof vis);
                    find_path(deg_1[6-i-j]);
                    for (int k = 1;k <= 3;k++){
                        if (!vis[deg_1[k]]){
                            int cur = deg_1[k];
                            while (cur != root){
                                path.push_back(cur);
                                cur = p[cur];
                            }
                            return path;
                        }
                    }
                }
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

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

output:

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

result:

ok 

Test #2:

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

input:

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

output:

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

result:

ok 

Test #3:

score: 0
Accepted
time: 2ms
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 49 1 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 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

result:

ok 

Test #4:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 127 1 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: 12ms
memory: 3952kb

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 255 1 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: 0
Runtime Error

Test #6:

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

input:

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

output:

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

result:

ok 

Test #7:

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

input:

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

output:

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

result:

ok 

Test #8:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 49 1 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 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

result:

ok 

Test #9:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 127 1 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 #10:

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

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 255 1 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 #11:

score: -10
Runtime Error

input:

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

output:

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

result:


Subtask #3:

score: 0
Runtime Error

Test #19:

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

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

result:

ok 

Test #20:

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

input:

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

output:

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

result:

ok 

Test #21:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 49 1 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 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

result:

ok 

Test #22:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 127 1 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 #23:

score: 0
Accepted
time: 20ms
memory: 3960kb

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 255 1 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 #24:

score: -25
Runtime Error

input:

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

output:

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

result:


Subtask #4:

score: 0
Runtime Error

Test #83:

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

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

result:

ok 

Test #84:

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

input:

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

output:

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

result:

ok 

Test #85:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 49 1 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 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 0
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 48 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...

result:

ok 

Test #86:

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

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

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 127 1 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 #87:

score: 45
Acceptable Answer
time: 5ms
memory: 4024kb

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 255 1 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:

points 0.750 points  0.750

Test #88:

score: 0
Runtime Error

input:

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

output:

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

result: