QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601542#9432. PermutationSorahISAAC ✓301ms3868kbC++2313.4kb2024-09-30 05:07:342024-09-30 05:07:35

Judging History

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

  • [2024-09-30 05:07:35]
  • 评测
  • 测评结果:AC
  • 用时:301ms
  • 内存:3868kb
  • [2024-09-30 05:07:34]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

void solve() {
    int N; cin >> N;
    
#ifdef duipai
    vector<int> ANSWER(N); iota(ALL(ANSWER), 1);
    shuffle(ALL(ANSWER), rng);
#endif
    
    vector<int> pos(N+1, 0), guess(N);
    
    int n_operation = 0;
    auto query = [&](bool answer = false) -> optional<int> {
        ++n_operation;
#ifdef duipai
        int _n_match = 0;
        for (int i = 0; i < N; ++i) _n_match += (guess[i] == ANSWER[i]);
        if (!answer) return _n_match;
        debug(N, _n_match);
#else
        cout << (answer ? 1 : 0) << " ";
        copy(ALL(guess), experimental::make_ostream_joiner(cout, " "));
        cout << "\n" << flush;
        if (!answer) {
            int ret; cin >> ret;
            return ret;
        }
#endif
        debug(n_operation);
        return nullopt;
    };
    
    if (N <= 3) {
        iota(ALL(guess), 1);
        do {
            if (query().value() == N) { query(true); break; }
        } while (next_permutation(ALL(guess)));
        return;
    }
    
    vector<int> perm(N); iota(ALL(perm), 1);
    for (int b = __lg(N-1); b >= 1; --b) {
        shuffle(ALL(perm), rng);
        
        int i = 0, lst = 0;
        while (i+1 < N) {
            for (int j = 0; j < N; ++j) guess[j] = perm[i + (j >> b & 1)];
            int ret = query().value();
            if (ret == 0) {
                for (int p = i+0; p >= lst; --p) {
                    pos[perm[p]] |= (1 << b);
                    // debug("known"s, perm[p]);
                }
                lst = (i += 2);
            }
            if (ret == 2) {
                pos[perm[i+1]] |= (1 << b);
                // debug("known"s, perm[i+1]);
                lst = (i += 2);
            }
            if (ret == 1) {
                ++i;
            }
        }
        if (i == N-1) {
            for (int j = 0; j < N; ++j) guess[j] = perm[((j >> b & 1) ? (N-1) & 1 : N-1)];
            int ret = query().value();
            if (ret == 0) {
                for (int p = N-1; p >= lst; --p) {
                    pos[perm[p]] |= (1 << b);
                    // debug("known"s, perm[p]);
                }
            }
            if (ret == 2) {
                /// nothing
            }
            if (ret == 1) {
                for (int p = N-1; p >= lst; --p) {
                    pos[perm[p]] |= ((pos[perm[(N-1)&1]] >> b & 1) << b);
                    // debug("known"s, perm[p]);
                }
            }
        }
        // debug(pos);
    }
    
    for (int i = 0; i+1 < N; i += 2) {
        vector<int> val;
        for (int p = 0; p < N; ++p) { if (pos[perm[p]] == i) val.eb(p); }
        assert(SZ(val) == 2);
        fill(ALL(guess), perm[val[0]]);
        guess[i+1] = perm[val[1]];
        if (query().value() == 2) ++pos[perm[val[1]]];
        else                      ++pos[perm[val[0]]];
    }
    // debug(pos);
    
    for (int i = 1; i <= N; ++i) guess[pos[i]] = i;
    
    query(true);
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <experimental/iterator>
using namespace std;
// #include <bits/extc++.h>
// #include <tr2/dynamic_bitset>

using i64 = long long;
using i128 = __int128;
#define int i64
using f80 = long double;
using f128 = __float128;
#define double f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

// template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
//     static_assert(D >= 1, "Vector dimension must be greater than zero!");
//     template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
// };

// template <typename T> struct Vec<1, T> : vector<T> {
//     Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
// };

#ifdef local
#define fastIO() void()
#define debug(...) \
    _color.emplace_back("\u001b[31m"), \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), _color.pop_back(), \
    fprintf(stderr, "%s", _color.back().c_str())
#define print(...) \
    fprintf(stdout, "%s", "\u001b[36m"), \
    _P(__VA_ARGS__), \
    fprintf(stdout, "%s", "\u001b[0m")

deque<string> _color{"\u001b[0m"};

template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) { begin(_t); };

template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);

inline void _do() { cerr << "\n"; }
template <typename T> inline void _do(T &&_t) { _print_err(_t), cerr << "\n"; }
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) { _print_err(_t), cerr << ", ", _do(_u...); }
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#define print(...) _P(__VA_ARGS__)
#endif

inline void _P() { cout << "\n"; }
template <typename T> inline void _P(T &&_t) { cout << _t << "\n"; }
template <typename T, typename ...U> inline void _P(T &&_t, U &&..._u) { cout << _t << " ", _P(_u...); }

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

inline int getRand(int L, int R) {
    if (L > R) swap(L, R);
    return (int)(rng() % ((uint64_t)R - L + 1) + L);
}

template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }

/// below are Fast I/O and _print_err templates ///

/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///

#include <unistd.h>

const int S = 65536;

int OP = 0;
char OB[S];

inline char RC() {
    static char buf[S], *p = buf, *q = buf;
    return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}

inline int RI() {
    static char c;
    int a;
    while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
    if (c == '-') {
        a = 0;
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
    }
    else {
        a = c ^ '0';
        while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
    }
    return a;
}

inline void WI(int n, char c = '\n') {
    static char buf[20], p;
    if (n == 0) OB[OP++] = '0';
    p = 0;
    if (n < 0) {
        OB[OP++] = '-';
        while (n) buf[p++] = '0' - (n % 10), n /= 10;
    }
    else {
        while (n) buf[p++] = '0' + (n % 10), n /= 10;
    }
    for (--p; p >= 0; --p) OB[OP++] = buf[p];
    OB[OP++] = c;
    if (OP > S-20) write(1, OB, OP), OP = 0;
}

/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/

#ifdef local

template <typename T> inline void _print_err(T &&_t) { cerr << _t; }

template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "[";
    for (bool _first = true; auto &_x : _t) {
        if (!_first) cerr << ", ";
        _print_err(_x), _first = false;
    }
    cerr << "]" << (_color.pop_back(), _color.back());
}

template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
    string _tmp_color = _color.back();
    ++_tmp_color[3], _color.emplace_back(_tmp_color);
    cerr << _color.back() << "(";
    _print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
    cerr << ")" << (_color.pop_back(), _color.back());
    return os;
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
    cerr << ")" << (_color.pop_back(), _color.back());
}

template <size_t I = 0, typename ...U> inline typename enable_if<I <  sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
    if (!I) {
        string _tmp_color = _color.back();
        ++_tmp_color[3], _color.emplace_back(_tmp_color);
        cerr << _color.back();
    }
    cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}

#endif

#endif

/**
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
 *                            iiiiii         iiiiiiiiii       iiiiiiiiiiiiii                                       
 *                       iiiiiiiiiiiii   iiiiiii    iiii    iiiiiiiiiiiiiii                          ii   iiii     
 *                    iiiiiiii     iiiiiiiii         iiii       iiii iii              iii          iiiiiiiiii      
 *                 iiiiiii          iiiiii           iiii    iiii   ii           iiiiiiiiii      iiii iiii         
 *               iiiiii            iiiii             iiii iiii        iii      iiii    iiiiiiiiiiiiiiiii  ii       
 *             iiiiii            iiiiiii            iiiiiii       iiiiiiii   iii    iiiiiiiiiiiiii iii  iiii       
 *           iiiiii             iiiiiii            iiiii   ii   iiii       iiiiiiiiiii iiii  iii iiii iiii      iii
 *          iiiii              iiiiiiii       ii        iiiii iiii    iiiiiiiii        iii iii  iii  iii  ii  iiii 
 *        iiiiii              iiiiiiii      iiiii     iiiii iiiiiiiiiiiiiiii         iii  iii  ii  iii  iii iiii   
 *       iiiii                 iiiiii     iiii     iiiiii iiiiiii    iii iii       iiii  ii   i   ii  iii  iii     
 *     iiiiii                            iiii  iiiiiiiiiiiiiii       iii iiii   iiiii  iii  ii  iii  iii  ii       
 *    iiiii                              iiiiiiii iiiiiiiiii       iiii   iiiiiiiii            ii  iii  ii         
 *   iiiii                                     iiiiii  iiii      iiiii              iii      ii   ii  i            
 * iiiiii                                  iiiiiiii   iiiii    iiiii                        ii  ii   ii            
 * iiiii                                iiii  iiii    iiiiiiiiiiii                             ii                  
 *  iii                              iiii   iiii       iiiiiiii                                                    
 *                                iiiii   iiii                                                                     
 *                              iiii     iiii                                                                      
 *                            iiii    iiiii                                                                        
 *                          iii     iiiii                                                                          
 *                        iii     iiiii                                                                            
 *                       iii   iiiiii                                                                              
 *                       iiiiiiiii                                                                                 
 *                       iiiiii                                                                                    
 *                                                                                                                 
 *                                                                                                                 
 *                                                                                                                 
**/

详细

Test #1:

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

input:

5
1
2
1
1
2
2
1
2
2

output:

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

result:

ok Accepted

Test #2:

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

input:

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

output:

0 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 226 22...

result:

ok Accepted

Test #3:

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

input:

1
1

output:

0 1
1 1

result:

ok Accepted

Test #4:

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

input:

2
0
2

output:

0 1 2
0 2 1
1 2 1

result:

ok Accepted

Test #5:

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

input:

3
0
1
1
0
3

output:

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

result:

ok Accepted

Test #6:

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

input:

4
1
2
0
0
2

output:

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

result:

ok Accepted

Test #7:

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

input:

6
1
1
2
2
2
1
1
2
2
0
2

output:

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

result:

ok Accepted

Test #8:

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

input:

7
0
1
1
2
1
2
0
1
2
0
2
0

output:

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

result:

ok Accepted

Test #9:

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

input:

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

output:

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

input:

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

output:

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

result:

ok Accepted

Test #11:

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

input:

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

output:

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

result:

ok Accepted

Test #12:

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

input:

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

output:

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

result:

ok Accepted

Test #13:

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

input:

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

output:

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

result:

ok Accepted

Test #14:

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

input:

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

output:

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

result:

ok Accepted

Test #15:

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

input:

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

output:

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

result:

ok Accepted

Test #16:

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

input:

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

output:

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

result:

ok Accepted

Test #17:

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

input:

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

output:

0 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 685 68...

result:

ok Accepted

Test #18:

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

input:

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

output:

0 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 20...

result:

ok Accepted

Test #19:

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

input:

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

output:

0 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 124 12...

result:

ok Accepted

Test #20:

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

input:

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

output:

0 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 135 13...

result:

ok Accepted

Test #21:

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

input:

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

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

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

input:

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

output:

0 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 3...

result:

ok Accepted

Test #23:

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

input:

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

output:

0 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 5...

result:

ok Accepted

Test #24:

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

input:

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

output:

0 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 1...

result:

ok Accepted

Test #25:

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

input:

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

output:

0 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 179 17...

result:

ok Accepted

Test #26:

score: 0
Accepted
time: 292ms
memory: 3572kb

input:

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

output:

0 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 532 53...

result:

ok Accepted

Test #27:

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

input:

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

output:

0 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 726 72...

result:

ok Accepted

Test #28:

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

input:

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

output:

0 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 9...

result:

ok Accepted

Test #29:

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

input:

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

output:

0 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 785 78...

result:

ok Accepted

Test #30:

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

input:

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

output:

0 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 499 49...

result:

ok Accepted

Test #31:

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

input:

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

output:

0 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 396 39...

result:

ok Accepted

Test #32:

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

input:

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

output:

0 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 60 6...

result:

ok Accepted

Test #33:

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

input:

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

output:

0 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 872 87...

result:

ok Accepted

Test #34:

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

input:

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

output:

0 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 850 85...

result:

ok Accepted

Test #35:

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

input:

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

output:

0 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 9...

result:

ok Accepted

Test #36:

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

input:

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

output:

0 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 829 82...

result:

ok Accepted

Test #37:

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

input:

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

output:

0 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 6...

result:

ok Accepted

Test #38:

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

input:

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

output:

0 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 379 37...

result:

ok Accepted

Test #39:

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

input:

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

output:

0 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 1...

result:

ok Accepted

Test #40:

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

input:

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

output:

0 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 781 78...

result:

ok Accepted

Test #41:

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

input:

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

output:

0 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 411 41...

result:

ok Accepted

Extra Test:

score: 0
Extra Test Passed