QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#607651#9432. Permutationucup-team4435#AC ✓260ms3884kbC++203.9kb2024-10-03 15:41:462024-10-03 15:41:46

Judging History

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

  • [2024-10-03 15:41:46]
  • 评测
  • 测评结果:AC
  • 用时:260ms
  • 内存:3884kb
  • [2024-10-03 15:41:46]
  • 提交

answer

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define each(x, a) for (auto &x : a)
#define ar array
#define vec vector
#define range(i, n) rep(i, n)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;

using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pair<int, int>>;
using vvi = vector<vi>;

int Bit(int mask, int b) { return (mask >> b) & 1; }

template<class T>
bool ckmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool ckmax(T &a, const T &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

// [l, r)
template<typename T, typename F>
T FindFirstTrue(T l, T r, const F &predicat) {
    --l;
    while (r - l > 1) {
        T mid = l + (r - l) / 2;
        if (predicat(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}


template<typename T, typename F>
T FindLastFalse(T l, T r, const F &predicat) {
    return FindFirstTrue(l, r, predicat) - 1;
}


const ll INF = 2e18;
const int INFi = 1e9;
const int N = 30 + 5;
const int LG = 20;

int ask(const vi &a) {
    cout << "0";
    rep(i, a.size()) cout << " " << a[i];
    cout << endl;
    int x; cin >> x;
    return x;
}

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

void solve() {
    int n; cin >> n;
    vi ans(n);
    function<void(int, int, vi&)> rec = [&] (int l, int r, vi &v) {
        if (l >= r) return;
        assert(r - l == (int)v.size());
        if (l + 1 == r)  {
            ans[l] = v[0];
            return;
        }
        int m = (l + r) / 2;
        vi L, R;
        shuffle(all(v), rng);
        vi cur;
        for(auto &x : v) {
            if ((int)L.size() + (int)cur.size() > m - l) {
                for(auto &t : cur) R.push_back(t);
                cur.clear();
            } else if ((int)R.size() + (int)cur.size() > r - m) {
                for(auto &t : cur) L.push_back(t);
                cur.clear();
            }
            if (cur.empty()) {
                cur.push_back(x);
                continue;
            }
            vi perm(n, x);
            for(int i = l; i < m; ++i) perm[i] = cur[0];
            int cnt = ask(perm);
            if (cnt == 0) {
                for(auto &y : cur) R.push_back(y);
                L.push_back(x);
                cur.clear();
                continue;
            }
            if (cnt == 2) {
                for(auto &y : cur) L.push_back(y);
                R.push_back(x);
                cur.clear();
                continue;
            }
            cur.push_back(x);
        }
        assert(!L.empty() || !R.empty());
        if (!cur.empty()) {
            if (L.size() != m - l) {
                for(auto &t : cur) L.push_back(t);
            } else {
                for(auto &t : cur) R.push_back(t);
            }
            cur.clear();
        }
        assert((int)L.size() == m - l);
        assert((int)R.size() == r - m);
        rec(l, m, L);
        rec(m, r, R);
    };
    vi v(n);
    iota(all(v), 1);
    rec(0, n, v);
    cout << "1";
    rep(i, n) cout << " " << ans[i];
    cout << endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(12) << fixed;
    int t = 1;
//    cin >> t;
    rep(i, t) {
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

5
1
1
0
0
0

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 810 81...

result:

ok Accepted

Test #3:

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

input:

1

output:

1 1

result:

ok Accepted

Test #4:

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

input:

2
0

output:

0 1 2
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
1
2

output:

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

result:

ok Accepted

Test #6:

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

input:

4
0
2
2
0

output:

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

result:

ok Accepted

Test #7:

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

input:

6
2
2
0
2
2
1
0

output:

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

result:

ok Accepted

Test #8:

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

input:

7
1
1
1
2
2
2
0
2
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

result:

ok Accepted

Test #10:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 13...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 218 21...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 8...

result:

ok Accepted

Test #20:

score: 0
Accepted
time: 247ms
memory: 3636kb

input:

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

output:

0 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 414 41...

result:

ok Accepted

Test #21:

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

input:

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

output:

0 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 386 38...

result:

ok Accepted

Test #22:

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

input:

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

output:

0 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 301 30...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 529 52...

result:

ok Accepted

Test #24:

score: 0
Accepted
time: 254ms
memory: 3788kb

input:

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

output:

0 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 888 88...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 3...

result:

ok Accepted

Test #26:

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

input:

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

output:

0 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 9...

result:

ok Accepted

Test #27:

score: 0
Accepted
time: 256ms
memory: 3624kb

input:

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

output:

0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 5...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 66...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 185 18...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 24...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 243 24...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 808 80...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 633 63...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 849 84...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 635 63...

result:

ok Accepted

Test #36:

score: 0
Accepted
time: 248ms
memory: 3704kb

input:

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

output:

0 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 721 72...

result:

ok Accepted

Test #37:

score: 0
Accepted
time: 260ms
memory: 3704kb

input:

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

output:

0 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 159 15...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 959 95...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 555 55...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 395 39...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 931 93...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed