QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#853631#9734. Identify Chorducup-team5243#AC ✓74ms3720kbC++174.7kb2025-01-11 17:53:402025-01-11 17:53:42

Judging History

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

  • [2025-01-11 17:53:42]
  • 评测
  • 测评结果:AC
  • 用时:74ms
  • 内存:3720kb
  • [2025-01-11 17:53:40]
  • 提交

answer

#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;

// a,b : 0-indexed
i64 query(i64 a, i64 b);

// a,b : 0-indexed
i64 answer(i64 a, i64 b);

#ifdef RANTES
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 INFL = (1ll << 31);
random_device seed_gen;
mt19937_64 engine(seed_gen());
i64 randint(i64 min, i64 max) {
    assert(min <= max);
    return engine() % (max - min + 1) + min;
}
vector<i64> randvec(int n, i64 min, i64 max) {
    vector<i64> rev(n);
    for (int i=0; i<n; i++) { rev[i] = randint(min, max); }
    return rev;
}
vector<i64> p;
i64 u,v;
vector<vector<i64>> dist;
i64 query(i64 a, i64 b) {
    //cout << "query " << a << " " << b <<  " -> " << dist[a][b] << endl;
    return dist[a][b];
}
i64 answer(i64 a, i64 b) {
    if(!((a == u && b == v) || (a == v && b == u))){
        cout << p.size() << " " << u << " " << v << endl;
        return -1;
    }
    return 1;
}
#else

i64 query(i64 a, i64 b){
    cout << "? " << (a+1) << " " << (b+1) << "\n";
    cout.flush();
    i64 x; cin >> x;
    return x;
}
i64 answer(i64 a, i64 b){
    cout << "! " << (a+1) << " " << (b+1) << "\n";
    cout.flush();
    i64 x; cin >> x;
    return x;
}
#endif

i64 testcase(i64 N){
    i64 x = 0;
    i64 y = 0;
    auto tr = [&](i64 s) -> int {
        if(y) s = (N - s) % N;
        s = (s+x)%N;
        return s;
    };
    auto query_x = [&](i64 s, i64 t) -> i64 {
        s = tr(s);
        t = tr(t);
        if(s > t) swap(s, t);
        return query(s, t);
    };
    auto answer_x = [&](i64 s, i64 t) -> i64 {
        s = tr(s);
        t = tr(t);
        if(s > t) swap(s, t);
        return answer(s, t);
    };
    while(true){
        i64 a = 0;
        i64 b = N/2;
        i64 dab = 0;
        if(N % 2 == 0){
            dab = query_x(a, b);
            if(dab == N/2){ x++; continue; }
        } else {
            dab = query_x(a, b);
            if(dab == N/2){
                b++;
                dab = query_x(a, b);
                if(dab == N/2){ x++; continue; }
            }
        }
        //cout << "##" << endl;
        if(dab == 1) return answer_x(a, b);
        //cout << "##" << endl;
        if(query_x((a+N-1)%N, b) < dab){
            b = (b + 1) % N;
            b = (N - b) % N;
            y = 1;
            x += N - 1; x %= N;
            dab--;
        }
        //cout << "##" << endl;
        i64 ng = dab+1, ok = 0;
        while(ok + 1 < ng){
            i64 mid = (ok + ng) / 2;
            if(query_x(mid, b) + mid != dab){
                ng = mid;
            } else ok = mid;
        }
        //cout << "a = " << a << " , b = " << b << " , x = " << x << " , y = " << y << " , ok = " << ok << endl;
        //rep(i,N){ cout << tr(i) << " "; } cout << endl;
        //cout << "##" << endl;
        if(abs(ok - (b - (dab-ok) + 1)) != 1 && query_x(ok, b - (dab-ok) + 1) == 1){
            return answer_x(ok, b - (dab-ok) + 1);
        }
        return answer_x(ok, b + (dab-ok) - 1);
    }
}

#ifdef RANTES
i64 test2(i64 N, i64 u, i64 v) {
    //cout << N << " " << u << " " << v << endl;
    ::u = u;
    ::v = v;
    dist = vector(N, vector<i64>(N, INFL));
    p.assign(N, 0);
    for(int i=0; i<N; i++) p[i] = i;
    for(int i=0; i<N; i++) dist[i][i] = 0;
    for (int i=0; i<N; i++) {
        dist[p[i]][p[(i+1)%N]]  = 1;
        dist[p[(i+1)%N]][p[i]]  = 1;
    }
    dist[u][v] = 1;
    dist[v][u] = 1;
    for (int k=0; k<N; k++) for (int i=0; i<N; i++) for (int j=0; j<N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    return testcase(N);
}

void test() {
    i64 N = randint(4, 20);
    u = randint(0, N-1);
    v = (u + randint(0, N-4) + 2) % N;
    test2(N, u, v);
}
#endif

int main(){
    //ios::sync_with_stdio(false); cin.tie(nullptr);
#ifdef RANTES
    i64 do_test = 1;
    if(do_test == 1){
        rep(i,100){
            test();
        }
    } else if(do_test == 2) {
        int T; cin >> T;
        rep(t,T){
            i64 N, u, v; cin >> N >> u >> v;
            test2(N, u, v);
        }
    } else {
#endif
        int T; cin >> T; rep(t,T){
            i64 N; cin >> N;
            if(testcase(N) == -1) break;
        }
#ifdef RANTES
    }
#endif
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

input:

2
6
2
2
1
1
1
1
4
1
1

output:

? 1 4
? 4 6
? 2 4
? 3 4
? 2 4
! 2 4
? 1 3
! 1 3

result:

ok ok (2 test cases)

Test #2:

score: 0
Accepted
time: 10ms
memory: 3708kb

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #3:

score: 0
Accepted
time: 9ms
memory: 3588kb

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #4:

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

input:

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

output:

? 1 13
? 13 25
? 5 13
? 3 13
? 2 13
? 1 6
! 1 6
? 1 13
? 13 25
? 13 22
? 13 24
? 17 25
! 9 25
? 1 13
? 13 25
? 13 20
? 13 23
? 13 22
? 20 23
! 6 23
? 1 13
? 13 25
? 4 13
? 2 13
? 3 13
? 3 11
! 3 11
? 1 14
? 14 26
? 14 20
? 14 17
? 14 19
? 18 20
! 18 20
? 1 14
? 14 26
? 14 21
? 14 24
? 14 25
? 22 25
...

result:

ok ok (1000 test cases)

Test #5:

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

input:

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

output:

? 1 15
? 15 29
? 6 15
? 3 15
? 4 15
? 3 8
! 3 22
? 1 15
? 15 28
? 15 22
? 15 25
? 15 24
? 15 23
? 22 24
! 8 24
? 1 16
? 16 30
? 3 16
? 2 16
? 2 15
! 2 17
? 1 15
? 15 29
? 3 15
? 2 15
? 2 13
! 2 13
? 1 15
? 15 28
? 15 24
? 15 22
? 15 23
? 16 23
! 14 23
? 1 15
? 15 29
? 4 15
? 2 15
? 3 15
? 3 12
! 3 1...

result:

ok ok (1000 test cases)

Test #6:

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

input:

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

output:

? 1 17
? 17 32
? 8 17
? 4 17
? 6 17
? 5 17
? 5 9
! 5 9
? 1 16
? 16 30
? 16 23
? 16 27
? 16 29
? 16 28
? 26 28
! 26 28
? 1 17
? 2 18
? 3 19
? 2 19
? 10 19
? 6 19
? 8 19
? 9 19
? 9 12
! 9 26
? 1 16
? 16 31
? 4 16
? 5 16
? 4 15
! 4 15
? 1 17
? 17 32
? 5 17
? 3 17
? 4 17
? 3 13
! 3 21
? 1 17
? 17 32
? 5...

result:

ok ok (1000 test cases)

Test #7:

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

input:

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

output:

? 1 18
? 2 19
? 1 19
? 10 19
? 6 19
? 4 19
? 5 19
? 5 7
! 5 31
? 1 17
? 17 33
? 5 17
? 7 17
? 6 17
? 6 15
! 6 15
? 1 17
? 17 33
? 17 28
? 17 31
? 17 30
? 24 31
! 24 31
? 1 18
? 18 34
? 18 29
? 18 32
? 18 31
? 25 32
! 11 32
? 1 18
? 18 34
? 7 18
? 4 18
? 2 18
? 3 18
? 2 9
! 2 27
? 1 18
? 18 35
? 8 18...

result:

ok ok (1000 test cases)

Test #8:

score: 0
Accepted
time: 9ms
memory: 3720kb

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #9:

score: 0
Accepted
time: 12ms
memory: 3580kb

input:

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

output:

? 1 19
? 19 37
? 19 29
? 19 25
? 19 27
? 19 26
? 24 27
! 14 27
? 1 19
? 19 36
? 19 28
? 19 24
? 19 26
? 19 27
? 26 28
! 26 28
? 1 20
? 20 38
? 6 20
? 8 20
? 7 20
? 7 18
! 7 18
? 1 19
? 19 37
? 9 19
? 13 19
? 15 19
? 14 19
? 13 17
! 13 21
? 1 19
? 19 37
? 19 31
? 19 28
? 19 27
? 19 26
? 19 27
! 19 27...

result:

ok ok (1000 test cases)

Test #10:

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

input:

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

output:

? 1 20
? 20 39
? 10 20
? 15 20
? 12 20
? 13 20
? 14 20
? 13 15
! 13 25
? 1 20
? 20 38
? 20 34
? 20 32
? 20 33
? 21 33
! 21 33
? 1 20
? 2 21
? 3 22
? 2 22
? 12 22
? 16 22
? 14 22
? 15 22
? 15 18
! 15 26
? 1 20
? 20 39
? 7 20
? 4 20
? 2 20
? 3 20
? 2 10
! 2 10
? 1 20
? 20 38
? 20 31
? 20 27
? 20 25
? ...

result:

ok ok (1000 test cases)

Test #11:

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

input:

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

output:

? 1 21
? 21 40
? 7 21
? 10 21
? 8 21
? 7 16
! 7 26
? 1 21
? 21 40
? 10 21
? 15 21
? 12 21
? 13 21
? 12 15
! 12 27
? 1 21
? 21 40
? 9 21
? 5 21
? 3 21
? 4 21
? 3 9
! 3 33
? 1 21
? 21 40
? 5 21
? 3 21
? 2 21
? 1 14
! 1 14
? 1 21
? 21 40
? 21 32
? 21 28
? 21 26
? 21 27
? 23 28
! 23 28
? 1 21
? 21 40
? ...

result:

ok ok (1000 test cases)

Test #12:

score: 0
Accepted
time: 21ms
memory: 3704kb

input:

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

output:

? 1 22
? 22 42
? 7 22
? 4 22
? 5 22
? 6 22
? 6 17
! 6 17
? 1 21
? 21 41
? 21 33
? 21 37
? 21 39
? 21 38
? 33 38
! 33 38
? 1 21
? 21 41
? 21 37
? 21 39
? 21 40
? 26 40
! 16 40
? 1 21
? 21 41
? 21 35
? 21 38
? 21 37
? 21 36
? 26 36
! 16 36
? 1 21
? 21 41
? 7 21
? 10 21
? 12 21
? 11 21
? 10 19
! 10 23
...

result:

ok ok (1000 test cases)

Test #13:

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

input:

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

output:

? 1 22
? 22 43
? 3 22
? 4 22
? 3 21
! 3 21
? 1 22
? 22 42
? 10 22
? 15 22
? 17 22
? 16 22
? 16 20
! 16 20
? 1 22
? 22 43
? 4 22
? 6 22
? 5 22
? 5 21
! 5 21
? 1 22
? 22 43
? 22 34
? 22 39
? 22 37
? 22 36
? 22 35
? 30 35
! 14 35
? 1 22
? 1 23
? 2 23
? 2 24
? 1 24
? 12 24
? 7 24
? 4 24
? 5 24
? 6 24
? ...

result:

ok ok (1000 test cases)

Test #14:

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

input:

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

output:

? 1 23
? 2 24
? 3 25
? 2 25
? 13 25
? 8 25
? 5 25
? 6 25
? 7 25
? 6 9
! 6 41
? 1 23
? 23 44
? 7 23
? 4 23
? 5 23
? 6 23
? 5 17
! 5 29
? 1 22
? 22 43
? 22 38
? 22 35
? 22 37
? 22 36
? 24 36
! 24 36
? 1 22
? 1 23
? 2 23
? 2 24
? 3 24
? 2 24
? 13 24
? 18 24
? 21 24
? 19 24
? 18 20
! 18 28
? 1 23
? 23 4...

result:

ok ok (1000 test cases)

Test #15:

score: 0
Accepted
time: 12ms
memory: 3588kb

input:

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

output:

? 1 23
? 23 45
? 23 35
? 23 40
? 23 43
? 23 44
? 41 45
! 5 45
? 1 23
? 23 45
? 23 37
? 23 41
? 23 43
? 23 42
? 34 42
! 12 42
? 1 23
? 23 45
? 6 23
? 3 23
? 4 23
? 5 23
? 5 18
! 5 18
? 1 23
? 23 45
? 9 23
? 5 23
? 7 23
? 6 23
? 6 14
! 6 32
? 1 23
? 23 45
? 7 23
? 4 23
? 2 23
? 3 23
? 2 14
! 2 14
? 1 ...

result:

ok ok (1000 test cases)

Test #16:

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

input:

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

output:

? 1 24
? 24 46
? 10 24
? 15 24
? 12 24
? 11 24
? 11 17
! 11 31
? 1 24
? 24 46
? 6 24
? 3 24
? 4 24
? 5 24
? 4 19
! 4 29
? 1 24
? 24 46
? 12 24
? 6 24
? 9 24
? 7 24
? 8 24
? 7 9
! 7 39
? 1 24
? 24 46
? 11 24
? 6 24
? 8 24
? 7 24
? 6 11
! 6 11
? 1 24
? 24 46
? 4 24
? 2 24
? 1 20
! 1 20
? 1 24
? 24 46
...

result:

ok ok (1000 test cases)

Test #17:

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

input:

1000
1000000000
499999999
499999998
250000000
374999999
312500000
343750000
359375000
367187500
371093750
373046874
372070312
371582032
371826173
371948243
372009278
372039796
372055054
372047425
372043611
372045519
372046473
372046950
372047188
372047307
372047367
372047396
372047381
372047375
3720...

output:

? 1 500000001
? 500000001 1000000000
? 500000001 750000001
? 500000001 875000001
? 500000001 812500001
? 500000001 843750001
? 500000001 859375001
? 500000001 867187501
? 500000001 871093751
? 500000001 873046876
? 500000001 872070314
? 500000001 871582033
? 500000001 871826174
? 500000001 871948244...

result:

ok ok (1000 test cases)

Test #18:

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

input:

1000
1000000000
499999969
499999970
249999984
124999992
62500027
93750025
109374993
101562494
97656244
95703150
96679713
97167963
96923823
96801753
96740749
96771236
96755977
96748379
96752163
96750256
96749302
96748856
96749095
96749183
96749124
96749100
96749109
96749102
96749098
96749098
96749097...

output:

? 1 500000001
? 500000001 1000000000
? 249999986 500000001
? 374999978 500000001
? 437499974 500000001
? 406249976 500000001
? 390624977 500000001
? 398437476 500000001
? 402343726 500000001
? 404296851 500000001
? 403320288 500000001
? 402832007 500000001
? 403076147 500000001
? 403198217 500000001...

result:

ok ok (1000 test cases)

Test #19:

score: 0
Accepted
time: 26ms
memory: 3584kb

input:

1000
1000000000
474148191
474148192
237074097
355611143
296342619
266708357
251891226
244482661
240778378
238926237
238000166
237537131
237305613
237189854
237131975
237103035
237088565
237081330
237077713
237075904
237075000
237074548
237074322
237074209
237074152
237074124
237074110
237074103
2370...

output:

? 1 500000001
? 500000001 1000000000
? 237074097 500000001
? 118537049 500000001
? 177805573 500000001
? 207439835 500000001
? 222256966 500000001
? 229665531 500000001
? 233369814 500000001
? 235221955 500000001
? 236148026 500000001
? 236611061 500000001
? 236842579 500000001
? 236958338 500000001...

result:

ok ok (1000 test cases)

Test #20:

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

input:

1000
1000000000
230485382
230485381
115242690
172863967
144053294
129647958
122445290
118843956
117043289
116142955
115692788
115467705
115355163
115298892
115270757
115256689
115249655
115246138
115244380
115243501
115243061
115242841
115242731
115242676
115242663
115242662
115242657
115242658
1152...

output:

? 1 500000001
? 500000001 1000000000
? 500000001 884757309
? 500000001 827135964
? 500000001 855946637
? 500000001 870351973
? 500000001 877554641
? 500000001 881155975
? 500000001 882956642
? 500000001 883856976
? 500000001 884307143
? 500000001 884532226
? 500000001 884644768
? 500000001 884701039...

result:

ok ok (1000 test cases)

Test #21:

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

input:

1000
1000000000
288090905
288090904
348392258
276369532
252079541
258363850
249361009
247578121
247110299
246452766
246547621
246266282
246312097
246241763
246231114
246224180
246222322
246219784
246220124
246219025
246219235
246218960
246218887
246218892
246218858
246218869
246218860
246218856
2462...

output:

? 1 500000001
? 500000001 1000000000
? 500000001 855954548
? 500000001 927977274
? 500000001 963988637
? 500000001 945982956
? 500000001 954985797
? 500000001 959487217
? 500000001 957236507
? 500000001 958361862
? 500000001 957799185
? 500000001 958080524
? 500000001 958221193
? 500000001 958150859...

result:

ok ok (1000 test cases)

Test #22:

score: 0
Accepted
time: 52ms
memory: 3644kb

input:

1000
999999999
499999998
499999999
250000000
374999999
312499999
281250000
296874999
289062499
285156249
283203124
282226562
281738281
281494140
281372071
281433105
281402588
281387329
281379701
281383515
281381608
281380655
281381132
281381371
281381489
281381431
281381460
281381446
281381453
28138...

output:

? 1 500000000
? 500000000 999999999
? 250000000 500000000
? 125000000 500000000
? 187500000 500000000
? 218750000 500000000
? 203125000 500000000
? 210937500 500000000
? 214843750 500000000
? 216796875 500000000
? 217773437 500000000
? 218261718 500000000
? 218505859 500000000
? 218627929 500000000
...

result:

ok ok (1000 test cases)

Test #23:

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

input:

1000
999999999
499999957
499999956
249999978
125000032
187500027
218749981
203124983
195312484
191406234
189453109
188476547
187988309
188232407
188110380
188171415
188201890
188186631
188179002
188175230
188177095
188176141
188175707
188175946
188176065
188176125
188176155
188176151
188176144
18817...

output:

? 1 500000000
? 500000000 999999999
? 500000000 750000021
? 500000000 625000032
? 500000000 687500027
? 500000000 718750024
? 500000000 703125026
? 500000000 695312527
? 500000000 691406277
? 500000000 689453152
? 500000000 688476590
? 500000000 687988309
? 500000000 688232450
? 500000000 688110380
...

result:

ok ok (1000 test cases)

Test #24:

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

input:

1000
999999999
324545945
324545946
162272974
243409459
202841216
182557094
172415033
167344003
164808488
163540730
162906851
162589912
162431442
162352207
162312590
162292781
162282877
162277925
162275449
162274211
162273592
162273282
162273127
162273050
162273011
162272992
162272982
162272977
16227...

output:

? 1 500000000
? 500000000 999999999
? 162272974 500000000
? 81136487 500000000
? 121704730 500000000
? 141988852 500000000
? 152130913 500000000
? 157201943 500000000
? 159737458 500000000
? 161005216 500000000
? 161639095 500000000
? 161956034 500000000
? 162114504 500000000
? 162193739 500000000
?...

result:

ok ok (1000 test cases)

Test #25:

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

input:

1000
999999999
487015083
487015082
243507541
134738687
195615573
226054016
241273237
248882848
247312282
245409879
244458678
243983077
243745277
243626377
243566927
243537202
243522339
243514908
243511192
243509334
243508405
243507941
243507709
243507593
243507535
243507512
243507520
243507513
24350...

output:

? 1 500000000
? 500000000 999999999
? 500000000 756492458
? 500000000 634738687
? 500000000 695615573
? 500000000 726054016
? 500000000 741273237
? 500000000 748882848
? 500000000 752687653
? 500000000 754590056
? 500000000 755541257
? 500000000 756016858
? 500000000 756254658
? 500000000 756373558
...

result:

ok ok (1000 test cases)

Test #26:

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

input:

1000
999999999
265285129
265285130
367357434
315586167
282425526
265845205
257555045
261140049
259067509
258031239
257513104
257295977
257383571
257318804
257286421
257279785
257278325
257275737
257276301
257275289
257275231
257275036
257275104
257275041
257275009
257275021
257275013
257275009
25727...

output:

? 1 500000000
? 500000000 999999999
? 132642566 500000000
? 66321283 500000000
? 33160642 500000000
? 16580321 500000000
? 8290161 500000000
? 4145081 500000000
? 6217621 500000000
? 7253891 500000000
? 7772026 500000000
? 8031093 500000000
? 7901559 500000000
? 7966326 500000000
? 7998709 500000000...

result:

ok ok (1000 test cases)

Test #27:

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

input:

1000
536870912
261621269
261621268
130810634
72219504
98107976
81756647
79684484
77668815
77640567
76646857
77129588
76874098
76746353
76682481
76650545
76634577
76638873
76634881
76632885
76633579
76633080
76632830
76632761
76632767
76632736
76632746
76632738
76632734
76632734
76632733
6814188
1
53...

output:

? 1 268435457
? 268435457 536870912
? 268435457 406060278
? 268435457 340654961
? 268435457 373357620
? 268435457 357006291
? 268435457 348830626
? 268435457 352918459
? 268435457 350874543
? 268435457 351896501
? 268435457 351385522
? 268435457 351641012
? 268435457 351768757
? 268435457 351832629
...

result:

ok ok (1000 test cases)

Test #28:

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

input:

1000
536870911
244408485
244408484
146231213
183306363
176782274
192026191
184388426
180569543
181396922
180442202
180092182
180203522
180084182
180032512
180054347
180039430
180031971
180028782
180030107
180029175
180028709
180028548
180028593
180028535
180028518
180028521
180028514
180028514
18002...

output:

? 1 268435456
? 268435456 536870911
? 268435456 414666669
? 268435456 475768790
? 268435456 445217730
? 268435456 460493260
? 268435456 468131025
? 268435456 471949908
? 268435456 473859349
? 268435456 472904629
? 268435456 472427269
? 268435456 472665949
? 268435456 472546609
? 268435456 472486939
...

result:

ok ok (1000 test cases)

Extra Test:

score: 0
Extra Test Passed