QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369722#6303. Inversionucup-team1191#AC ✓100ms6136kbC++205.8kb2024-03-28 17:02:372024-03-28 17:02:38

Judging History

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

  • [2024-03-28 17:02:38]
  • 评测
  • 测评结果:AC
  • 用时:100ms
  • 内存:6136kb
  • [2024-03-28 17:02:37]
  • 提交

answer

/*
    author:  Maksim1744
    created: 28.03.2024 11:46:49
*/

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T> &v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T> &v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T> &v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>  v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> pair<T,U>& operator--           (pair<T, U> &p){--p.first; --p.second;            return  p;}
template<typename T, typename U> pair<T,U>& operator++           (pair<T, U> &p){++p.first; ++p.second;            return  p;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U> &p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>  p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define SHOW_COLORS
#include "/mnt/c/Libs/tools/print.cpp"
#else
#define show(...) void(0)
#define debugf(fun)   fun
#define debugv(var)   var
#define mclock    void(0)
#define shows     void(0)
#define debug  if (false)
#define OSTREAM(...)    ;
#define OSTREAM0(...)   ;
#endif

// #define INTERACT

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rng(4783682);
ll rnd (ll l, ll r) { return (ll)(rng() % (r - l + 1)) + l; }
ll rnd (ll r)       { return rng() % r; }
ll rnd ()           { return rng(); }
ld rndf()           { return (ld)rng() / (ld)ULLONG_MAX; }
ld rndf(ld l, ld r) { return rndf() * (r - l) + l; }

template<typename T>
struct fenwick {
    vector<T> tree;
    int n;
    int K;

    fenwick(int n = 0) : n(n) {
        tree.assign(n, 0);
        K = 0;
        while ((1 << K) <= n)
            ++K;
    }

    void add(int i, T k) {
        for (; i < n; i = (i | (i + 1)))
            tree[i] += k;
    }

    T ask(int r) {
        T res = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            res += tree[r];
        return res;
    }

    T ask(int l, int r) {
        if (l > r) return 0;
        return ask(r) - ask(l - 1);
    }

    // find first i such that sum[0..i] >= x
    int lower_bound(T x) {
        int cur = 0;
        T cur_sum = 0;
        for (int k = K - 1; k >= 0; --k) {
            int ind = cur | ((1 << k) - 1);
            if (ind >= n) continue;
            if (cur_sum + tree[ind] >= x) continue;
            cur_sum += tree[ind];
            cur |= (1 << k);
        }
        return cur;
    }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n;
    #ifdef INTERACT
    n = 2000;
    #else
    cin >> n;
    #endif
    vector<int> invs_left(n);

    #ifdef INTERACT
    vector<int> p0(n);
    iota(p0.begin(), p0.end(), 1);
    shuffle(p0.begin(), p0.end(), rng);
    fenwick<int> tree(n);
    #endif

    map<pair<int, int>, int> mem;
    int que = 0;
    auto ask = [&](int i, int j) {
        assert(i <= j);
        if (i == j) return 0;
        if (mem.count({i, j})) return mem[{i, j}];
        ++que;
        int ans = 0;

        #ifdef INTERACT
        for (int k = i; k <= j; ++k) {
            ans += tree.ask(p0[k]-1, n-1);
            tree.add(p0[k]-1, 1);
        }
        for (int k = i; k <= j; ++k) {
            tree.add(p0[k]-1, -1);
        }
        #else
        cout << "? " << i + 1 << ' ' << j + 1 << endl;
        cin >> ans;
        #endif
        return mem[{i, j}] = ans;
    };

    vector<int> cur = {0};
    for (int i = 1; i < n; ++i) {
        shows;
        show(cur);
        auto cmp = [&](int i, int j) {
            int a = ask(i, j);
            int b = ask(i + 1, j);
            show(i, j, b, a, invs_left[i]);
            if ((b ^ a ^ invs_left[i]) % 2) {
                return false;
            } else {
                return true;
            }
        };

        int l = 0, r = cur.size();
        while (l != r) {
            int m = (l + r) / 2;
            if (cmp(cur[m], i)) {
                l = m + 1;
            } else {
                r = m;
            }
        }
        for (int j = l; j < cur.size(); ++j) {
            invs_left[cur[j]]++;
        }
        cur.insert(cur.begin() + l, i);
    }
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        p[cur[i]] = i + 1;
    }
    #ifdef INTERACT
    if (p != p0) {
        cout << "ans: " << p0 << endl;
        cout << "out: " << p << endl;
        assert(false);
    }
    #endif
    cout << "! " << p << endl;
    #ifdef INTERACT
    cout << "que: " << que << endl;
    #endif

    return 0;
}

詳細信息

Test #1:

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

input:

3
0
1
0

output:

? 1 2
? 2 3
? 1 3
! 2 3 1 

result:

ok OK, guesses=3

Test #2:

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

input:

1993
0
0
0
0
0
1
1
0
0
0
0
0
1
0
1
0
0
1
0
0
1
1
0
1
0
1
1
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1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11
? 6 11
? 9 11
? 10 11
? 8 11
? 7 11
? 5 12
? 6 12
? 3 12
? 4 12
? 7 12
? 8 12
? 5 13
? 6 ...

result:

ok OK, guesses=35504

Test #4:

score: 0
Accepted
time: 49ms
memory: 5848kb

input:

1882
1
1
0
0
0
1
1
0
0
0
1
1
0
0
0
1
1
1
1
1
1
0
1
1
0
1
1
1
1
0
1
1
1
0
1
0
0
0
0
1
0
1
1
1
1
0
1
0
1
1
1
1
1
0
0
1
1
0
0
0
0
1
1
1
1
1
0
0
0
1
1
1
0
0
1
0
1
1
0
1
0
1
1
1
0
0
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
1
0
0
1
1
0
1
0
0
0
1
0
0
0
0
1
1
0
1
0
0
0
1
1
1
1
1
1
0
1
1...

output:

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

result:

ok OK, guesses=35493

Test #5:

score: 0
Accepted
time: 34ms
memory: 5804kb

input:

1877
0
1
0
1
0
0
1
1
1
0
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
1
1
1
0
0
1
0
1
1
1
0
0
0
0
1
1
1
1
1
1
0
0
1
1
0
0
1
0
0
1
1
1
0
1
1
1
0
0
0
1
0
1
1
0
0
1
1
0
0
1
1
0
0
0
0
0
1
1
0
1
0
0
0
0
1
0
0
0
0
1
0
1
0
0
0
1
0
1
0
1
1
1
1
0
0
0
0
1
0
0
1
1
1
1
0
1
0
1
1
1
1
0
0
1
1
1
1...

output:

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

result:

ok OK, guesses=35268

Test #6:

score: 0
Accepted
time: 48ms
memory: 6024kb

input:

1871
1
0
0
1
0
1
0
1
0
0
0
0
1
1
1
0
0
0
1
0
1
0
1
0
1
1
1
0
1
0
0
1
1
1
1
0
0
1
0
1
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
1
0
0
1
0
1
0
1
1
1
1
0
1
0
0
0
1
0
1
0
1
0
0
1
1
1
0
1
1
0
1
1
1
0
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
0
0
1
1
1
1
0
1
0
1
1
0
0
1
0
1
0
1
0
1
0
0
1
1
1
1
0
1
1
0
0
1
0
0
0
1
1
1
0
1
1
0...

output:

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

result:

ok OK, guesses=35190

Test #7:

score: 0
Accepted
time: 34ms
memory: 5876kb

input:

1994
0
0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 8
? 2 8
? 5 8
? 6 8
? 7 9
? 8 9
? 3 9
? 4 9
? 2 9
? 7 10
? 8 10
? 3 10
? 4 10
? 6 10
? 2 11
? 3 11
? 10 11
? 6 11
? 7 11
? 2 12
? 3 12
? 10 12
? 11 12
? 9 13
? 10 13
? 6 13
? 7 13
? 11 13
? 3 13...

result:

ok OK, guesses=34429

Test #9:

score: 0
Accepted
time: 54ms
memory: 5780kb

input:

1981
1
0
0
1
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
0
0
0
1
0
0
1
0
1
0
0
1
0
0
1
0
1
0
0
1
0
1
0
1
0
1
0
1
1
0
1
0
1
1
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
0
1
0
1
1
0
0
0
0
0
0
1
1
0
0
1
0
0
1
0
1
0
0
1
0
1
1
0
1
0
1
1
1
1
1
0
1
0
0
0
1
1
1
0
0
1
1
1
0
1
0
0
1
0
1
1
1
1
0
0
1...

output:

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

result:

ok OK, guesses=35836

Test #10:

score: 0
Accepted
time: 53ms
memory: 5932kb

input:

1988
0
1
1
0
0
1
0
0
1
0
1
1
1
1
1
1
1
0
1
0
0
1
1
1
0
1
1
1
1
1
1
0
0
0
0
1
1
0
1
0
0
0
1
1
0
0
1
1
1
0
0
1
0
0
0
0
1
1
0
0
0
0
1
1
0
1
1
0
1
1
1
0
0
0
0
0
1
0
0
1
1
0
0
1
1
0
1
1
1
0
1
1
0
0
1
0
1
1
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
0
0
1
1
1
0
0
0
0
0
1
1
1
1
0
1
1
1
0
1
1
1
0
1
0
1
0
0
0
1
1
1
1
0...

output:

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

result:

ok OK, guesses=36564

Test #11:

score: 0
Accepted
time: 50ms
memory: 6020kb

input:

1991
0
1
1
0
0
1
1
1
0
1
0
0
1
0
0
1
0
1
0
0
0
1
0
1
0
0
0
1
1
1
0
0
1
0
0
0
1
1
1
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
1
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
1
1
0
0
0
1
1
0
0
0
0
0
1
0
1
0
1
0
0
1
1
0
0
0
1
0
1
1
0
0
1
0
1
1
1
0
1
0
1
1
0
0
1
1
0
0
1
0
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
0
1
1
0
1
1
1
1
0
0
1
1
0
1
1...

output:

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

result:

ok OK, guesses=37509

Test #12:

score: 0
Accepted
time: 67ms
memory: 6032kb

input:

1996
0
1
0
1
0
0
0
1
0
0
0
0
0
1
1
0
1
0
1
1
1
1
1
0
1
1
0
1
0
0
1
1
1
1
0
0
0
1
1
1
0
0
0
1
1
1
0
0
0
1
1
1
1
0
1
1
1
0
1
0
0
0
1
0
1
0
0
0
0
0
1
0
1
1
1
1
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
0
1
1
0
1
0
0
0
1
0
1
1
1
1
1
1
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
1
1
0
1
1...

output:

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

result:

ok OK, guesses=37902

Test #13:

score: 0
Accepted
time: 22ms
memory: 5992kb

input:

1992
1
1
1
1
1
0
1
1
0
1
1
0
0
1
1
0
0
1
1
1
0
0
1
1
1
0
0
1
1
1
1
0
1
1
1
1
0
1
1
0
1
0
0
1
1
0
1
0
0
1
1
0
0
0
0
1
1
0
0
0
0
1
1
1
0
1
0
0
1
1
1
0
1
0
0
1
1
1
1
1
0
0
1
1
1
1
1
0
0
1
1
0
1
1
1
0
1
1
0
1
1
1
0
1
1
0
0
1
1
0
1
1
0
0
1
1
0
1
1
1
0
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
0
1
0
0
1
1
1
1
0
1
0...

output:

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

result:

ok OK, guesses=34727

Test #14:

score: 0
Accepted
time: 19ms
memory: 5852kb

input:

1988
1
0
0
1
0
1
0
1
0
1
1
0
0
0
0
0
1
1
1
1
0
1
0
0
1
1
0
1
0
1
0
1
0
0
0
0
0
1
0
1
1
1
1
0
1
0
1
0
1
1
1
1
1
1
0
1
1
0
0
1
0
1
1
1
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
1
0
1
0
1
0
0
1
0
0
1
0
1
1
1
1
1
1
1
1
0
0
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
0
1
1
1
1
1
1
0
0
1
0
1
0
1
0
0
1
0
0
0
0
1
1
0
0
0
0
1
0
0
0...

output:

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

result:

ok OK, guesses=35654

Test #15:

score: 0
Accepted
time: 29ms
memory: 6000kb

input:

1983
1
1
1
0
0
0
0
1
0
1
1
1
1
1
0
1
0
0
0
1
1
0
1
1
1
1
1
1
1
0
0
0
1
0
0
0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
? 7 9
? 5 10
? 6 10
? 1 10
? 2 10
? 9 10
? 7 10
? 10 11
? 8 11
? 9 11
? 7 11
? 2 11
? 3 11
? 5 12
? 6 12
? 7 12
? 8 12
? 4 12
? 5 13
? 6 1...

result:

ok OK, guesses=37249

Test #17:

score: 0
Accepted
time: 45ms
memory: 6068kb

input:

1989
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
1
1
1
1
1
1
0
1
1
0
1
0
1
0
0
0
1
1
0
0
0
0
0
1
1
1
1
1
1
0
1
0
1
0
1
1
1
1
0
1
0
1
0
0
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
1
0
1
0
0
1
0
1
0
0
1
0
1
1
1
0
0
1
1
1
0
0
0
1
0
0
0
1
0
1
1
1
0
1
1
0
1
0
0
0
0
0
1
1
0
0
0
1
0
0
0
1
0
1
1
1...

output:

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

result:

ok OK, guesses=37619

Test #18:

score: 0
Accepted
time: 71ms
memory: 5956kb

input:

1998
0
1
0
0
0
0
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
1
0
0
1
1
0
1
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
1
1
0
0
1
0
0
0
0
0
1
1
1
1
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
1
1
0
1
0
1
0
0
0
0
1
0
0
0
0
0
1
0
1
1
0
1
0
1
0
1
1
1
1
0
0
1
0
1
0
1
1
1
1
0
1
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
0
0
1
1
1
0...

output:

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

result:

ok OK, guesses=37920

Test #19:

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

input:

1

output:

! 1 

result:

ok OK, guesses=0

Test #20:

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

input:

2
0

output:

? 1 2
! 1 2 

result:

ok OK, guesses=1

Test #21:

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

input:

2
1

output:

? 1 2
! 2 1 

result:

ok OK, guesses=1

Test #22:

score: 0
Accepted
time: 84ms
memory: 5968kb

input:

1997
1
1
0
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok OK, guesses=33724

Test #23:

score: 0
Accepted
time: 60ms
memory: 5696kb

input:

1998
1
1
0
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok OK, guesses=33745

Test #24:

score: 0
Accepted
time: 43ms
memory: 5680kb

input:

1999
1
1
0
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok OK, guesses=33763

Test #25:

score: 0
Accepted
time: 40ms
memory: 5920kb

input:

2000
1
1
0
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok OK, guesses=33784