QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386907#8553. Exchanging Kubicucup-team087#AC ✓79ms98304kbC++2013.7kb2024-04-11 21:19:342024-04-11 21:19:35

Judging History

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

  • [2024-04-11 21:19:35]
  • 评测
  • 测评结果:AC
  • 用时:79ms
  • 内存:98304kb
  • [2024-04-11 21:19:34]
  • 提交

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else

// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

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); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(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>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

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

#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) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  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;
    (check(x) ? ok : ng) = 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;
    (check(x) ? ok : ng) = 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 5 "main.cpp"

vvc<ll> calc(vi A) {
  ll N = len(A);
  auto Ac = cumsum<ll>(A);
  vv(ll, dp, N + 1, N + 1, -infty<ll>);
  FOR(L, N + 1) FOR(R, L, N + 1) { dp[L][R] = Ac[R] - Ac[L]; }
  FOR_R(L, N + 1) FOR(R, L, N + 1) {
    if (L - 1 >= 0) chmax(dp[L - 1][R], dp[L][R]);
    if (R + 1 <= N) chmax(dp[L][R + 1], dp[L][R]);
  }
  return dp;
}

void solve() {
  LL(N);
  ll QLE = 0;
#if defined(LOCAL)
  vi AA(N);
  //  FOR(i, N) AA[i] = RNG(-1000000000, 1000000000);
  FOR(i, N) AA[i] = RNG(0, 10000);
  FOR(i, N) if (i % 2 == 1) AA[i] = -AA[i];
  // N = 40;
  // AA = {5222, -6802, 9262, -1379, 8503, -3723, 8262, -451,  4482, -6534,
  //       3617, -273,  1848, -5231, 8279, -9523, 9557, -1141, 567,  -2283,
  //       3869, -7463, 7765, -3772, 4785, -6491, 4769, -4282, 3956, -4991,
  //       6933, -1637, 7773, -2370, 968,  -9092, 9079, -1036, 5579, -4426};
  vvc<ll> god = calc(AA);
#endif

  map<pi, ll> MP;

  auto ask = [&](int L, int R) -> ll {
    pi p = {L, R};
    if (MP.count(p)) return MP[p];
    ++QLE;
    print("?", 1 + L, R);
#if defined(LOCAL)
    MP[p] = god[L][R];
#else
    LL(x);
    MP[p] = x;
#endif
    return MP[p];
  };

  // 数列、もとの数列における各項の範囲
  // 不明なところは 0 を入れておく
  vi A(N);
  vc<pi> range(N);
  FOR(i, N) range[i] = {i, i + 1};
  FOR(i, N) { A[i] = ask(i, i + 1); }

  const ll INF = infty<ll>;

  auto dfs = [&](auto& dfs, vi A, vc<pi> range) -> vi {
    auto subask
        = [&](int L, int R) -> ll { return ask(range[L].fi, range[R - 1].se); };
    // print("A", A);
    /*
    連長圧縮できるところがあるならば圧縮して解く
    */
    ll N = len(A);
    if (N == 0) return {};
    FOR(i, N - 1) {
      bool same = 0;
      if (A[i] > 0 && A[i + 1] > 0) same = 1;
      if (A[i] == 0 && A[i + 1] == 0) same = 1;
      if (same) {
        vi B(N - 1);
        vc<pi> R(N - 1);
        FOR(j, i) B[j] = A[j], R[j] = range[j];
        B[i] = A[i] + A[i + 1];
        R[i] = {range[i].fi, range[i + 1].se};
        FOR(j, i + 1, N - 1) { B[j] = A[j + 1], R[j] = range[j + 1]; }
        vi C = dfs(dfs, B, R);

        FOR(j, i) A[j] = C[j];
        if (A[i] == 0) { A[i] = C[i]; }
        FOR(j, i + 2, N) { A[j] = C[j - 1]; }
        return A;
      }
    }
    // 先頭や末尾が負なら無視して解く
    if (A[0] == 0) {
      A.erase(A.begin());
      range.erase(range.begin());
      A = dfs(dfs, A, range);
      A.insert(A.begin(), -INF);
      return A;
    }
    if (A.back() == 0) {
      POP(A);
      POP(range);
      A = dfs(dfs, A, range);
      A.eb(-INF);
      return A;
    }

    auto merge_mpm = [&](int i) -> vi {
      vi B(N - 2);
      vc<pi> R(N - 2);
      FOR(j, i - 1) {
        B[j] = A[j];
        R[j] = range[j];
      }
      B[i - 1] = 0;
      R[i - 1] = {range[i - 1].fi, range[i + 1].se};
      FOR(j, i + 2, N) {
        B[j - 2] = A[j];
        R[j - 2] = range[j];
      }
      vi C = dfs(dfs, B, R);
      FOR(j, i - 1) A[j] = C[j];
      FOR(j, i + 2, N) A[j] = C[j - 2];
      ll x = C[i - 1];
      ll c = A[i];
      // -c 以下で総和が x になるようにする
      if (x == -INF) {
        A[i - 1] = A[i + 1] = -INF;
      } else {
        A[i - 1] = -c;
        A[i + 1] = -c;
        ll add = x - A[i - 1] - A[i] - A[i + 1];
        A[i - 1] += add;
      }
      return A;
    };

    auto merge_pmp = [&](int i, ll x) -> vi {
      A[i] = x - A[i - 1] - A[i + 1];
      vi B(N - 2);
      vc<pi> R(N - 2);
      FOR(j, i - 1) { B[j] = A[j], R[j] = range[j]; }
      B[i - 1] = x;
      R[i - 1] = {range[i - 1].fi, range[i + 1].se};
      FOR(j, i + 2, N) { B[j - 2] = A[j], R[j - 2] = range[j]; }
      vi C = dfs(dfs, B, R);
      FOR(j, i - 1) A[j] = C[j];
      FOR(j, i + 2, N) A[j] = C[j - 2];
      return A;
    };

    // 極小な正の要素の前後をマージ
    FOR(i, 1, N - 1) {
      if (A[i] == 0) continue;
      if (A[i - 2] >= A[i] && A[i] <= A[i + 2]) {
        ll x = subask(i - 2, i + 1);
        if (x > A[i - 2] && x > A[i]) { return merge_pmp(i - 1, x); }
        x = subask(i, i + 3);
        if (x > A[i + 2] && x > A[i]) { return merge_pmp(i + 1, x); }
        return merge_mpm(i);
      }
    }

    // 負で確定できるやつがあれば
    FOR(i, N) {
      if (A[i] > 0) continue;
      ll x = subask(i - 1, i + 2);
      if (x > A[i - 1] && x > A[i + 1]) { return merge_pmp(i, x); }
    }

    FOR(i, N) {
      if (i & 1) A[i] = -INF;
    }
    return A;
  };
  A = dfs(dfs, A, range);
  for (auto& x: A) { chmax(x, -1'000'000'000'000'000LL); }
#if defined(LOCAL)
  vvc<ll> my_ans = calc(A);
  print("N=", N);
  print("god=", AA);
  // print("ANS=", A);
  FOR(L, N) FOR(R, L, N + 1) { assert(god[L][R] == my_ans[L][R]); }
  print("QLE=", QLE);
  assert(QLE <= N + N);
  print("!!!AC!!!");
#endif
  print("!", A);
}

signed main() {
  INT(T);
  FOR(T) solve();
  return 0;
}

詳細信息

Test #1:

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

input:

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

output:

? 1 1
? 2 2
? 3 3
? 1 3
! 1 -1000000000000000 1
? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 1 3
? 1 5
! 2 -1 3 -1000000000000000 5

result:

ok ok (2 test cases)

Test #2:

score: 0
Accepted
time: 33ms
memory: 3612kb

input:

10000
1
718876398
1
0
1
0
1
0
1
938356223
1
857157125
1
0
1
0
1
0
1
0
1
0
1
965894497
1
0
1
626061677
1
642094813
1
107398046
1
0
1
0
1
0
1
287188651
1
0
1
345108193
1
0
1
0
1
714952783
1
0
1
325760098
1
0
1
800487422
1
322806679
1
0
1
0
1
0
1
866952779
1
741483102
1
492063609
1
0
1
833448280
1
0
1
...

output:

? 1 1
! 718876398
? 1 1
! -1000000000000000
? 1 1
! -1000000000000000
? 1 1
! -1000000000000000
? 1 1
! 938356223
? 1 1
! 857157125
? 1 1
! -1000000000000000
? 1 1
! -1000000000000000
? 1 1
! -1000000000000000
? 1 1
! -1000000000000000
? 1 1
! -1000000000000000
? 1 1
! 965894497
? 1 1
! -10000000000...

result:

ok ok (10000 test cases)

Test #3:

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

input:

1052
9
167536100
0
373372185
0
427949326
442758705
102715118
0
0
373372185
973423149
9
248442934
306962195
570791475
593033322
0
582850731
559429390
0
120053133
2780526396
2780526396
10
785691778
0
981032824
0
0
592503870
0
0
0
0
981032824
1112480382
1112480382
10
0
737563509
985502704
427600980
0
8...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 1 3
? 3 7
! 167536100 -1000000000000000 373372185 -1000000000000000 427949326 442758705 102715118 -1000000000000000 0
? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 1 7
? 1 9
! 248442934 306962195 570791475 593033322 -80983651 58285073...

result:

ok ok (1052 test cases)

Test #4:

score: 0
Accepted
time: 16ms
memory: 3904kb

input:

105
98
0
622130364
0
603542943
491665548
0
535594695
169182905
269002770
437838930
534070706
783210752
0
914335037
560159875
0
216552904
666995724
0
0
0
753649796
0
0
0
779352417
0
121063647
0
496743470
0
4104890
0
648149367
0
965790695
732089017
0
0
0
0
6701195
0
0
0
0
750231085
0
0
511641740
36964...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (105 test cases)

Test #5:

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

input:

10
911
0
0
318490282
367703800
0
447141340
683983129
0
319014522
385248618
0
0
0
453686281
0
0
503449442
0
451161866
0
422033116
892391115
0
0
0
0
0
0
116949378
0
305018897
441460055
390798833
643328028
0
0
785497871
0
0
0
0
702685168
0
177748037
150437291
920782161
719254975
0
519494673
555035366
0...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (10 test cases)

Test #6:

score: 0
Accepted
time: 77ms
memory: 86308kb

input:

5
1952
0
207059033
0
846665449
247683562
650126777
348616690
570194875
727419904
504212241
0
0
491140658
0
876684021
0
8207113
0
0
0
0
0
0
325502144
0
78879155
0
828506541
357830073
0
831431906
864603826
0
0
656125431
582335892
651256373
0
640787570
0
103421615
0
0
0
0
0
481682299
493673601
93577949...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (5 test cases)

Test #7:

score: 0
Accepted
time: 79ms
memory: 98304kb

input:

5
2000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (5 test cases)

Test #8:

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

input:

1052
9
911133045
0
526984535
0
931320524
0
928006811
0
176872302
1331374524
1398941858
1808307998
1808307998
9
916585987
0
423565782
0
615681673
0
935399347
0
661248049
1275831339
1377399889
2278784416
2278784416
10
587217915
0
129148010
0
316225345
0
935126806
0
641901481
0
587217915
316225345
5872...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 1 3
? 1 5
? 1 7
? 1 9
! 911133045 -106743056 526984535 -863753190 931320524 -518640671 928006811 -1000000000000000 176872302
? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 1 3
? 1 5
? 1 7
? 1 9
! 916585987 -64320430 423565782 -51411312...

result:

ok ok (1052 test cases)

Test #9:

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

input:

105
98
488529703
0
468492922
0
802901522
0
475641005
0
635144928
0
319324280
0
312095441
0
637285947
0
863514749
0
567178596
0
785897142
0
706104708
0
913552861
0
580235462
0
86293259
0
945400504
0
549373433
0
807677852
0
115856051
0
376484061
0
984127422
0
202884700
0
516705542
0
286842060
0
517315...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (105 test cases)

Test #10:

score: 0
Accepted
time: 72ms
memory: 15148kb

input:

10
911
190008868
0
267501671
0
615470163
0
133513401
0
314315377
0
660548519
0
555314918
0
941289689
0
231059371
0
56848945
0
294509086
0
423676574
0
947717893
0
631853488
0
420480249
0
447345907
0
368504182
0
757380250
0
498988264
0
155354017
0
832730679
0
982153581
0
779911649
0
228619121
0
524075...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (10 test cases)

Test #11:

score: 0
Accepted
time: 68ms
memory: 51148kb

input:

5
1952
270943944
0
427827622
0
706467567
0
657378898
0
336632977
0
646373280
0
330175227
0
636169757
0
614552419
0
752377204
0
964998361
0
223064174
0
402544250
0
855778411
0
374152994
0
278416329
0
988879952
0
151167996
0
775855140
0
366009963
0
63772275
0
189944036
0
123776551
0
636001304
0
860458...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 10 10
? 11 11
? 12 12
? 13 13
? 14 14
? 15 15
? 16 16
? 17 17
? 18 18
? 19 19
? 20 20
? 21 21
? 22 22
? 23 23
? 24 24
? 25 25
? 26 26
? 27 27
? 28 28
? 29 29
? 30 30
? 31 31
? 32 32
? 33 33
? 34 34
? 35 35
? 36 36
? 37 37
? 38 38
? 39 39
? 40 4...

result:

ok ok (5 test cases)

Extra Test:

score: 0
Extra Test Passed