QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#154964#7119. Longest Triparbuzick15 22ms4128kbC++207.4kb2023-09-01 04:18:092023-09-01 04:18:09

Judging History

你现在查看的是测评时间为 2023-09-01 04:18:09 的历史记录

  • [2024-04-28 06:51:30]
  • 管理员手动重测本题所有提交记录
  • 测评结果:15
  • 用时:9ms
  • 内存:4120kb
  • [2023-09-01 04:18:09]
  • 评测
  • 测评结果:15
  • 用时:22ms
  • 内存:4128kb
  • [2023-09-01 04:18:09]
  • 提交

answer

#include <bits/stdc++.h>

#include "longesttrip.h"

using namespace 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) {
        vector<int> ans = {0};
        vector<int> used(n);
        used[0] = 1;
        while (ans.size() < n) {
            int nxt = -1;
            for (int i = 0; i < n; ++i) {
                if (!used[i] && are_connected({ans.back()}, {i})) {
                    nxt = i;
                    used[i] = 1;
                    break;
                }
            }
            if (nxt == -1) {
                reverse(ans.begin(), ans.end());
                for (int i = 0; i < n; ++i) {
                    if (!used[i] && are_connected({ans.back()}, {i})) {
                        nxt = i;
                        used[i] = 1;
                        break;
                    }
                }
            }
            ans.push_back(nxt);
        }
        return ans;
    }
    if (d == 1) {
        mt19937 rnd(57);
        vector<vector<int>> blocks;
        for (int i = 0; i < n; ++i) {
            blocks.push_back({i});
        }
        shuffle(blocks.begin(), blocks.end(), rnd);
        vector<int> ans = blocks.back();
        blocks.pop_back();
        auto try_to_add = [&](vector<int> vals) {
            if (vals.empty()) {
                return -1;
            }
            if (!are_connected({ans.back()}, vals)) {
                return -1;
            }
            while (vals.size() > 1) {
                int m = vals.size() / 2;
                vector<int> vals1, vals2;
                for (int i = 0; i < (int)vals.size(); ++i) {
                    if (i < m) {
                        vals1.push_back(vals[i]);
                    } else {
                        vals2.push_back(vals[i]);
                    }
                }
                if (are_connected({ans.back()}, vals1)) {
                    vals = vals1;
                } else {
                    vals = vals2;
                }
            }
            return vals[0];
        };
        while (!blocks.empty()) {
            shuffle(blocks.begin(), blocks.end(), rnd);
            bool change = false;
            while (blocks.size() > 1) {
                if (are_connected({ans.back()}, {blocks.back()[0]})) {
                    change = true;
                    for (auto vl : blocks.back()) {
                        ans.push_back(vl);
                    }
                    blocks.pop_back();
                    break;
                }
                if (are_connected({ans.back()}, {blocks.rbegin()[1].back()})) {
                    change = true;
                    swap(blocks.back(), blocks.rbegin()[1]);
                    reverse(blocks.back().begin(), blocks.back().end());
                    for (auto vl : blocks.back()) {
                        ans.push_back(vl);
                    }
                    blocks.pop_back();
                }
                for (auto vl : blocks.back()) {
                    blocks.rbegin()[1].push_back(vl);
                }
                blocks.pop_back();
            }
            if (change) {
                continue;
            }
            if (are_connected({ans.back()}, {blocks[0].back()})) {
                reverse(blocks.back().begin(), blocks.back().end());
                for (auto vl : blocks.back()) {
                    ans.push_back(vl);
                }
                blocks.pop_back();
            } else {
                int val = try_to_add(blocks[0]);
                if (val != -1) {
                    vector<int> vals1, vals2;
                    for (auto vl : blocks[0]) {
                        if (vals2.empty() && vl != val) {
                            vals1.push_back(vl);
                        } else {
                            vals2.push_back(vl);
                        }
                    }
                    for (auto vl : vals2) {
                        ans.push_back(vl);
                    }
                    for (auto vl : vals1) {
                        ans.push_back(vl);
                    }
                    blocks.pop_back();
                } else {
                    break;
                }
            }
        }
        if (!blocks.empty()) {
            reverse(ans.begin(), ans.end());
            int val = try_to_add(blocks[0]);
            if (val != -1) {
                vector<int> vals1, vals2;
                for (auto vl : blocks[0]) {
                    if (vals2.empty() && vl != val) {
                        vals1.push_back(vl);
                    } else {
                        vals2.push_back(vl);
                    }
                }
                for (auto vl : vals2) {
                    ans.push_back(vl);
                }
                for (auto vl : vals1) {
                    ans.push_back(vl);
                }
                blocks.pop_back();
            } else {
                vector<int> ans2 = ans;
                if (are_connected(ans2, blocks[0])) {
                    while (ans2.size() > 1) {
                        int m = ans2.size() / 2;
                        vector<int> ans21, ans22;
                        for (int i = 0; i < (int)ans2.size(); ++i) {
                            if (i < m) {
                                ans21.push_back(ans2[i]);
                            } else {
                                ans22.push_back(ans2[i]);
                            }
                        }
                        if (are_connected(ans21, blocks[0])) {
                            ans2 = ans21;
                        } else {
                            ans2 = ans22;
                        }
                    }
                    vector<int> ansl, ansr;
                    for (auto vl : ans) {
                        if (ansl.empty() || ansl.back() != ans2[0]) {
                            ansl.push_back(vl);
                        } else {
                            ansr.push_back(vl);
                        }
                    }
                    ans.clear();
                    for (auto vl : ansr) {
                        ans.push_back(vl);
                    }
                    for (auto vl : ansl) {
                        ans.push_back(vl);
                    }
                    int val = try_to_add(blocks[0]);
                    if (val != -1) {
                        vector<int> vals1, vals2;
                        for (auto vl : blocks[0]) {
                            if (vals2.empty() && vl != val) {
                                vals1.push_back(vl);
                            } else {
                                vals2.push_back(vl);
                            }
                        }
                        for (auto vl : vals2) {
                            ans.push_back(vl);
                        }
                        for (auto vl : vals1) {
                            ans.push_back(vl);
                        }
                        blocks.pop_back();
                    }
                }
            }
        }
        if (!blocks.empty() && blocks[0].size() > ans.size()) {
            ans = blocks[0];
        }
        return ans;
    }
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

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

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: 2ms
memory: 4104kb

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: 2ms
memory: 3808kb

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

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

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: 6ms
memory: 3820kb

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

result:

ok 

Test #7:

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

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 1 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: 3ms
memory: 3816kb

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 1 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: 3792kb

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 1 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: 11ms
memory: 3816kb

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 1 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: 2ms
memory: 3820kb

input:

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

output:

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

result:

ok 

Test #12:

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

input:

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

result:

ok 

Test #13:

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

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

output:

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

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 1 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: 4ms
memory: 3828kb

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 1 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: 7ms
memory: 3804kb

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 1 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: 6ms
memory: 4116kb

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 1 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: 4ms
memory: 3900kb

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 1 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
Runtime Error

Test #19:

score: 25
Accepted
time: 8ms
memory: 4108kb

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

result:

ok 

Test #20:

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

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

result:

ok 

Test #21:

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

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 26 11
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 11 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 46 19
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 19 21
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 21 36
3kC2Ia2048BfyJVGojMUKKtilctlZKcB...

result:

ok 

Test #22:

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

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 29 100
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 100 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 35 73
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 73 47
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 47 95
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 95 93
3kC2Ia2048BfyJVGojMUKKtilctl...

result:

ok 

Test #23:

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

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 200 181
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 181 111
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 111 150
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 150 114
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 114 92
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 92 99
3kC2Ia2048BfyJVGojMUK...

result:

ok 

Test #24:

score: -25
Runtime Error

input:

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

output:

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

result:


Subtask #4:

score: 0
Runtime Error

Test #83:

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

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

result:

ok 

Test #84:

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

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

result:

ok 

Test #85:

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

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 26 11
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 11 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 2 46
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 46 19
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 19 21
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 21 36
3kC2Ia2048BfyJVGojMUKKtilctlZKcB...

result:

ok 

Test #86:

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

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 29 100
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 100 35
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 35 73
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 73 47
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 47 95
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 95 93
3kC2Ia2048BfyJVGojMUKKtilctl...

result:

ok 

Test #87:

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

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 200 181
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 181 111
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 111 150
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 150 114
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 114 92
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 92 99
3kC2Ia2048BfyJVGojMUK...

result:

ok 

Test #88:

score: 0
Runtime Error

input:

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

output:

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

result: