QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#853406#9734. Identify Chorducup-team112#RE 74ms3868kbC++2015.5kb2025-01-11 16:56:472025-01-11 16:56:49

Judging History

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

  • [2025-01-11 16:56:49]
  • 评测
  • 测评结果:RE
  • 用时:74ms
  • 内存:3868kb
  • [2025-01-11 16:56:47]
  • 提交

answer

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#define INTERACTIVE

#include <bits/stdc++.h>
using namespace std;

namespace templates {
// type
using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pil = pair<int, ll>;
using Pli = pair<ll, int>;
using Pll = pair<ll, ll>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using qp = priority_queue<T, vector<T>, greater<T>>;
// clang-format off
#define vec(T, A, ...) vector<T> A(__VA_ARGS__);
#define vvec(T, A, h, ...) vector<vector<T>> A(h, vector<T>(__VA_ARGS__));
#define vvvec(T, A, h1, h2, ...) vector<vector<vector<T>>> A(h1, vector<vector<T>>(h2, vector<T>(__VA_ARGS__)));
// clang-format on

// for loop
#define fori1(a) for (ll _ = 0; _ < (a); _++)
#define fori2(i, a) for (ll i = 0; i < (a); i++)
#define fori3(i, a, b) for (ll i = (a); i < (b); i++)
#define fori4(i, a, b, c) for (ll i = (a); ((c) > 0 || i > (b)) && ((c) < 0 || i < (b)); i += (c))
#define overload4(a, b, c, d, e, ...) e
#define fori(...) overload4(__VA_ARGS__, fori4, fori3, fori2, fori1)(__VA_ARGS__)

// declare and input
// clang-format off
#define INT(...) int __VA_ARGS__; inp(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; inp(__VA_ARGS__);
#define STRING(...) string __VA_ARGS__; inp(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; inp(__VA_ARGS__);
#define DOUBLE(...) double __VA_ARGS__; STRING(str___); __VA_ARGS__ = stod(str___);
#define VEC(T, A, n) vector<T> A(n); inp(A);
#define VVEC(T, A, n, m) vector<vector<T>> A(n, vector<T>(m)); inp(A);
// clang-format on

// const value
const ll MOD1   = 1000000007;
const ll MOD9   = 998244353;
const double PI = acos(-1);

// other macro
#if !defined(RIN__LOCAL) && !defined(INTERACTIVE)
#define endl "\n"
#endif
#define spa ' '
#define len(A) ll(A.size())
#define all(A) begin(A), end(A)

// function
vector<char> stoc(string &S) {
    int n = S.size();
    vector<char> ret(n);
    for (int i = 0; i < n; i++) ret[i] = S[i];
    return ret;
}
string ctos(vector<char> &S) {
    int n      = S.size();
    string ret = "";
    for (int i = 0; i < n; i++) ret += S[i];
    return ret;
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}
template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}
template <class T, class S>
auto clamp(T &a, const S &l, const S &r) {
    return (a > r ? r : a < l ? l : a);
}
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);
}
template <class T, class S>
inline bool chclamp(T &a, const S &l, const S &r) {
    auto b = clamp(a, l, r);
    return (a != b ? a = b, 1 : 0);
}

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

template <typename T>
vector<T> compression(vector<T> X) {
    sort(all(X));
    X.erase(unique(all(X)), X.end());
    return X;
}

// input and output
namespace io {
// __int128_t
std::istream &operator>>(std::istream &is, __int128_t &value) {
    std::string str;
    is >> str;
    value    = 0;
    int sign = 1;
    for (size_t i = 0; i < str.size(); i++) {
        if (i == 0 && str[i] == '-') {
            sign = -1;
            continue;
        }
        value = value * 10 + str[i] - '0';
    }
    value *= sign;
    return is;
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// vector<T>
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << ' ';
    }
    return os;
}

// vector<vector<T>>
template <typename T>
istream &operator>>(istream &is, vector<vector<T>> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<vector<T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// pair<S, T>
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &A) {
    is >> A.first >> A.second;
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, pair<S, T> &A) {
    os << A.first << ' ' << A.second;
    return os;
}

// vector<pair<S, T>>
template <typename S, typename T>
istream &operator>>(istream &is, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        is >> A[i];
    }
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// tuple
template <typename T, size_t N>
struct TuplePrint {
    static ostream &print(ostream &os, const T &t) {
        TuplePrint<T, N - 1>::print(os, t);
        os << ' ' << get<N - 1>(t);
        return os;
    }
};
template <typename T>
struct TuplePrint<T, 1> {
    static ostream &print(ostream &os, const T &t) {
        os << get<0>(t);
        return os;
    }
};
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
    TuplePrint<decltype(t), sizeof...(Args)>::print(os, t);
    return os;
}

// io functions
void FLUSH() {
    cout << flush;
}

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

template <typename T, typename S>
void prisep(vector<T> &A, S sep) {
    int n = A.size();
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) cout << sep;
    }
    cout << endl;
}
template <typename T, typename S>
void priend(T A, S end) {
    cout << A << end;
}
template <typename T>
void prispa(T A) {
    priend(A, spa);
}
template <typename T, typename S>
bool printif(bool f, T A, S B) {
    if (f)
        print(A);
    else
        print(B);
    return f;
}

template <class... T>
void inp(T &...a) {
    (cin >> ... >> a);
}

} // namespace io
using namespace io;

// read graph
vector<vector<int>> read_edges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<int>> edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        u -= indexed;
        v -= indexed;
        edges[u].push_back(v);
        if (!direct) edges[v].push_back(u);
    }
    return edges;
}
vector<vector<int>> read_tree(int n, int indexed = 1) {
    return read_edges(n, n - 1, false, indexed);
}

template <typename T = long long>
vector<vector<pair<int, T>>> read_wedges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<pair<int, T>>> edges(n, vector<pair<int, T>>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        T w;
        inp(w);
        u -= indexed;
        v -= indexed;
        edges[u].push_back({v, w});
        if (!direct) edges[v].push_back({u, w});
    }
    return edges;
}
template <typename T = long long>
vector<vector<pair<int, T>>> read_wtree(int n, int indexed = 1) {
    return read_wedges<T>(n, n - 1, false, indexed);
}

// yes / no
namespace yesno {

// yes
inline bool yes(bool f = true) {
    cout << (f ? "yes" : "no") << endl;
    return f;
}
inline bool Yes(bool f = true) {
    cout << (f ? "Yes" : "No") << endl;
    return f;
}
inline bool YES(bool f = true) {
    cout << (f ? "YES" : "NO") << endl;
    return f;
}

// no
inline bool no(bool f = true) {
    cout << (!f ? "yes" : "no") << endl;
    return f;
}
inline bool No(bool f = true) {
    cout << (!f ? "Yes" : "No") << endl;
    return f;
}
inline bool NO(bool f = true) {
    cout << (!f ? "YES" : "NO") << endl;
    return f;
}

// possible
inline bool possible(bool f = true) {
    cout << (f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Possible(bool f = true) {
    cout << (f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool POSSIBLE(bool f = true) {
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// impossible
inline bool impossible(bool f = true) {
    cout << (!f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Impossible(bool f = true) {
    cout << (!f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool IMPOSSIBLE(bool f = true) {
    cout << (!f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// Alice Bob
inline bool Alice(bool f = true) {
    cout << (f ? "Alice" : "Bob") << endl;
    return f;
}
inline bool Bob(bool f = true) {
    cout << (f ? "Bob" : "Alice") << endl;
    return f;
}

// Takahashi Aoki
inline bool Takahashi(bool f = true) {
    cout << (f ? "Takahashi" : "Aoki") << endl;
    return f;
}
inline bool Aoki(bool f = true) {
    cout << (f ? "Aoki" : "Takahashi") << endl;
    return f;
}

} // namespace yesno
using namespace yesno;

} // namespace templates
using namespace templates;

void solve() {
    INT(n);

    auto ask = [&](int x, int y) -> int {
        x = (x % n + n) % n;
        y = (y % n + n) % n;
        print("?", x + 1, y + 1);
        INT(res);
        return res;
    };
    auto answer = [&](int x, int y) -> void {
        print("!", x + 1, y + 1);
        INT(res);
        assert(res == 1);
    };

    if (n <= 10) {
        fori(i, n) {
            fori(j, i + 2, n) {
                if (i == 0 and j == n - 1) break;
                if (ask(i, j) == 1) {
                    answer(i, j);
                    return;
                }
            }
        }
        assert(false);
    }

    int n2 = n / 2;
    vec(Pii, cand, 0);
    cand.emplace_back(0, n2);
    if (n & 1) {
        cand.emplace_back(0, n2 + 1);
    }
    cand.emplace_back(n / 4, n / 4 + n2);
    if (n & 1) {
        cand.emplace_back(n / 4, n / 4 + n2 + 1);
    }
    int l = -1;
    int r = -1;
    int d = -1;
    for (auto [l_, r_] : cand) {
        d = ask(l_, r_);
        if (d == 1) {
            answer(l_, r_);
            return;
        }
        if (d != n2) {
            l = l_;
            r = r_;
            break;
        }
    }
    assert(l != -1);

    auto d2 = ask(l + 1, r);
    int lp;
    if (d2 + 1 == d) {
        int lef = l + 1;
        int rig = r;
        while (rig - lef > 1) {
            int mid = (lef + rig) / 2;
            auto dd = ask(mid, r);
            if (dd + mid - l == d) {
                lef = mid;
            } else {
                rig = mid;
            }
        }
        lp = lef;
    } else {
        int rig = l + n;
        int lef = r;
        while (rig - lef > 1) {
            int mid = (lef + rig) / 2;
            auto dd = ask(mid, r);
            if (dd + (l + n) - mid == d) {
                rig = mid;
            } else {
                lef = mid;
            }
        }
        lp = rig % n;
    }

    d = ask(lp, r) - 1;
    if (d == 0) {
        answer(lp, r);
        return;
    }
    {
        int rp = (r + d) % n;
        if (ask(lp, rp) == 1) {
            answer(lp, rp);
            return;
        }
    }
    {
        int rp = (r - d + n) % n;
        if (ask(lp, rp) == 1) {
            answer(lp, rp);
            return;
        }
    }
    assert(false);
}

int main() {
#ifndef INTERACTIVE
    std::cin.tie(0)->sync_with_stdio(0);
#endif
    // std::cout << std::fixed << std::setprecision(12);
    int t;
    t = 1;
    std::cin >> t;
    while (t--) solve();
    return 0;
}

// // #pragma GCC target("avx2")
// // #pragma GCC optimize("O3")
// // #pragma GCC optimize("unroll-loops")
// #define INTERACTIVE
//
// #include "kyopro-cpp/template.hpp"
//
// void solve() {
//     INT(n);
//
//     auto ask = [&](int x, int y) -> int {
//         x = (x % n + n) % n;
//         y = (y % n + n) % n;
//         print("?", x + 1, y + 1);
//         INT(res);
//         return res;
//     };
//     auto answer = [&](int x, int y) -> void {
//         print("!", x + 1, y + 1);
//         INT(res);
//         assert(res == 1);
//     };
//
//     if (n <= 10) {
//         fori(i, n) {
//             fori(j, i + 2, n) {
//                 if (i == 0 and j == n - 1) break;
//                 if (ask(i, j) == 1) {
//                     answer(i, j);
//                     return;
//                 }
//             }
//         }
//         assert(false);
//     }
//
//     int n2 = n / 2;
//     vec(Pii, cand, 0);
//     cand.emplace_back(0, n2);
//     if (n & 1) {
//         cand.emplace_back(0, n2 + 1);
//     }
//     cand.emplace_back(n / 4, n / 4 + n2);
//     if (n & 1) {
//         cand.emplace_back(n / 4, n / 4 + n2 + 1);
//     }
//     int l = -1;
//     int r = -1;
//     int d = -1;
//     for (auto [l_, r_] : cand) {
//         d = ask(l_, r_);
//         if (d == 1) {
//             answer(l_, r_);
//             return;
//         }
//         if (d != n2) {
//             l = l_;
//             r = r_;
//             break;
//         }
//     }
//     assert(l != -1);
//
//     auto d2 = ask(l + 1, r);
//     int lp;
//     if (d2 + 1 == d) {
//         int lef = l + 1;
//         int rig = r;
//         while (rig - lef > 1) {
//             int mid = (lef + rig) / 2;
//             auto dd = ask(mid, r);
//             if (dd + mid - l == d) {
//                 lef = mid;
//             } else {
//                 rig = mid;
//             }
//         }
//         lp = lef;
//     } else {
//         int rig = l + n;
//         int lef = r;
//         while (rig - lef > 1) {
//             int mid = (lef + rig) / 2;
//             auto dd = ask(mid, r);
//             if (dd + (l + n) - mid == d) {
//                 rig = mid;
//             } else {
//                 lef = mid;
//             }
//         }
//         lp = rig % n;
//     }
//
//     d = ask(lp, r) - 1;
//     if (d == 0) {
//         answer(lp, r);
//         return;
//     }
//     {
//         int rp = (r + d) % n;
//         if (ask(lp, rp) == 1) {
//             answer(lp, rp);
//             return;
//         }
//     }
//     {
//         int rp = (r - d + n) % n;
//         if (ask(lp, rp) == 1) {
//             answer(lp, rp);
//             return;
//         }
//     }
//     assert(false);
// }
//
// int main() {
// #ifndef INTERACTIVE
//     std::cin.tie(0)->sync_with_stdio(0);
// #endif
//     // std::cout << std::fixed << std::setprecision(12);
//     int t;
//     t = 1;
//     std::cin >> t;
//     while (t--) solve();
//     return 0;
// }

詳細信息

Test #1:

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

input:

2
6
2
2
2
1
1
4
1
1

output:

? 1 3
? 1 4
? 1 5
? 2 4
! 2 4
? 1 3
! 1 3

result:

ok ok (2 test cases)

Test #2:

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

input:

1000
15
5
4
1
2
1
1
19
5
4
4
4
3
3
1
1
17
5
4
4
3
4
3
1
1
15
6
6
4
6
7
6
3
1
1
14
5
4
3
5
4
5
1
1
15
3
2
3
3
2
1
1
17
8
8
2
3
4
5
4
3
2
1
1
20
6
7
5
7
8
7
6
5
1
1
13
5
5
3
3
2
2
3
1
1
18
3
4
4
4
3
2
2
1
1
13
4
5
3
4
3
3
1
1
14
2
3
3
2
1
1
1
17
8
7
6
2
2
3
2
1
1
12
5
4
3
3
3
1
1
10
2
3
4
5
4
3
2
2
3
...

output:

? 1 8
? 2 8
? 5 8
? 6 8
? 5 8
! 5 8
? 1 10
? 2 10
? 6 10
? 4 10
? 3 10
? 3 10
? 3 12
! 3 12
? 1 9
? 2 9
? 5 9
? 3 9
? 4 9
? 3 9
? 3 11
! 3 11
? 1 8
? 2 8
? 12 8
? 14 8
? 15 8
? 1 8
? 1 13
? 1 3
! 1 3
? 1 8
? 2 8
? 5 8
? 3 8
? 2 8
? 2 11
? 2 5
! 2 5
? 1 8
? 2 8
? 5 8
? 3 8
? 2 8
? 2 9
! 2 9
? 1 9
? 1...

result:

ok ok (1000 test cases)

Test #3:

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

input:

1000
21
3
4
5
4
3
2
2
3
1
1
22
8
7
5
7
6
6
1
1
20
5
4
2
2
1
1
1
22
10
9
4
3
4
4
1
1
21
9
8
4
3
3
3
1
1
21
8
9
5
5
6
6
5
1
1
24
11
11
5
3
4
4
4
2
1
1
22
10
10
4
2
2
2
1
1
21
4
3
5
5
4
3
1
1
23
8
9
6
9
8
7
7
1
1
21
10
10
4
3
5
3
2
2
3
1
1
24
9
8
3
3
2
3
2
1
1
20
9
9
4
1
1
1
1
24
11
10
5
2
2
2
3
1
1
23...

output:

? 1 11
? 2 11
? 16 11
? 19 11
? 20 11
? 21 11
? 21 11
? 21 12
? 21 10
! 21 10
? 1 12
? 2 12
? 7 12
? 4 12
? 3 12
? 3 12
? 3 17
! 3 17
? 1 11
? 2 11
? 6 11
? 4 11
? 5 11
? 5 11
! 5 11
? 1 12
? 2 12
? 7 12
? 9 12
? 8 12
? 7 12
? 7 15
! 7 15
? 1 11
? 2 11
? 6 11
? 8 11
? 7 11
? 7 11
? 7 13
! 7 13
? 1 1...

result:

ok ok (1000 test cases)

Test #4:

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

input:

1000
25
8
9
6
9
10
9
8
6
1
1
25
6
7
6
8
6
5
5
8
1
1
25
11
11
6
9
9
8
8
3
1
1
25
5
4
6
4
3
3
5
1
1
26
12
12
5
3
4
5
5
1
1
26
11
12
6
9
9
10
9
3
1
1
26
13
11
12
6
7
7
8
7
1
1
27
12
11
5
3
5
5
9
1
1
25
9
10
2
3
2
1
1
1
27
9
8
6
7
7
6
6
11
1
1
27
11
12
4
3
5
5
4
1
1
27
13
13
4
3
6
6
4
3
1
1
26
5
6
6
5
3...

output:

? 1 13
? 2 13
? 19 13
? 22 13
? 24 13
? 25 13
? 1 13
? 1 20
? 1 6
! 1 6
? 1 13
? 2 13
? 19 13
? 22 13
? 24 13
? 25 13
? 25 13
? 25 17
? 25 9
! 25 9
? 1 13
? 2 13
? 19 13
? 22 13
? 24 13
? 23 13
? 23 13
? 23 20
? 23 6
! 23 6
? 1 13
? 2 13
? 7 13
? 4 13
? 3 13
? 3 13
? 3 15
? 3 11
! 3 11
? 1 14
? 2 14...

result:

ok ok (1000 test cases)

Test #5:

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

input:

1000
29
10
9
7
10
8
9
8
1
1
28
13
13
7
9
8
8
8
2
1
1
30
3
2
7
5
3
2
1
1
29
4
3
7
6
4
3
5
1
1
28
8
9
3
4
2
2
3
1
1
29
6
5
7
6
4
5
4
1
1
29
9
10
7
7
7
6
6
1
1
28
11
10
4
4
5
4
7
1
1
30
4
5
6
2
2
1
1
1
30
8
9
4
4
2
3
2
3
1
1
28
11
10
4
3
3
2
2
1
1
29
14
13
14
6
3
5
5
5
1
1
29
11
10
7
10
9
10
9
9
1
1
29...

output:

? 1 15
? 2 15
? 8 15
? 5 15
? 3 15
? 4 15
? 3 15
? 3 22
! 3 22
? 1 15
? 2 15
? 22 15
? 25 15
? 23 15
? 24 15
? 24 15
? 24 22
? 24 8
! 24 8
? 1 16
? 2 16
? 9 16
? 5 16
? 3 16
? 2 16
? 2 17
! 2 17
? 1 15
? 2 15
? 8 15
? 5 15
? 3 15
? 2 15
? 2 17
? 2 13
! 2 13
? 1 15
? 2 15
? 22 15
? 25 15
? 23 15
? 23...

result:

ok ok (1000 test cases)

Test #6:

score: 0
Accepted
time: 8ms
memory: 3812kb

input:

1000
32
13
12
8
9
10
10
9
12
1
1
30
14
14
7
11
12
11
11
1
1
32
16
2
3
8
6
4
3
2
1
1
31
5
4
7
3
3
2
2
3
1
1
32
7
6
8
7
5
6
5
1
1
32
8
7
8
10
8
7
1
1
31
15
14
13
6
4
4
3
3
1
1
31
6
7
8
8
6
5
5
1
1
32
12
11
4
4
4
3
3
5
1
1
30
14
14
7
10
9
9
9
1
1
31
11
12
8
9
9
8
8
6
1
1
31
10
11
2
4
4
3
2
1
1
33
7
8
8...

output:

? 1 17
? 2 17
? 9 17
? 5 17
? 7 17
? 6 17
? 5 17
? 5 25
? 5 9
! 5 9
? 1 16
? 2 16
? 23 16
? 27 16
? 29 16
? 28 16
? 28 16
? 28 26
! 28 26
? 1 17
? 9 25
? 10 25
? 1 25
? 5 25
? 7 25
? 8 25
? 9 25
? 9 26
! 9 26
? 1 16
? 2 16
? 9 16
? 5 16
? 3 16
? 4 16
? 4 16
? 4 17
? 4 15
! 4 15
? 1 17
? 2 17
? 9 17
...

result:

ok ok (1000 test cases)

Test #7:

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

input:

1000
34
17
10
11
8
7
7
6
6
1
1
33
8
7
6
4
4
3
3
5
1
1
33
11
12
8
10
8
9
8
1
1
34
11
12
8
10
8
9
8
7
1
1
34
11
10
8
12
12
11
10
1
1
35
14
15
9
13
15
16
15
14
5
1
1
34
8
9
8
9
7
6
6
10
1
1
34
14
13
8
11
11
10
10
1
1
34
16
15
8
12
13
13
13
8
1
1
33
9
10
8
4
6
5
4
1
1
33
16
16
15
14
7
4
6
7
7
13
1
1
34
...

output:

? 1 18
? 9 26
? 10 26
? 34 26
? 4 26
? 6 26
? 5 26
? 5 26
? 5 31
! 5 31
? 1 17
? 2 17
? 9 17
? 5 17
? 7 17
? 6 17
? 6 17
? 6 19
? 6 15
! 6 15
? 1 17
? 2 17
? 25 17
? 29 17
? 31 17
? 30 17
? 31 17
? 31 24
! 31 24
? 1 18
? 2 18
? 26 18
? 30 18
? 32 18
? 31 18
? 32 18
? 32 25
? 32 11
! 32 11
? 1 18
? 2...

result:

ok ok (1000 test cases)

Test #8:

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

input:

1000
36
18
17
16
9
12
10
9
9
17
1
1
36
3
4
8
4
2
1
1
1
36
13
12
9
12
10
11
10
12
1
1
36
5
4
9
6
4
3
3
5
1
1
36
18
9
10
9
6
6
5
5
1
1
36
12
11
3
5
5
4
3
1
1
35
13
14
6
8
6
5
5
1
1
36
13
12
4
5
4
3
3
1
1
36
14
13
9
9
11
10
9
1
1
36
16
15
9
11
9
8
8
15
1
1
36
9
8
9
6
6
5
5
1
1
36
8
9
9
7
5
6
5
9
1
1
36...

output:

? 1 19
? 10 28
? 11 28
? 19 28
? 15 28
? 17 28
? 18 28
? 18 28
? 18 36
? 18 20
! 18 20
? 1 19
? 2 19
? 28 19
? 32 19
? 34 19
? 35 19
? 35 19
! 35 19
? 1 19
? 2 19
? 10 19
? 6 19
? 4 19
? 5 19
? 4 19
? 4 28
? 4 10
! 4 10
? 1 19
? 2 19
? 10 19
? 6 19
? 4 19
? 3 19
? 3 19
? 3 21
? 3 17
! 3 17
? 1 19
? ...

result:

ok ok (1000 test cases)

Test #9:

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

input:

1000
37
17
17
7
4
6
7
6
6
3
1
1
36
17
17
8
4
6
7
8
8
1
1
38
9
8
7
4
4
3
3
5
1
1
37
15
14
6
4
4
3
3
1
1
37
12
13
2
4
3
2
1
1
1
36
8
9
9
7
5
6
5
1
1
37
6
7
9
7
5
4
4
1
1
37
18
18
3
4
9
8
6
5
4
3
1
1
37
17
17
7
2
2
1
1
1
37
8
7
7
3
5
4
3
1
1
37
10
11
9
11
9
8
8
1
1
37
18
18
18
17
18
9
12
10
9
9
1
1
36
...

output:

? 1 19
? 2 19
? 28 19
? 23 19
? 25 19
? 26 19
? 27 19
? 27 19
? 27 24
? 27 14
! 27 14
? 1 19
? 2 19
? 28 19
? 23 19
? 25 19
? 26 19
? 27 19
? 28 19
? 28 26
! 28 26
? 1 20
? 2 20
? 11 20
? 6 20
? 8 20
? 7 20
? 7 20
? 7 22
? 7 18
! 7 18
? 1 19
? 2 19
? 10 19
? 14 19
? 12 19
? 13 19
? 13 19
? 13 21
! 1...

result:

ok ok (1000 test cases)

Test #10:

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

input:

1000
39
18
17
8
5
6
6
6
1
1
38
8
9
6
3
4
3
2
2
1
1
38
19
9
8
9
4
6
5
4
7
1
1
39
12
11
9
14
13
12
11
11
1
1
38
15
16
5
4
2
3
2
1
1
39
4
5
10
9
7
6
5
4
1
1
39
18
18
10
15
17
16
16
3
1
1
38
18
17
8
4
2
1
1
1
1
39
14
15
10
15
17
16
15
14
1
1
39
11
10
7
6
4
5
4
7
1
1
39
9
8
9
10
8
7
7
1
1
38
19
18
17
9
1...

output:

? 1 20
? 2 20
? 11 20
? 15 20
? 13 20
? 14 20
? 13 20
? 13 25
! 13 25
? 1 20
? 2 20
? 29 20
? 34 20
? 31 20
? 32 20
? 33 20
? 33 20
? 33 21
! 33 21
? 1 20
? 10 29
? 11 29
? 20 29
? 15 29
? 17 29
? 16 29
? 15 29
? 15 32
? 15 26
! 15 26
? 1 20
? 2 20
? 11 20
? 6 20
? 4 20
? 3 20
? 2 20
? 2 30
? 2 10
!...

result:

ok ok (1000 test cases)

Test #11:

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

input:

1000
40
12
11
10
7
7
6
6
1
1
40
18
17
8
5
8
7
7
1
1
40
15
14
10
15
14
13
13
1
1
40
8
9
10
13
11
10
9
8
13
1
1
40
16
17
6
5
3
4
3
1
1
40
15
16
9
10
7
8
7
6
1
1
41
13
14
10
15
16
15
14
13
9
1
1
40
7
8
10
6
4
5
4
1
1
40
18
19
8
3
2
3
4
3
1
1
40
6
5
10
5
3
4
3
5
1
1
40
4
3
10
7
5
4
3
5
1
1
41
12
11
10
1...

output:

? 1 21
? 2 21
? 11 21
? 6 21
? 8 21
? 7 21
? 7 21
? 7 26
! 7 26
? 1 21
? 2 21
? 11 21
? 16 21
? 13 21
? 12 21
? 12 21
? 12 27
! 12 27
? 1 21
? 2 21
? 11 21
? 6 21
? 4 21
? 3 21
? 3 21
? 3 33
! 3 33
? 1 21
? 2 21
? 31 21
? 36 21
? 38 21
? 39 21
? 40 21
? 1 21
? 1 28
? 1 14
! 1 14
? 1 21
? 2 21
? 31 2...

result:

ok ok (1000 test cases)

Test #12:

score: 0
Accepted
time: 5ms
memory: 3520kb

input:

1000
42
11
10
10
7
8
7
6
6
11
1
1
41
17
18
10
15
14
14
13
13
1
1
41
8
9
10
10
7
6
6
11
1
1
41
12
13
10
6
9
8
7
6
10
1
1
41
12
11
4
7
5
4
3
3
1
1
41
18
19
10
14
15
13
13
4
1
1
41
14
15
10
15
15
14
13
13
1
1
41
20
20
1
1
41
17
18
10
15
14
14
13
13
5
1
1
41
15
16
4
5
7
6
5
4
1
1
41
18
19
10
12
9
10
9
4...

output:

? 1 22
? 2 22
? 12 22
? 7 22
? 4 22
? 5 22
? 6 22
? 6 22
? 6 27
? 6 17
! 6 17
? 1 21
? 2 21
? 31 21
? 36 21
? 39 21
? 37 21
? 38 21
? 38 21
? 38 33
! 38 33
? 1 21
? 2 21
? 31 21
? 36 21
? 39 21
? 40 21
? 40 21
? 40 26
? 40 16
! 40 16
? 1 21
? 2 21
? 31 21
? 36 21
? 33 21
? 34 21
? 35 21
? 36 21
? 36...

result:

ok ok (1000 test cases)

Test #13:

score: 0
Accepted
time: 32ms
memory: 3860kb

input:

1000
43
4
3
10
6
3
2
2
3
1
1
42
18
17
7
4
5
4
3
3
5
1
1
43
6
5
9
4
3
2
3
2
3
1
1
43
18
19
11
12
9
10
9
5
1
1
43
21
21
15
16
11
9
12
11
10
9
1
1
43
17
18
11
13
14
12
12
6
1
1
43
18
17
10
15
17
16
16
9
1
1
43
21
21
21
20
21
10
14
11
11
11
1
1
42
13
14
10
7
10
9
8
7
1
1
42
20
20
10
14
11
10
10
1
1
42
5...

output:

? 1 22
? 2 22
? 12 22
? 7 22
? 4 22
? 3 22
? 3 22
? 3 23
? 3 21
! 3 21
? 1 22
? 2 22
? 12 22
? 17 22
? 14 22
? 15 22
? 16 22
? 16 22
? 16 24
? 16 20
! 16 20
? 1 22
? 2 22
? 12 22
? 7 22
? 4 22
? 5 22
? 6 22
? 5 22
? 5 23
? 5 21
! 5 21
? 1 22
? 2 22
? 33 22
? 38 22
? 35 22
? 34 22
? 35 22
? 35 30
? 3...

result:

ok ok (1000 test cases)

Test #14:

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

input:

1000
44
22
14
15
11
8
11
10
9
8
1
1
44
11
10
11
9
8
7
8
7
1
1
43
11
12
6
5
4
3
3
1
1
43
21
21
12
11
9
6
6
5
5
9
1
1
44
19
18
11
16
19
19
18
1
1
44
16
15
11
14
13
12
13
12
15
1
1
44
17
18
6
5
3
5
4
3
5
1
1
44
10
9
7
4
4
3
3
1
1
43
13
14
4
7
4
3
3
5
1
1
43
4
5
11
6
3
2
2
1
1
44
9
8
8
3
5
4
3
5
1
1
44
...

output:

? 1 23
? 12 34
? 13 34
? 1 34
? 6 34
? 3 34
? 4 34
? 5 34
? 6 34
? 6 41
! 6 41
? 1 23
? 2 23
? 12 23
? 7 23
? 4 23
? 5 23
? 6 23
? 5 23
? 5 29
! 5 29
? 1 22
? 2 22
? 33 22
? 38 22
? 35 22
? 36 22
? 36 22
? 36 24
! 36 24
? 1 22
? 1 23
? 11 32
? 12 32
? 22 32
? 17 32
? 19 32
? 18 32
? 18 32
? 18 36
? ...

result:

ok ok (1000 test cases)

Test #15:

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

input:

1000
45
20
21
11
17
20
20
19
19
4
1
1
45
16
17
11
14
13
13
12
12
8
1
1
45
10
9
11
8
7
6
7
6
11
1
1
45
15
14
11
11
12
11
10
10
1
1
45
11
10
11
15
12
11
10
15
1
1
45
16
17
11
10
9
8
8
8
1
1
45
19
20
7
5
4
6
5
4
1
1
45
5
6
11
5
2
4
3
2
3
1
1
44
19
20
11
13
13
13
12
12
1
1
45
12
13
11
17
15
14
13
12
1
1...

output:

? 1 23
? 2 23
? 34 23
? 40 23
? 43 23
? 44 23
? 45 23
? 45 23
? 45 41
? 45 5
! 45 5
? 1 23
? 2 23
? 34 23
? 40 23
? 43 23
? 41 23
? 42 23
? 42 23
? 42 34
? 42 12
! 42 12
? 1 23
? 2 23
? 12 23
? 7 23
? 4 23
? 5 23
? 6 23
? 5 23
? 5 28
? 5 18
! 5 18
? 1 23
? 2 23
? 12 23
? 7 23
? 4 23
? 5 23
? 6 23
? ...

result:

ok ok (1000 test cases)

Test #16:

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

input:

1000
46
18
17
10
12
9
8
9
8
1
1
46
9
8
11
9
6
7
6
1
1
46
22
21
11
16
14
16
16
1
1
46
19
18
11
15
16
15
14
14
15
1
1
46
5
6
11
11
8
7
6
5
9
1
1
46
21
20
9
6
9
8
8
1
1
46
18
17
8
12
9
8
7
7
1
1
46
16
15
6
10
7
6
5
5
1
1
46
22
22
10
4
2
2
2
1
1
46
5
4
11
9
6
5
4
1
1
45
19
20
11
13
14
15
14
13
1
1
46
14...

output:

? 1 24
? 2 24
? 13 24
? 7 24
? 10 24
? 11 24
? 12 24
? 11 24
? 11 31
! 11 31
? 1 24
? 2 24
? 13 24
? 7 24
? 4 24
? 5 24
? 4 24
? 4 29
! 4 29
? 1 24
? 2 24
? 13 24
? 7 24
? 10 24
? 8 24
? 7 24
? 7 39
! 7 39
? 1 24
? 2 24
? 13 24
? 7 24
? 4 24
? 5 24
? 6 24
? 6 24
? 6 37
? 6 11
! 6 11
? 1 24
? 2 24
? ...

result:

ok ok (1000 test cases)

Test #17:

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

input:

1000
1000000000
499999999
499999999
250000000
374999999
312500000
343750000
359375000
367187500
371093750
373046874
372070311
371582031
371826171
371948241
372009276
372039794
372055052
372047422
372043608
372045515
372046469
372046946
372047184
372047303
372047363
372047392
372047378
372047384
3720...

output:

? 1 500000001
? 2 500000001
? 750000001 500000001
? 875000001 500000001
? 812500001 500000001
? 843750001 500000001
? 859375001 500000001
? 867187501 500000001
? 871093751 500000001
? 873046876 500000001
? 872070313 500000001
? 871582032 500000001
? 871826172 500000001
? 871948242 500000001
? 872009...

result:

ok ok (1000 test cases)

Test #18:

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

input:

1000
1000000000
499999969
499999968
249999969
124999969
62500000
93750000
109374969
101562469
97656219
95703125
96679688
97167938
96923798
96801728
96740724
96771211
96755952
96748354
96752138
96750231
96749277
96748831
96749070
96749158
96749099
96749100
96749110
96749102
96749098
96749098
96749097...

output:

? 1 500000001
? 2 500000001
? 250000001 500000001
? 375000001 500000001
? 437500001 500000001
? 406250001 500000001
? 390625001 500000001
? 398437501 500000001
? 402343751 500000001
? 404296876 500000001
? 403320313 500000001
? 402832032 500000001
? 403076172 500000001
? 403198242 500000001
? 403259...

result:

ok ok (1000 test cases)

Test #19:

score: 0
Accepted
time: 59ms
memory: 3860kb

input:

1000
1000000000
474148191
474148190
250000000
349148191
286648191
255398191
239773191
242187501
238281251
237820066
237304688
237331785
237087645
237182617
237121582
237091064
237075805
237080016
237076202
237074295
237074851
237074374
237074135
237074176
237074117
237074105
237074102
237074097
2370...

output:

? 1 500000001
? 2 500000001
? 250000001 500000001
? 125000001 500000001
? 187500001 500000001
? 218750001 500000001
? 234375001 500000001
? 242187501 500000001
? 238281251 500000001
? 236328126 500000001
? 237304688 500000001
? 236816407 500000001
? 237060547 500000001
? 237182617 500000001
? 237121...

result:

ok ok (1000 test cases)

Test #20:

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

input:

1000
1000000000
230485382
230485383
249999930
124999930
167985382
136735382
121110382
117187430
117204132
115251007
116210868
115722587
115478446
115356376
115295341
115264823
115249564
115243377
115245750
115243843
115242889
115242900
115242661
115242770
115242711
115242681
115242666
115242659
1152...

output:

? 1 500000001
? 2 500000001
? 750000001 500000001
? 875000001 500000001
? 937500001 500000001
? 906250001 500000001
? 890625001 500000001
? 882812501 500000001
? 886718751 500000001
? 884765626 500000001
? 883789063 500000001
? 884277344 500000001
? 884521485 500000001
? 884643555 500000001
? 884704...

result:

ok ok (1000 test cases)

Test #21:

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

input:

1000
1000000000
288090905
288090906
250000000
329346805
266846805
256840905
251221805
249028405
247315555
247075280
246338993
246586998
246342857
246220787
246277958
246247441
246232182
246224553
246220738
246218879
246219785
246219308
246219070
246218951
246218891
246218861
246218864
246218856
2462...

output:

? 1 500000001
? 2 500000001
? 750000001 500000001
? 875000001 500000001
? 937500001 500000001
? 968750001 500000001
? 953125001 500000001
? 960937501 500000001
? 957031251 500000001
? 958984376 500000001
? 958007813 500000001
? 958496094 500000001
? 958251953 500000001
? 958129883 500000001
? 958068...

result:

ok ok (1000 test cases)

Test #22:

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

input:

1000
999999999
499999998
499999997
249999999
374999998
312499998
281249999
296874998
289062498
285156248
283203123
282226561
281738280
281494139
281372070
281433104
281402587
281387328
281379700
281383514
281381607
281380654
281381131
281381370
281381488
281381430
281381459
281381445
281381453
28138...

output:

? 1 500000000
? 2 500000000
? 250000001 500000000
? 125000001 500000000
? 187500001 500000000
? 218750001 500000000
? 203125001 500000000
? 210937501 500000000
? 214843751 500000000
? 216796876 500000000
? 217773438 500000000
? 218261719 500000000
? 218505860 500000000
? 218627930 500000000
? 218566...

result:

ok ok (1000 test cases)

Test #23:

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

input:

1000
999999999
499999957
499999958
249999957
125000000
187500000
218749957
203124957
195312457
191406207
189453082
188476519
187988281
188232378
188110351
188171386
188201860
188186601
188178972
188175200
188177064
188176153
188176587
188176348
188176229
188176169
188176139
188176154
188176147
18817...

output:

? 1 500000000
? 2 500000000
? 750000000 500000000
? 625000000 500000000
? 687500000 500000000
? 718750000 500000000
? 703125000 500000000
? 695312500 500000000
? 691406250 500000000
? 689453125 500000000
? 688476562 500000000
? 687988281 500000000
? 688232421 500000000
? 688110351 500000000
? 688171...

result:

ok ok (1000 test cases)

Test #24:

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

input:

1000
999999999
324545945
324545944
249999999
199545945
187500001
168295945
171875001
164062501
164389695
162436570
163085938
162597657
162353516
162314500
162292481
162283983
162277222
162276354
162273407
162274447
162273493
162273016
162273168
162273049
162272989
162272987
162272974
162272980
16227...

output:

? 1 500000000
? 2 500000000
? 250000001 500000000
? 125000001 500000000
? 187500001 500000000
? 156250001 500000000
? 171875001 500000000
? 164062501 500000000
? 160156251 500000000
? 162109376 500000000
? 163085938 500000000
? 162597657 500000000
? 162353516 500000000
? 162231446 500000000
? 162292...

result:

ok ok (1000 test cases)

Test #25:

score: 0
Accepted
time: 61ms
memory: 3860kb

input:

1000
999999999
487015083
487015084
249999935
362015083
299515083
268265083
252640083
244827583
246093685
244140560
243851020
243652279
243606879
243530209
243545844
243515326
243514951
243507696
243511137
243509230
243508276
243507799
243507561
243507576
243507516
243507532
243507517
243507510
24350...

output:

? 1 500000000
? 2 500000000
? 750000000 500000000
? 875000000 500000000
? 812500000 500000000
? 781250000 500000000
? 765625000 500000000
? 757812500 500000000
? 753906250 500000000
? 755859375 500000000
? 756835937 500000000
? 756347656 500000000
? 756591796 500000000
? 756469726 500000000
? 756530...

result:

ok ok (1000 test cases)

Test #26:

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

input:

1000
999999999
265285129
265285128
249999999
374264885
311764885
280514885
264889885
257472629
260983635
259030510
258053947
257565666
257321525
257350559
257289524
257291007
257275748
257281895
257278081
257276174
257275220
257275271
257275032
257275101
257275042
257275012
257275017
257275009
25727...

output:

? 1 500000000
? 2 500000000
? 250000001 500000000
? 125000001 500000000
? 62500001 500000000
? 31250001 500000000
? 15625001 500000000
? 7812501 500000000
? 11718751 500000000
? 9765626 500000000
? 8789063 500000000
? 8300782 500000000
? 8056641 500000000
? 7934571 500000000
? 7995606 500000000
? 80...

result:

ok ok (1000 test cases)

Test #27:

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

input:

1000
536870912
261621269
261621270
127403541
67108864
93849109
77071893
75497472
79691776
78290725
77242149
76717861
76809749
76678677
76652325
76645909
76635941
76637717
76633621
76633893
76632869
76633109
76632853
76632741
76632789
76632757
76632741
76632733
76632737
76632735
76632734
76632733
681...

output:

? 1 268435457
? 2 268435457
? 402653185 268435457
? 335544321 268435457
? 369098753 268435457
? 352321537 268435457
? 343932929 268435457
? 348127233 268435457
? 350224385 268435457
? 351272961 268435457
? 351797249 268435457
? 352059393 268435457
? 351928321 268435457
? 351862785 268435457
? 351895...

result:

ok ok (1000 test cases)

Test #28:

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

input:

1000
536870911
244408485
244408486
134217728
182757403
210854053
194076837
185688229
181493925
180660251
180445349
180135963
180183205
180052133
180070427
180037659
180035749
180029467
180031653
180029605
180028581
180028955
180028699
180028571
180028517
180028539
180028523
180028515
180028513
18002...

output:

? 1 268435456
? 2 268435456
? 402653184 268435456
? 469762048 268435456
? 503316480 268435456
? 486539264 268435456
? 478150656 268435456
? 473956352 268435456
? 471859200 268435456
? 472907776 268435456
? 472383488 268435456
? 472645632 268435456
? 472514560 268435456
? 472449024 268435456
? 472481...

result:

ok ok (1000 test cases)

Extra Test:

score: -3
Extra Test Failed : Runtime Error on 2

input:

1
999999999
499999999
499999999
499999999
499999998
499999999
249999999
227516349
499999998
2
3

output:

? 1 500000000
? 1 500000001
? 250000000 749999999
? 250000000 750000000
? 250000001 750000000
? 999999999 750000000
? 977516349 750000000
? 250000000 750000000
? 250000000 249999998
? 250000000 250000003

result: