QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596039#9432. Permutationucup-team3519#AC ✓250ms3956kbC++173.1kb2024-09-28 14:59:592024-09-28 15:00:00

Judging History

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

  • [2024-09-28 15:00:00]
  • 评测
  • 测评结果:AC
  • 用时:250ms
  • 内存:3956kb
  • [2024-09-28 14:59:59]
  • 提交

answer

#include <bits/stdc++.h>

std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());

int query(const std::vector<int> &a) {
    std::cout << "0 ";
    for (int i : a) {
        std::cout << i + 1 << ' ';
    }
    std::cout << std::endl;
    int res;
    std::cin >> res;
    return res;
}
void answer(const std::vector<int> &a) {
    std::cout << "1 ";
    for (int i : a) {
        std::cout << i + 1 << ' ';
    }
    std::cout << std::endl;
}

int main() {
    int n;
    std::cin >> n;

    std::vector<int> all(n);
    std::iota(all.begin(), all.end(), 0);

    std::vector<int> p(n);
    auto solve = [&](auto self, int l, int r, std::vector<int> arr) -> void {
        // std::cout << "(" << l + 1 << ", " << r + 1 << ") ";
        // for (int i : arr) {
        //     std::cout << i + 1 << ' ';
        // }
        // std::cout << '\n';
        // assert(arr.size() == r - l + 1);
        
        if (l == r) {
            p[l] = arr[0];
            return;
        }

        std::shuffle(arr.begin(), arr.end(), rng);

        std::vector<std::vector<int>> pack;
        for (int i : arr) {
            pack.push_back(std::vector<int>{i});
        }

        int mid = (l + r) / 2;
        
        std::vector<int> L, R;
        auto cap_L = [&]() {
            return mid - l + 1 - L.size();
        };
        auto cap_R = [&]() {
            return r - mid - R.size();
        };

        while (!pack.empty()) {
            auto a = pack.back();
            pack.pop_back();
            if (a.size() > cap_L()) {
                R.insert(R.end(), a.begin(), a.end());
            } else if (a.size() > cap_R()) {
                L.insert(L.end(), a.begin(), a.end());
            } else {
                assert(!pack.empty());
                auto b = pack.back();
                pack.pop_back();
            
                if (b.size() > cap_L()) {
                    L.insert(L.end(), a.begin(), a.end());
                    R.insert(R.end(), b.begin(), b.end());
                } else if (b.size() > cap_R()) {
                    L.insert(L.end(), b.begin(), b.end());
                    R.insert(R.end(), a.begin(), a.end());
                } else {
                    int x = a.back(), y = b.back();
                    std::vector<int> q(n, x);
                    for (int i = mid + 1; i <= r; ++i) {
                        q[i] = y;
                    }
                    int rsps = query(q);
                    if (rsps == 2) {
                        L.insert(L.end(), a.begin(), a.end());
                        R.insert(R.end(), b.begin(), b.end());
                    } else if (rsps == 0) {
                        L.insert(L.end(), b.begin(), b.end());
                        R.insert(R.end(), a.begin(), a.end());
                    } else {
                        a.insert(a.end(), b.begin(), b.end());
                        pack.push_back(a);
                    }
                }
            }
        }

        self(self, l, mid, L);
        self(self, mid + 1, r, R);
    };
    solve(solve, 0, n - 1, all);

    answer(p);
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3676kb

input:

5
0
1
0
2
0

output:

0 1 1 1 3 3 
0 2 2 2 4 4 
0 2 2 3 2 2 
0 3 4 3 3 3 
0 5 5 5 5 1 
1 3 4 2 1 5 

result:

ok Accepted

Test #2:

score: 0
Accepted
time: 242ms
memory: 3752kb

input:

1000
1
1
1
0
1
1
0
1
1
1
2
0
2
1
0
2
2
2
0
1
1
0
2
2
2
1
1
0
2
1
2
0
2
2
2
1
2
1
1
1
1
0
2
1
1
2
2
2
1
1
1
2
0
1
1
0
1
2
2
1
1
1
2
1
0
1
0
0
1
0
2
1
0
2
1
0
1
1
0
2
2
0
0
2
0
0
1
0
2
2
2
0
0
2
0
2
0
1
1
1
1
2
1
0
1
2
2
0
1
2
1
1
2
2
1
0
1
1
2
0
1
0
1
1
1
1
0
2
1
1
1
1
2
2
1
0
1
0
1
1
1
1
1
0
0
2
1
2...

output:

0 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 453 45...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1 

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2 
1 2 1 

result:

ok Accepted

Test #5:

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

input:

3
1
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
0
2
0

output:

0 2 2 1 1 
0 1 1 4 4 
0 3 4 3 3 
0 1 1 1 2 
1 3 4 2 1 

result:

ok Accepted

Test #7:

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

input:

6
2
0
2
1
0
2
2

output:

0 2 2 2 5 5 5 
0 1 1 1 3 3 3 
0 4 4 4 6 6 6 
0 3 3 4 3 3 3 
0 4 3 4 4 4 4 
0 6 6 6 6 6 5 
0 1 1 1 1 6 1 
1 3 4 2 1 6 5 

result:

ok Accepted

Test #8:

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

input:

7
1
1
2
2
1
0
2
0
1
2

output:

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

result:

ok Accepted

Test #9:

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

input:

8
2
2
2
0
1
2
0
2
2
2
0
0

output:

0 7 7 7 7 5 5 5 5 
0 2 2 2 2 8 8 8 8 
0 1 1 1 1 4 4 4 4 
0 6 6 6 6 3 3 3 3 
0 7 7 3 3 7 7 7 7 
0 3 3 1 1 3 3 3 3 
0 7 3 7 7 7 7 7 7 
0 2 2 2 1 2 2 2 2 
0 5 5 5 5 5 5 4 4 
0 6 6 6 6 6 6 8 8 
0 5 5 5 5 5 6 5 5 
0 8 8 8 8 8 8 8 4 
1 3 7 2 1 6 5 4 8 

result:

ok Accepted

Test #10:

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

input:

9
1
1
2
0
2
0
2
2
2
0
2
0
0
0

output:

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

result:

ok Accepted

Test #11:

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

input:

10
1
0
1
0
0
2
2
2
0
0
1
0
0
2
0

output:

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

result:

ok Accepted

Test #12:

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

input:

11
2
1
1
2
0
2
2
0
2
0
2
1
2
0
0
0
0
0

output:

0 7 7 7 7 7 7 2 2 2 2 2 
0 9 9 9 9 9 9 10 10 10 10 10 
0 10 10 10 10 10 10 1 1 1 1 1 
0 1 1 1 1 1 1 6 6 6 6 6 
0 8 8 8 8 8 8 5 5 5 5 5 
0 3 3 3 3 3 3 11 11 11 11 11 
0 7 7 7 5 5 5 7 7 7 7 7 
0 9 9 9 3 3 3 9 9 9 9 9 
0 10 10 10 1 1 1 10 10 10 10 10 
0 10 10 3 10 10 10 10 10 10 10 10 
0 3 7 3 3 3 3 3 ...

result:

ok Accepted

Test #13:

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

input:

12
2
2
2
2
1
2
1
0
1
2
0
2
2
1
2
1
2
2
0
0

output:

0 9 9 9 9 9 9 4 4 4 4 4 4 
0 7 7 7 7 7 7 11 11 11 11 11 11 
0 3 3 3 3 3 3 8 8 8 8 8 8 
0 10 10 10 10 10 10 2 2 2 2 2 2 
0 5 5 5 5 5 5 1 1 1 1 1 1 
0 1 1 1 1 1 1 12 12 12 12 12 12 
0 5 5 5 9 9 9 5 5 5 5 5 5 
0 9 9 9 7 7 7 9 9 9 9 9 9 
0 10 10 10 3 3 3 10 10 10 10 10 10 
0 7 7 10 7 7 7 7 7 7 7 7 7 
0 ...

result:

ok Accepted

Test #14:

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

input:

13
1
1
2
1
1
1
0
0
2
0
2
1
2
0
2
2
2
0
1
2
0
2
0
2

output:

0 1 1 1 1 1 1 1 13 13 13 13 13 13 
0 13 13 13 13 13 13 13 10 10 10 10 10 10 
0 10 10 10 10 10 10 10 6 6 6 6 6 6 
0 2 2 2 2 2 2 2 12 12 12 12 12 12 
0 12 12 12 12 12 12 12 8 8 8 8 8 8 
0 8 8 8 8 8 8 8 11 11 11 11 11 11 
0 11 11 11 11 11 11 11 7 7 7 7 7 7 
0 3 3 3 3 3 3 3 4 4 4 4 4 4 
0 13 13 13 13 9 ...

result:

ok Accepted

Test #15:

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

input:

14
0
2
1
2
2
1
0
0
1
2
0
2
1
0
0
2
2
2
2
1
2
0
0
0
0
0
0
0

output:

0 3 3 3 3 3 3 3 1 1 1 1 1 1 1 
0 4 4 4 4 4 4 4 12 12 12 12 12 12 12 
0 7 7 7 7 7 7 7 10 10 10 10 10 10 10 
0 10 10 10 10 10 10 10 11 11 11 11 11 11 11 
0 9 9 9 9 9 9 9 5 5 5 5 5 5 5 
0 6 6 6 6 6 6 6 8 8 8 8 8 8 8 
0 8 8 8 8 8 8 8 14 14 14 14 14 14 14 
0 2 2 2 2 2 2 2 13 13 13 13 13 13 13 
0 13 13 13...

result:

ok Accepted

Test #16:

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

input:

15
2
1
0
0
1
1
2
2
0
2
2
1
2
2
2
0
2
1
2
2
2
1
0
1
0
1
2
0
0
0
0

output:

0 9 9 9 9 9 9 9 9 2 2 2 2 2 2 2 
0 14 14 14 14 14 14 14 14 6 6 6 6 6 6 6 
0 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 
0 12 12 12 12 12 12 12 12 4 4 4 4 4 4 4 
0 11 11 11 11 11 11 11 11 15 15 15 15 15 15 15 
0 15 15 15 15 15 15 15 15 10 10 10 10 10 10 10 
0 10 10 10 10 10 10 10 10 5 5 5 5 5 5 5 
0 13 13 13 13 1...

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 231ms
memory: 3712kb

input:

975
1
1
1
1
2
2
0
1
1
2
2
1
2
1
0
0
2
1
0
1
0
1
0
2
0
1
0
1
0
0
1
1
1
1
0
1
0
0
1
2
2
2
1
2
1
0
1
1
0
0
1
1
2
1
1
1
0
1
1
1
0
0
1
2
1
1
0
1
1
1
1
2
2
2
0
2
0
1
2
1
0
1
1
2
0
1
0
1
0
2
1
0
1
1
1
0
2
0
0
2
0
1
1
2
2
2
0
1
2
1
2
0
2
2
0
1
1
2
2
1
0
1
1
1
1
0
0
0
1
0
2
2
0
0
2
2
1
1
2
1
1
2
1
2
0
1
0
2
...

output:

0 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 423 42...

result:

ok Accepted

Test #18:

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

input:

976
1
1
1
2
1
1
2
0
1
1
0
1
0
1
2
1
1
1
1
1
1
1
1
0
1
0
0
1
0
1
0
1
1
2
2
1
1
2
0
1
0
1
0
0
0
1
0
0
1
1
1
1
0
2
2
1
1
1
1
0
1
2
2
2
1
2
1
2
0
1
2
1
0
1
1
2
1
0
1
1
0
1
2
2
1
1
2
0
1
0
2
1
1
0
1
0
1
2
2
0
0
0
1
1
2
2
2
0
0
0
2
1
0
2
2
1
1
1
2
1
2
1
0
0
0
1
2
2
1
1
2
0
0
0
0
1
1
2
1
1
0
1
1
1
2
2
2
1
...

output:

0 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 16...

result:

ok Accepted

Test #19:

score: 0
Accepted
time: 219ms
memory: 3784kb

input:

977
1
2
1
0
1
1
0
1
0
0
0
2
2
2
0
1
1
0
2
2
0
0
0
1
1
2
2
1
2
2
2
1
0
1
1
1
2
0
1
1
1
1
0
1
2
2
2
1
1
2
0
2
1
2
1
2
1
1
2
1
1
2
1
0
0
1
2
1
2
0
2
2
1
1
1
1
1
1
1
1
1
0
0
1
2
2
0
0
1
0
0
1
2
1
0
2
1
0
1
1
1
1
1
1
2
2
1
2
2
0
1
2
1
1
2
2
1
1
2
0
0
2
2
0
2
1
1
2
1
2
0
2
2
0
0
2
1
0
2
1
0
1
0
0
1
0
0
1
...

output:

0 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 140 14...

result:

ok Accepted

Test #20:

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

input:

978
2
1
0
1
1
1
2
1
1
1
1
1
1
0
1
0
1
0
0
2
0
1
1
0
2
0
1
0
1
2
2
1
2
1
1
1
2
2
1
1
1
2
1
2
1
0
2
1
1
0
2
0
2
0
1
2
1
1
1
1
2
1
0
2
2
1
2
1
2
1
0
2
0
2
0
1
1
1
0
1
1
0
2
1
1
1
1
2
2
2
1
1
2
1
0
2
2
0
1
2
2
0
0
1
0
1
1
0
1
1
0
1
2
0
0
0
1
1
2
0
0
2
1
2
2
1
1
1
1
1
0
1
2
0
1
1
2
1
1
1
0
0
1
2
1
1
1
1
...

output:

0 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 750 75...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 227ms
memory: 3648kb

input:

979
1
1
0
0
1
1
1
0
0
1
2
1
0
2
2
2
2
0
1
0
1
2
0
1
2
0
1
1
1
1
1
2
0
0
0
0
1
1
0
1
2
1
2
0
0
1
1
1
2
2
0
1
1
0
2
1
1
1
1
2
1
0
1
1
0
1
1
1
1
2
1
0
1
1
1
0
2
0
1
2
1
1
2
0
1
2
1
2
2
2
1
2
1
1
1
2
1
1
1
0
2
1
2
0
1
0
1
2
1
1
0
1
0
2
2
2
1
1
1
1
0
1
2
0
1
2
2
2
1
1
0
1
1
0
1
1
2
2
0
1
0
2
2
1
1
0
1
0
...

output:

0 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 265 26...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 213ms
memory: 3692kb

input:

980
1
0
0
1
1
0
1
1
1
1
1
2
2
2
0
0
0
2
1
2
1
2
1
1
1
0
0
1
1
1
1
2
2
2
1
1
1
1
1
1
1
1
1
2
1
1
1
0
0
1
2
0
0
2
1
1
2
1
0
1
1
1
0
2
1
1
2
1
1
0
0
2
0
1
2
2
0
0
1
1
2
0
2
2
2
1
0
1
1
0
2
2
1
1
0
1
1
1
0
1
1
0
1
2
1
1
0
1
1
0
0
1
1
0
0
2
2
1
1
0
1
0
1
1
1
2
1
1
0
2
2
1
0
1
1
1
1
1
0
1
0
1
1
0
2
0
1
1
...

output:

0 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 5...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 223ms
memory: 3716kb

input:

981
0
1
1
2
1
1
2
2
1
1
1
0
1
1
1
1
1
1
1
1
1
2
0
2
1
1
1
1
2
2
1
1
1
1
0
2
1
1
0
1
0
2
0
1
2
2
0
1
1
1
1
0
1
0
0
2
0
1
1
2
1
2
2
2
1
2
0
1
1
0
0
1
1
1
1
0
2
2
1
1
1
0
2
1
2
1
1
2
1
1
1
2
0
1
1
1
2
2
1
1
1
2
2
1
1
0
1
1
2
1
0
1
1
2
1
1
2
0
1
1
0
1
1
2
0
1
1
1
2
1
0
0
2
2
2
1
0
0
2
1
0
1
2
1
0
1
0
1
...

output:

0 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 492 49...

result:

ok Accepted

Test #24:

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

input:

982
1
2
1
0
2
1
1
0
2
1
0
2
0
2
0
0
1
1
0
1
2
1
2
0
0
1
1
0
1
1
1
1
2
1
1
2
1
0
2
1
2
2
1
2
1
1
2
0
2
1
1
1
1
2
0
0
2
0
1
2
1
2
2
1
1
2
2
2
1
1
0
2
2
1
1
0
1
0
2
0
2
0
1
0
2
2
1
0
1
1
1
1
0
1
1
1
1
1
2
1
0
1
1
0
2
2
2
2
1
2
1
0
0
1
1
2
1
2
1
1
2
1
2
1
1
2
0
0
0
1
1
0
1
1
1
2
1
1
2
2
0
1
2
0
0
1
1
1
...

output:

0 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 21...

result:

ok Accepted

Test #25:

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

input:

983
2
2
2
1
0
1
1
1
1
2
2
1
1
2
1
0
1
2
2
0
1
1
0
1
1
1
1
2
1
1
1
1
2
1
2
0
1
1
2
2
1
0
1
1
1
0
1
1
1
1
0
1
1
0
2
1
0
1
2
1
1
1
0
0
2
1
1
0
0
1
0
2
2
1
1
1
1
0
0
0
1
0
1
0
1
1
1
1
2
1
2
0
0
2
1
0
2
1
1
1
2
2
1
0
1
1
2
2
1
1
2
0
2
2
1
1
1
1
2
0
1
1
1
0
1
1
1
0
2
1
2
0
2
0
2
2
1
0
2
1
2
1
0
0
1
1
1
1
...

output:

0 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 518 51...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 221ms
memory: 3756kb

input:

984
1
1
0
0
0
2
2
2
1
1
2
0
2
1
2
1
1
1
1
1
0
1
0
2
2
1
2
1
1
0
2
0
2
0
1
0
1
2
2
1
0
2
2
1
1
1
1
0
0
0
2
2
0
0
2
1
1
1
1
1
0
0
1
1
1
1
0
1
2
1
2
1
1
2
1
1
1
1
2
2
2
1
2
0
1
1
2
1
2
0
0
2
1
0
0
0
2
1
2
1
2
1
1
2
2
1
1
0
1
2
0
2
2
2
1
0
1
1
0
1
0
1
1
0
0
1
0
1
2
1
1
2
0
1
1
2
0
1
0
1
1
1
1
2
0
1
0
1
...

output:

0 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 946 94...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 220ms
memory: 3956kb

input:

985
1
2
0
2
1
0
1
1
1
1
2
0
2
0
1
0
0
1
0
1
0
0
1
1
2
0
1
1
1
0
2
2
1
2
1
0
1
1
1
1
1
0
2
1
2
1
0
1
0
0
1
2
1
1
2
0
1
0
2
0
0
0
0
2
2
0
1
1
1
0
0
0
1
0
0
0
1
2
0
2
0
2
2
1
1
1
0
1
1
1
1
0
1
2
1
0
1
2
1
1
1
1
2
2
1
2
2
0
2
1
1
2
2
1
0
1
1
1
1
2
1
0
2
1
1
0
1
1
0
2
0
0
1
2
2
2
2
1
1
1
0
2
0
2
2
1
2
1
...

output:

0 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 7...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 203ms
memory: 3776kb

input:

986
1
1
1
0
2
1
1
1
1
2
2
1
1
1
0
1
2
1
1
0
2
1
1
1
2
2
1
1
1
2
2
1
0
1
1
1
1
0
2
2
0
0
0
1
0
1
1
1
1
2
1
2
2
1
1
1
1
1
1
1
2
1
0
0
1
1
0
1
2
0
0
0
2
2
1
0
0
1
0
1
1
0
1
2
1
2
2
1
1
0
0
2
1
0
2
1
1
1
1
1
2
0
1
2
0
0
2
0
2
0
2
2
1
1
2
0
1
2
2
2
0
1
1
2
1
1
2
1
0
0
1
1
1
0
0
0
2
1
1
0
0
2
1
2
1
1
1
0
...

output:

0 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 334 33...

result:

ok Accepted

Test #29:

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

input:

987
1
2
0
1
1
2
1
1
0
1
1
2
1
1
1
0
0
1
0
1
2
0
2
1
1
1
0
2
2
1
0
0
2
0
1
2
1
1
1
0
1
2
2
0
1
2
1
0
1
1
1
2
2
2
2
0
2
1
1
1
2
1
1
1
2
0
0
1
1
2
0
1
0
1
2
1
2
1
1
1
0
1
1
1
0
1
0
2
1
2
0
1
0
0
2
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
0
1
1
1
1
1
0
2
1
0
2
0
2
0
2
1
1
1
0
2
2
0
1
2
1
0
1
2
1
1
0
0
0
1
1
1
...

output:

0 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 875 87...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 204ms
memory: 3956kb

input:

988
2
1
1
1
1
0
1
1
0
2
1
1
1
1
0
1
1
1
0
1
1
0
1
1
1
0
1
1
1
2
0
1
1
2
0
2
2
1
0
0
2
1
0
1
0
0
0
2
1
2
1
1
2
1
0
1
1
2
2
2
1
0
1
1
1
1
1
0
0
0
1
1
1
0
2
2
1
2
1
1
0
1
2
1
1
1
2
1
1
2
1
1
1
0
1
0
2
1
0
2
1
2
2
1
0
1
1
1
1
1
0
2
1
1
1
2
0
2
1
1
2
2
0
0
0
0
1
2
2
2
2
1
1
1
1
1
2
2
2
2
1
1
0
1
1
0
1
2
...

output:

0 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 338 33...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 207ms
memory: 3664kb

input:

989
1
2
1
0
1
1
2
1
0
0
1
1
2
0
0
1
2
2
2
0
1
0
1
1
0
1
2
0
0
1
0
1
1
0
1
2
1
1
2
0
2
2
1
2
2
0
2
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
0
2
0
1
0
2
0
2
1
1
2
0
2
0
1
0
1
1
0
2
2
1
0
2
1
1
1
2
1
1
1
1
1
1
1
0
2
2
1
1
2
1
1
2
0
0
0
1
1
0
1
0
0
0
1
2
0
2
2
2
1
1
0
1
1
0
0
0
1
2
1
1
0
1
2
2
1
1
1
2
1
0
0
1
1
...

output:

0 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 9...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 246ms
memory: 3776kb

input:

990
2
1
1
1
0
0
2
2
0
0
0
2
2
0
2
2
2
1
2
0
2
2
0
2
1
0
2
1
1
2
0
1
0
0
1
0
2
1
1
0
0
1
1
2
0
2
2
1
1
0
0
1
2
0
2
0
1
0
1
0
2
0
1
0
0
1
1
1
2
0
1
0
2
0
2
1
1
1
0
2
0
0
1
0
2
0
1
1
2
2
1
0
1
0
1
0
2
0
2
2
1
2
1
1
0
1
1
0
1
1
0
1
1
1
0
1
1
1
0
2
2
1
1
0
1
0
2
1
1
1
1
0
1
2
0
2
1
1
2
0
0
1
1
0
2
2
2
1
...

output:

0 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 21...

result:

ok Accepted

Test #33:

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

input:

991
1
1
2
1
2
1
2
1
2
1
2
0
1
0
2
2
0
1
1
2
2
2
0
2
0
1
1
2
2
1
0
1
1
2
0
2
2
1
1
1
1
0
1
0
1
0
1
0
1
2
0
1
2
2
1
1
0
1
0
0
0
2
0
1
1
1
1
1
2
1
2
0
1
1
1
2
1
1
1
2
1
1
2
1
0
0
0
2
1
1
1
0
2
1
0
1
1
2
1
2
1
2
1
0
0
0
0
1
2
1
1
0
1
1
1
1
1
1
2
1
0
1
1
1
1
0
0
1
0
1
2
1
0
1
0
1
1
2
2
2
1
1
0
2
0
0
0
0
...

output:

0 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 164 16...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 222ms
memory: 3752kb

input:

992
2
1
1
2
1
1
1
1
0
1
0
0
0
1
1
1
1
2
2
0
2
0
1
1
0
0
1
1
0
0
2
1
2
1
0
0
2
0
2
1
0
1
1
1
0
1
0
2
2
1
1
0
1
1
1
2
1
0
2
2
2
2
1
0
2
0
0
1
0
1
1
1
1
0
0
1
1
0
1
1
1
0
0
2
0
0
1
1
1
1
2
1
0
1
1
2
2
1
2
1
1
0
1
1
2
1
0
2
2
1
1
2
0
2
1
1
1
2
1
2
2
1
0
1
1
1
1
0
1
1
2
0
2
0
1
1
1
2
2
1
0
1
2
1
1
1
1
2
...

output:

0 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 306 30...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 250ms
memory: 3656kb

input:

993
1
1
0
1
1
0
0
0
0
1
1
2
1
1
1
1
2
2
2
0
1
1
1
1
0
0
2
1
2
2
2
0
0
2
1
2
1
1
0
1
0
1
2
2
1
1
0
2
2
2
2
1
2
0
2
0
1
1
1
1
1
0
0
2
2
2
1
0
1
1
1
1
1
2
2
1
1
1
1
1
1
2
2
1
1
1
1
1
1
0
1
2
2
1
2
0
2
2
0
1
2
1
0
2
1
2
2
0
1
1
0
0
1
1
1
2
0
0
0
0
0
1
2
1
2
0
0
1
2
0
2
0
1
0
0
2
1
0
1
1
1
1
2
1
2
2
0
1
...

output:

0 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 593 59...

result:

ok Accepted

Test #36:

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

input:

994
1
2
1
2
1
1
2
0
1
1
0
2
1
0
1
2
1
1
1
0
1
1
1
1
1
1
1
1
1
2
2
1
0
2
2
0
2
1
0
1
2
1
2
1
0
0
1
1
1
0
2
1
0
0
1
2
2
1
1
1
2
1
0
2
2
2
0
1
0
2
1
1
1
0
2
1
1
0
2
0
1
1
0
2
1
1
1
1
2
0
1
2
2
1
1
1
1
1
0
0
0
2
1
1
0
1
1
2
0
2
0
2
2
2
1
1
1
0
1
2
1
1
1
2
0
0
1
0
1
0
1
0
0
1
1
1
2
1
0
1
0
1
1
1
2
1
1
1
...

output:

0 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 284 28...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 240ms
memory: 3784kb

input:

995
1
1
1
1
1
0
2
2
0
2
1
2
1
1
0
1
1
1
1
2
2
2
0
1
2
2
0
1
1
1
1
0
0
1
1
0
0
2
2
0
0
1
1
1
2
1
1
2
1
0
2
1
0
2
2
1
0
1
1
0
0
0
0
1
2
0
1
1
1
1
1
1
2
0
1
1
1
1
2
0
0
1
0
2
2
1
1
1
1
1
1
0
1
1
1
0
2
1
0
1
0
1
1
1
1
1
0
1
0
1
1
2
2
0
0
2
1
1
0
1
0
0
0
1
0
1
1
1
1
2
2
2
2
1
2
1
2
0
1
1
2
1
0
1
0
2
1
1
...

output:

0 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 783 78...

result:

ok Accepted

Test #38:

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

input:

996
0
1
0
1
2
0
0
0
1
0
0
0
1
2
1
0
1
1
2
0
1
1
2
0
2
0
0
2
1
1
2
0
1
1
1
1
1
0
2
0
2
1
1
1
2
0
1
1
1
0
2
0
0
1
0
1
1
2
1
0
1
0
1
2
0
2
2
2
1
0
2
0
1
0
1
1
1
0
2
1
1
1
1
2
2
2
1
0
0
1
0
1
1
1
2
1
1
0
1
1
1
1
0
2
0
1
1
1
0
1
0
2
1
0
2
1
1
2
0
0
0
1
0
1
1
0
2
2
2
1
1
1
1
2
2
1
0
0
2
2
2
1
2
0
0
0
0
0
...

output:

0 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 716 71...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 223ms
memory: 3712kb

input:

997
1
0
1
0
2
0
0
0
2
1
1
2
2
0
2
0
1
2
0
1
0
1
0
0
1
1
1
1
0
1
0
0
0
1
1
1
2
1
1
1
0
1
1
1
2
1
1
0
0
0
1
1
2
1
0
2
0
1
2
1
1
0
0
0
0
1
1
1
2
1
2
0
0
1
2
1
1
1
1
1
2
2
2
1
1
0
1
1
2
2
0
2
1
2
1
2
2
1
2
2
2
1
1
1
1
0
1
1
1
0
1
0
1
1
1
0
1
2
2
0
2
1
2
2
1
1
2
0
0
2
2
1
1
1
1
1
2
2
1
1
0
2
2
1
0
0
0
0
...

output:

0 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 624 62...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 235ms
memory: 3784kb

input:

998
1
1
0
1
0
0
1
2
2
1
0
0
2
0
1
2
2
1
1
1
1
2
2
1
0
1
0
1
1
1
1
1
1
1
0
2
2
2
1
1
1
1
1
1
1
1
0
0
0
0
2
2
1
0
2
2
1
1
2
2
1
1
0
0
0
1
2
1
1
0
1
2
0
1
1
0
1
2
2
2
1
1
2
0
0
2
1
0
1
1
0
0
0
0
0
2
2
0
1
1
2
2
0
1
1
0
1
1
1
2
1
1
1
1
1
1
1
0
1
1
1
0
1
0
2
0
1
1
0
0
1
2
2
2
0
1
0
1
1
0
1
2
1
2
0
2
1
1
...

output:

0 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 311 31...

result:

ok Accepted

Test #41:

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

input:

999
0
2
2
1
2
1
1
1
1
0
2
1
1
2
1
1
0
0
2
0
2
1
1
1
1
1
2
1
1
2
2
0
1
0
2
2
2
1
1
0
1
2
0
0
1
2
0
1
1
1
0
0
0
1
1
2
1
1
2
0
1
1
0
1
2
0
1
0
2
1
1
1
1
0
1
2
1
1
1
2
0
0
1
0
0
1
2
1
2
0
1
1
1
1
1
1
2
2
2
1
0
1
0
1
2
1
1
2
1
2
0
2
1
1
2
1
1
2
0
2
1
2
1
1
2
1
2
1
0
0
0
2
1
0
1
2
1
1
2
1
2
1
1
2
1
1
1
0
...

output:

0 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 664 66...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed