QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#622694#9432. PermutationLegend_dy#AC ✓258ms4556kbC++202.7kb2024-10-09 00:12:282024-10-09 00:12:29

Judging History

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

  • [2024-10-09 00:12:29]
  • 评测
  • 测评结果:AC
  • 用时:258ms
  • 内存:4556kb
  • [2024-10-09 00:12:28]
  • 提交

answer

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout<<#x"="<<x<<' '

using namespace std;
typedef long long ll;

int n;
int P[1005];
int query_cnt;
int force(const vector<int>&a) {
    query_cnt++;
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += P[i] == a[i];
    return ans;
}

int ask(const vector<int>&a) {
    // return force(a);
    cout << 0;
    for (int i = 1; i <= n; i++) cout << ' ' << a[i];
    cout << endl;
    int x;
    cin >> x;
    return x;
}
int p[1005];

void solve(int l, int r, vector<int> a) {
    if (l == r) {
        p[l] = a[0];
        return;
    }
    random_shuffle(a.begin(), a.end());

    vector<int> L, R;
    int mid = l + r >> 1;

    auto Ask = [&](int x, int y) -> int {
        vector<int> v(n + 1);
        for (int i = 1; i < l; i++) v[i] = a[0];
        for (int i = l; i <= mid; i++) v[i] = x;
        for (int i = mid + 1; i <= r; i++) v[i] = y;
        for (int i = r + 1; i <= n; i++) v[i] = a[0];
        int t = ask(v);
        return t;
    };
    
    vector<vector<int>> g(n + 1);
    for (int i = 1; i <= n; i++) g[i].push_back(i);

    while (a.size() > 1) {
        if (L.size() == (mid - l + 1)) break;
        if (R.size() == (r - mid)) break;
        vector<int> na;
        int len = a.size();
        for (int i = 1; i < len; i += 2) {
            int x = a[i - 1];
            int y = a[i];
            int ans = Ask(x, y);
            if (ans == 0) {
                for (int t : g[x]) R.push_back(t);
                for (int t : g[y]) L.push_back(t);
            }else if (ans == 2) {
                for (int t : g[x]) L.push_back(t);
                for (int t : g[y]) R.push_back(t);
            }else {
                for (int t : g[y]) g[x].push_back(t);
                na.push_back(x);
            }
        }
        if (a.size() % 2) na.push_back(a.back());
        a = na;
    }
    if (a.size()) {
        if (L.size() != (mid - l + 1)) {
            for (int x : a) for (int t : g[x]) L.push_back(t);
        }
        if (R.size() != (r - mid)) {
            for (int x : a) for (int t : g[x]) R.push_back(t);
        }
    }

    solve(l, mid, L);
    solve(mid + 1, r, R);
}

int main() {
    fastio;
    srand(time(0));
    cin >> n;
    // iota(P + 1, P + n + 1, 1);

    vector<int> a(n);
    iota(a.begin(), a.end(), 1);
    solve(1, n, a);

    // cout << query_cnt << '\n';;
    // int ans = 0;
    // for (int i = 1; i <= n; i++) ans += (p[i] != i);
    // cout << ans;
    cout << 1;
    for (int i = 1; i <= n; i++) cout << ' ' << p[i];

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2
0
2
2
2

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 862 86...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
2

output:

0 2 1
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
1
2
0

output:

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

result:

ok Accepted

Test #6:

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

input:

4
2
0
0
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
1
2
0
2
0
0
2

output:

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

result:

ok Accepted

Test #8:

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

input:

7
1
1
0
0
2
2
0
0
0
2

output:

0 5 5 5 5 6 6 6
0 2 2 2 2 3 3 3
0 4 4 4 4 1 1 1
0 5 5 5 5 2 2 2
0 7 7 1 1 7 7 7
0 3 3 2 2 7 7 7
0 7 3 7 7 7 7 7
0 1 1 1 2 1 1 1
0 4 4 4 4 4 4 5
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: 0ms
memory: 3684kb

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 733 73...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 533 53...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 5...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 225ms
memory: 4276kb

input:

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

output:

0 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 933 93...

result:

ok Accepted

Test #21:

score: 0
Accepted
time: 217ms
memory: 4280kb

input:

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

output:

0 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 424 42...

result:

ok Accepted

Test #22:

score: 0
Accepted
time: 239ms
memory: 4288kb

input:

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

output:

0 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 758 75...

result:

ok Accepted

Test #23:

score: 0
Accepted
time: 210ms
memory: 4252kb

input:

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

output:

0 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 280 28...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 243ms
memory: 4352kb

input:

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

output:

0 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 234 23...

result:

ok Accepted

Test #25:

score: 0
Accepted
time: 214ms
memory: 4232kb

input:

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

output:

0 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 54...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 241ms
memory: 4256kb

input:

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

output:

0 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 263 26...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 209ms
memory: 4284kb

input:

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

output:

0 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 919 91...

result:

ok Accepted

Test #28:

score: 0
Accepted
time: 210ms
memory: 4284kb

input:

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

output:

0 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 523 52...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 590 59...

result:

ok Accepted

Test #30:

score: 0
Accepted
time: 211ms
memory: 4296kb

input:

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

output:

0 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 889 88...

result:

ok Accepted

Test #31:

score: 0
Accepted
time: 236ms
memory: 4224kb

input:

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

output:

0 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 8...

result:

ok Accepted

Test #32:

score: 0
Accepted
time: 234ms
memory: 4288kb

input:

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

output:

0 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 451 45...

result:

ok Accepted

Test #33:

score: 0
Accepted
time: 238ms
memory: 4324kb

input:

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

output:

0 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 880 88...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 548 54...

result:

ok Accepted

Test #35:

score: 0
Accepted
time: 236ms
memory: 4220kb

input:

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

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 #36:

score: 0
Accepted
time: 229ms
memory: 4228kb

input:

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

output:

0 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 859 85...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 238ms
memory: 4288kb

input:

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

output:

0 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 2...

result:

ok Accepted

Test #38:

score: 0
Accepted
time: 233ms
memory: 4232kb

input:

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

output:

0 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 143 14...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 266 26...

result:

ok Accepted

Test #40:

score: 0
Accepted
time: 233ms
memory: 4292kb

input:

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

output:

0 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 677 67...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 12...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed