QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106734#6303. InversionmaspyAC ✓624ms19184kbC++2313.8kb2023-05-19 01:06:222023-05-19 01:06:23

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 01:06:23]
  • 评测
  • 测评结果:AC
  • 用时:624ms
  • 内存:19184kb
  • [2023-05-19 01:06:22]
  • 提交

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) \
  for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sum = 0;
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  assert(!que.empty());
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  assert(!que.empty());
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}
#endif
#line 1 "library/other/io2.hpp"
#define INT(...) \
  int __VA_ARGS__; \
  IN(__VA_ARGS__)
#define LL(...) \
  ll __VA_ARGS__; \
  IN(__VA_ARGS__)
#define STR(...) \
  string __VA_ARGS__; \
  IN(__VA_ARGS__)
#define CHR(...) \
  char __VA_ARGS__; \
  IN(__VA_ARGS__)
#define DBL(...) \
  long double __VA_ARGS__; \
  IN(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void read(int &a) { cin >> a; }
void read(long long &a) { cin >> a; }
void read(char &a) { cin >> a; }
void read(double &a) { cin >> a; }
void read(long double &a) { cin >> a; }
void read(string &a) { cin >> a; }
template <class T, class S> void read(pair<T, S> &p) { read(p.first), read(p.second); }
template <class T> void read(vector<T> &a) {for(auto &i : a) read(i);}
template <class T> void read(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
  read(head);
  IN(tail...);
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& A) {
  os << A.fi << " " << A.se;
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& A) {
  for (size_t i = 0; i < A.size(); i++) {
    if(i) os << " ";
    os << A[i];
  }
  return os;
}

void print() {
  cout << "\n";
  cout.flush();
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail)) cout << " ";
  print(forward<Tail>(tail)...);
}

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"

#line 2 "library/random/base.hpp"

u64 RNG_64() {
  static uint64_t x_
      = uint64_t(chrono::duration_cast<chrono::nanoseconds>(
                     chrono::high_resolution_clock::now().time_since_epoch())
                     .count())
        * 10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}

u64 RNG(u64 lim) { return RNG_64() % lim; }

ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }
#line 2 "library/random/shuffle.hpp"

template <typename T>
void shuffle(vc<T>& A) {
  FOR(i, len(A)) swap(A[i], A[RNG(0, i + 1)]);
}
#line 2 "library/alg/monoid/add.hpp"

template <typename X>
struct Monoid_Add {
  using value_type = X;
  static constexpr X op(const X &x, const X &y) noexcept { return x + y; }
  static constexpr X inverse(const X &x) noexcept { return -x; }
  static constexpr X power(const X &x, ll n) noexcept { return X(n) * x; }
  static constexpr X unit() { return X(0); }
  static constexpr bool commute = true;
};
#line 3 "library/ds/fenwicktree/fenwicktree.hpp"

template <typename Monoid>
struct FenwickTree {
  using G = Monoid;
  using E = typename G::value_type;
  int n;
  vector<E> dat;
  E total;

  FenwickTree() {}
  FenwickTree(int n) { build(n); }
  template <typename F>
  FenwickTree(int n, F f) {
    build(n, f);
  }
  FenwickTree(const vc<E>& v) { build(v); }

  void build(int m) {
    n = m;
    dat.assign(m, G::unit());
    total = G::unit();
  }
  void build(const vc<E>& v) {
    build(len(v), [&](int i) -> E { return v[i]; });
  }
  template <typename F>
  void build(int m, F f) {
    n = m;
    dat.clear();
    dat.reserve(n);
    total = G::unit();
    FOR(i, n) { dat.eb(f(i)); }
    for (int i = 1; i <= n; ++i) {
      int j = i + (i & -i);
      if (j <= n) dat[j - 1] = G::op(dat[i - 1], dat[j - 1]);
    }
    total = prefix_sum(m);
  }

  E prod_all() { return total; }
  E sum_all() { return total; }
  E sum(int k) { return prefix_sum(k); }
  E prod(int k) { return prefix_prod(k); }
  E prefix_sum(int k) { return prefix_prod(k); }
  E prefix_prod(int k) {
    chmin(k, n);
    E ret = G::unit();
    for (; k > 0; k -= k & -k) ret = G::op(ret, dat[k - 1]);
    return ret;
  }
  E sum(int L, int R) { return prod(L, R); }
  E prod(int L, int R) {
    chmax(L, 0), chmin(R, n);
    if (L == 0) return prefix_prod(R);
    assert(0 <= L && L <= R && R <= n);
    E pos = G::unit(), neg = G::unit();
    while (L < R) { pos = G::op(pos, dat[R - 1]), R -= R & -R; }
    while (R < L) { neg = G::op(neg, dat[L - 1]), L -= L & -L; }
    return G::op(pos, G::inverse(neg));
  }

  void add(int k, E x) { multiply(k, x); }
  void multiply(int k, E x) {
    static_assert(G::commute);
    total = G::op(total, x);
    for (++k; k <= n; k += k & -k) dat[k - 1] = G::op(dat[k - 1], x);
  }

  template <class F>
  int max_right(const F check) {
    assert(check(G::unit()));
    int i = 0;
    E s = G::unit();
    int k = 1;
    while (2 * k <= n) k *= 2;
    while (k) {
      if (i + k - 1 < len(dat)) {
        E t = G::op(s, dat[i + k - 1]);
        if (check(t)) { i += k, s = t; }
      }
      k >>= 1;
    }
    return i;
  }

  int kth(E k) {
    return max_right([&k](E x) -> bool { return x <= k; });
  }
};
#line 3 "library/seq/inversion.hpp"

template <typename T, bool SMALL = false>
ll inversion(vc<T> A) {
  if (A.empty()) return 0;
  if (!SMALL) {
    auto key = A;
    UNIQUE(key);
    for (auto&& x: A) x = LB(key, x);
  }
  ll ANS = 0;
  ll K = MAX(A) + 1;
  FenwickTree<Monoid_Add<int>> bit(K);
  for (auto&& x: A) {
    ANS += bit.sum(x + 1, K);
    bit.add(x, 1);
  }
  return ANS;
}

// i 番目:A_i が先頭になるように rotate したときの転倒数
template <typename T, bool SMALL = false>
vi inversion_rotate(vc<T>& A) {
  const int N = len(A);
  if (!SMALL) {
    auto key = A;
    UNIQUE(key);
    for (auto&& x: A) x = LB(key, x);
  }
  ll K = MAX(A) + 1;
  ll ANS = 0;
  FenwickTree<Monoid_Add<int>> bit(K);
  for (auto&& x: A) {
    ANS += bit.sum(x + 1, K);
    bit.add(x, 1);
  }
  vi res(N);
  FOR(i, N) {
    res[i] = ANS;
    ll x = A[i];
    ANS = ANS + bit.sum(x + 1, K) - bit.prefix_sum(x);
  }
  return res;
}

// inv[i][j] = inversion A[i:j) であるような (N+1, N+1) テーブル
template <typename T>
vvc<int> all_range_inversion(vc<T>& A) {
  int N = len(A);
  vv(int, dp, N + 1, N + 1);
  FOR_R(L, N + 1) FOR(R, L + 2, N + 1) {
    dp[L][R] = dp[L][R - 1] + dp[L + 1][R] - dp[L + 1][R - 1];
    if (A[L] > A[R - 1]) ++dp[L][R];
  }
  return dp;
}
#line 6 "main.cpp"

void solve() {
  int qcnt = 0;
  LL(N);
#if defined(LOCAL)
  vc<int> god(N);
  iota(all(god), 1);
  shuffle(god);
#endif

  auto ask = [&](int L, int R) -> int {
    if (L == R) return 0;
    ++qcnt;
#if defined(LOCAL)
    vc<int> sub = {god.begin() + L, god.begin() + R};
    ll x = inversion<int, true>(sub);
    return x % 2;
#endif
    print("?", L + 1, R);
    INT(v);
    return v;
  };

  vc<int> A(N);
  vv(int, dp, N + 1, N + 1);

  FOR(n, 1, N) {
    vc<int> pos(n);
    FOR(i, n) pos[A[i]] = i;
    // A[n] より小さいものの個数
    auto check = [&](int k) -> bool {
      // k 個小さい
      if (k == 0) return 1;
      int L = pos[k - 1];
      int x = 0;
      x ^= ask(L, n + 1);
      x ^= ask(L + 1, n + 1);
      x ^= dp[L][n];
      x ^= dp[L + 1][n];
      return x == 0;
    };

    int k = binary_search(check, 0, n + 1, 0);
    FOR(i, n) if (A[i] >= k)++ A[i];
    A[n] = k;
    FOR(L, n) {
      ll x = dp[L][n];
      FOR(i, L, n) if (A[i] > A[n])++ x;
      dp[L][n + 1] = x & 1;
    }
  }

  for (auto&& x: A) ++x;
#if defined(LOCAL)
  print("ANS", god);
  print("you", A);
  print("query", qcnt);
#endif
  print("!", A);
}

signed main() {
  solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3432kb

input:

3
0
0
0
1

output:

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

result:

ok OK, guesses=4

Test #2:

score: 0
Accepted
time: 574ms
memory: 19056kb

input:

1993
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
1
0
1
0
1
0
0
1
0
0
1
1
0
1
1
1
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
0
0
0
0
1
0
1
1
0
1
0
0
0
0
1
0
1
0
0
1
0
0
0
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
0
0
0
0
0
1
0
0
1
0
1
1
0
0
1
0
1
1
0
1
1
0
1
1
0
0
1
0
0...

output:

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

result:

ok OK, guesses=38180

Test #3:

score: 0
Accepted
time: 510ms
memory: 17368kb

input:

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

result:

ok OK, guesses=35724

Test #5:

score: 0
Accepted
time: 498ms
memory: 17300kb

input:

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

output:

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

result:

ok OK, guesses=35658

Test #6:

score: 0
Accepted
time: 490ms
memory: 17160kb

input:

1871
1
0
0
0
0
0
1
0
0
1
0
1
1
0
1
0
0
0
0
1
1
1
0
1
1
1
0
1
1
0
1
0
1
0
1
0
1
1
0
1
0
0
0
1
1
1
1
0
1
0
0
0
1
1
0
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7 8
? 7 8
? 8 8
? 4 9
? 5 9
? 6 9
? 7 9
? 7 9
? 8 9
? 8 9
? 9 9
? 5 10
? 6 10
? 7 10
? 8 10
? 8 10
? 9 10
? 9 10...

result:

ok OK, guesses=39774

Test #8:

score: 0
Accepted
time: 549ms
memory: 18956kb

input:

1990
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
0
1
0
0
1
1
0
0
0
0
1
1
0
0
0
1
0
1
1
1
0
1
0
0
0
1
1
1
1
0
0
1
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
1
0
0
1
0
1
0
0
0
0
0
0
1
0
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
0
1...

output:

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

result:

ok OK, guesses=38916

Test #9:

score: 0
Accepted
time: 581ms
memory: 18872kb

input:

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

output:

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

result:

ok OK, guesses=38320

Test #10:

score: 0
Accepted
time: 496ms
memory: 18888kb

input:

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

output:

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

result:

ok OK, guesses=38314

Test #11:

score: 0
Accepted
time: 508ms
memory: 19036kb

input:

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

output:

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

result:

ok OK, guesses=38268

Test #12:

score: 0
Accepted
time: 571ms
memory: 19044kb

input:

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

output:

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

result:

ok OK, guesses=38224

Test #13:

score: 0
Accepted
time: 541ms
memory: 18972kb

input:

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

output:

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

result:

ok OK, guesses=35768

Test #14:

score: 0
Accepted
time: 563ms
memory: 18892kb

input:

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

result:

ok OK, guesses=37512

Test #16:

score: 0
Accepted
time: 576ms
memory: 18988kb

input:

1990
1
0
0
0
1
0
1
1
1
1
0
0
1
0
0
0
1
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
1
1
0
0
1
0
0
1
0
0
1
1
0
1
0
1
1
0
1
0
0
1
1
1
0
0
1
0
0
1
0
1
1
0
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
1
0
0
1
1
0
1
0
0
1
1
0
0
0
0
1
0
0
0
1
0
1
1
0
1
0
0
0
0
1
0
1
1
0
0
1
1
1
1
1
0
1
1
0
0
1
1
0
1
1
1
1
0
1
1
1...

output:

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

result:

ok OK, guesses=37778

Test #17:

score: 0
Accepted
time: 546ms
memory: 18924kb

input:

1989
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
0
1
0
1
0
0
1
1
0
1
0
0
1
0
1
1
1
1
1
1
0
1
0
1
1
1
0
1
0
0
1
0
1
0
0
0
0
1
0
0
1
1
1
1
1
1
1
0
1
1
1
1
0
1
0
0
1
0
1
0
0
1
1
1
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11 11
? 2 11
? 3 ...

result:

ok OK, guesses=38220

Test #19:

score: 0
Accepted
time: 2ms
memory: 3384kb

input:

1

output:

! 1

result:

ok OK, guesses=0

Test #20:

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

input:

2
0
0

output:

? 1 2
? 2 2
! 1 2

result:

ok OK, guesses=2

Test #21:

score: 0
Accepted
time: 2ms
memory: 3344kb

input:

2
1
0

output:

? 1 2
? 2 2
! 2 1

result:

ok OK, guesses=2

Test #22:

score: 0
Accepted
time: 624ms
memory: 19124kb

input:

1997
1
0
0
0
1
0
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
0
0
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
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok OK, guesses=38818

Test #23:

score: 0
Accepted
time: 560ms
memory: 19184kb

input:

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

result:

ok OK, guesses=38862

Test #25:

score: 0
Accepted
time: 585ms
memory: 19100kb

input:

2000
1
0
0
0
1
0
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
0
0
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
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1...

output:

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

result:

ok OK, guesses=38884