QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#597885#9432. Permutationucup-team296#AC ✓283ms3896kbC++143.3kb2024-09-28 19:18:032024-09-28 19:18:03

Judging History

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

  • [2024-09-28 19:18:03]
  • 评测
  • 测评结果:AC
  • 用时:283ms
  • 内存:3896kb
  • [2024-09-28 19:18:03]
  • 提交

answer

#include <bits/stdc++.h>
#define long long long int
#define DEBUG
using namespace std;

// @author: pashka

int n;

void init() {
}

int cnt = 0;
int ask(vector<int> q) {
    cout << "0";
    for (int i = 0; i < n; i++) {
        cout << " " << (q[i] + 1);
    }
    cout << endl;
    cnt++;
    assert(cnt <= 6666);
    int s;
    cin >> s;
    return s;
}

void answer(vector<int> q) {
    cout << "1";
    for (int i = 0; i < n; i++) {
        cout << " " << (q[i] + 1);
    }
    cout << endl;
}

//void init() {
//    p.resize(n);
//    for (int i = 0; i < n; i++) {
//        p[i] = i;
//        int j = rand() % (i + 1);
//        swap(p[i], p[j]);
//    }
//}
//
//int cnt = 0;
//int ask(vector<int> q) {
//    int s = 0;
//    for (int i = 0; i < n; i++) {
//        if (p[i] == q[i]) s++;
//    }
//    cnt++;
//    return s;
//}
//
//void answer(vector<int> q) {
//    for (int i = 0; i < n; i++) assert(p[i] == q[i]);
//    cout << cnt << "\n";
//}

vector<int> ans;

int ask(int l, int m, int r, int c1, int c2) {
    vector<int> q(n);
    for (int i = 0; i < n; i++) {
        if (i < l || i >= r) q[i] = c1;
        else if (i < m) q[i] = c1;
        else q[i] = c2;
    }
    return ask(q);
}

void add_all(vector<int> &a, vector<int> &b) {
    a.insert(a.end(), b.begin(), b.end());
}

void go(int l, int r, vector<int> a) {
    if (r - l == 1) {
        ans[l] = a[0];
        return;
    }
    int m = (l + r) / 2;
    if (r - l == 2) {
        ans[l] = a[0];
        ans[l + 1] = a[1];
        if (ask(l, m, r, a[0], a[1]) == 0) {
            swap(ans[l], ans[l + 1]);
        }
        return;
    }
    if (r - l == 3) {
        int t = ask(l, m, r, a[0], a[1]);
        int f = (t + 1) % 3;
        ans[l] = a[f];
        go(m, r, {a[(f + 1) % 3], a[(f + 2) % 3]});
        return;
    }
    vector<vector<int>> aa;
    for (int x : a) {
        aa.push_back({x});
    }
    vector<int> al;
    vector<int> ar;
    while (!aa.empty()) {
        if ((int)al.size() == m - l) {
            for (auto &t : aa) {
                add_all(ar, t);
            }
            break;
        }
        if ((int)ar.size() == r - m) {
            for (auto &t : aa) {
                add_all(al, t);
            }
            break;
        }
        vector<vector<int>> aaa;
        while (aa.size() >= 2) {
            auto x = aa.back();
            aa.pop_back();
            auto y = aa.back();
            aa.pop_back();
            int t = ask(l, m, r, x[0], y[0]);
            if (t == 0) {
                add_all(al, y);
                add_all(ar, x);
            } else if (t == 2) {
                add_all(al, x);
                add_all(ar, y);
            } else {
                add_all(x, y);
                aaa.push_back(x);
            }
        }
        if (!aa.empty()) {
            aaa.push_back(aa.back());
        }
        aa = aaa;
    }
    go(l, m, al);
    go(m, r, ar);
}

int main() {
    ios::sync_with_stdio(false);

    cin >> n;

    init();
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = i;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    shuffle(a.begin(), a.end(), rng);
    ans.resize(n);
    go(0, n, a);

    answer(ans);

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

5
1
2
2
2
1
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 276 27...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
1
0
2
0

output:

0 3 3 4 4
0 1 1 2 2
0 1 1 3 3
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: 3556kb

input:

6
1
1
2
2
0
0
0
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
0
2
1
0
0
2
0
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

score: 0
Accepted
time: 276ms
memory: 3644kb

input:

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

output:

0 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 478 47...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 652 65...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 599 59...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 258ms
memory: 3856kb

input:

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

output:

0 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 405 40...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 264ms
memory: 3596kb

input:

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

output:

0 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 407 40...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 7...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 6...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 141 14...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 258ms
memory: 3600kb

input:

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

output:

0 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 393 39...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 594 59...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 263ms
memory: 3600kb

input:

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

output:

0 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 839 83...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 681 68...

result:

ok Accepted

Test #29:

score: 0
Accepted
time: 269ms
memory: 3652kb

input:

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

output:

0 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 659 65...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 856 85...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 676 67...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 640 64...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 257ms
memory: 3644kb

input:

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

output:

0 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 495 49...

result:

ok Accepted

Test #34:

score: 0
Accepted
time: 266ms
memory: 3896kb

input:

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

output:

0 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 748 74...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 272ms
memory: 3892kb

input:

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

output:

0 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 277 27...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 489 48...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 612 61...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 264ms
memory: 3652kb

input:

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

output:

0 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 669 66...

result:

ok Accepted

Test #39:

score: 0
Accepted
time: 279ms
memory: 3856kb

input:

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

output:

0 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 369 36...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 275ms
memory: 3652kb

input:

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

output:

0 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 754 75...

result:

ok Accepted

Test #41:

score: 0
Accepted
time: 283ms
memory: 3652kb

input:

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

output:

0 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 364 36...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed