QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#883534#9734. Identify ChordzhulexuanAC ✓45ms3840kbC++144.1kb2025-02-05 16:46:592025-02-05 16:47:06

Judging History

This is the latest submission verdict.

  • [2025-02-05 16:47:06]
  • Judged
  • Verdict: AC
  • Time: 45ms
  • Memory: 3840kb
  • [2025-02-05 16:46:59]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define FF fflush(stdout)
#define fr(i,l,r) for (i=(l); i<=(r); i++)
#define rfr(i,l,r) for (i=(l); i>=(r); i--)
template<typename T>inline void read(T &n){
    T w=1; n=0; char ch=getchar();
    while (!isdigit(ch) && ch!=EOF){ if (ch=='-') w=-1; ch=getchar(); }
    while (isdigit(ch) && ch!=EOF){ n=(n<<3)+(n<<1)+(ch&15); ch=getchar(); }
    n*=w;
}
template<typename T>inline void write(T x){
    if (x==0){ putchar('0'); return ; }
    T tmp;
    if (x>0) tmp=x;
    else tmp=-x;
    if (x<0) putchar('-');
    char F[105];
    long long cnt=0;
    while (tmp){
        F[++cnt]=tmp%10+48;
        tmp/=10;
    }
    while (cnt) putchar(F[cnt--]);
}
#define Min(x,y) x = min(x,y)
#define Max(x,y) x = max(x,y)
//基础配置=================================================================================
const bool flag = true;
ll n, ans;
struct grader{
    ll cnt, n,x,y;
    ll N(){ return n; }
    ll dis(ll x,ll y){ return min(abs(x-y),n-abs(x-y)); }
    void init(){ cnt = 0; read(n), read(x), read(y); }
    ll qry(ll l,ll r){
        cnt++;
        if (cnt>40){ printf("To many query !!!\n"); exit(0); }
        ll ans = dis(l,r);
        Min( ans , dis(l,x) + 1 + dis(y,r) );
        Min( ans , dis(l,y) + 1 + dis(x,r) );
        printf("qry %lld %lld = %lld\n",l,r,ans);
        return ans;
    }
    void answer(ll l,ll r){
        if (l==x && r==y){ printf("OK : %lld %lld\n",x,y); return ; }
        if (l==y && r==x){ printf("OK : %lld %lld\n",x,y); return ; }
        printf("Wrong : get %lld %lld , expected %lld %lld\n",l,r,x,y); exit(0);
    }
}gr;
ll qry(ll x,ll y){
    while (x>n) x -= n;
    while (y>n) y -= n;
    while (x<1) x += n;
    while (y<1) y += n;
    if (flag){
        printf("? %lld %lld\n",x,y), FF;
        read(ans); return ans;
    }
    else return ans = gr.qry(x,y);
}
void print(ll x,ll y){
    while (x>n) x -= n;
    while (y>n) y -= n;
    while (x<1) x += n;
    while (y<1) y += n;
    if (flag){
        printf("! %lld %lld\n",x,y), FF;
        read(ans); return ;
    }
    else gr.answer(x,y);
}
ll To(ll x,ll y,ll d){
    while (x>y) y += n;
    if (d==1) return y-x;
    else return n-(y-x);
}
void work(){
    if (!flag) gr.init(), n = gr.N();
    else read(n);
    ll x = 1, y = n/2 + 1;
    while (qry(x,y)==n/2){
        if (n&1){ if (qry(x,y+1)!=n/2){ y++, swap(x,y); break; } }
        x++, y++;
    }
    x = (x-1)%n+1, y = (y-1)%n+1;
    ll k = qry(x,y);
    if (ans==1){ print(x,y); return ; }
    // if (To(x,y)==n/2){
        // if (qry(x+1,y)==k || qry(x,y-1)==k) swap(x,y);
    // }
    // printf("x,y = %lld,%lld\n",x,y);
    ll d = 1; if (qry(x-1,y)==k-1) d = -1;
    // if (x<y){
        // if (qry(x+1,y)!=k-1 && qry(x,y-1)!=k-1) swap(x,y);
    // }
    // else{
        // if (qry())
    // }
    // printf("%lld %lld , k = %lld , d = %lld\n",x,y,k,d);
    // if (qry(x,y-k+1)==1){ print(x,y-k+1); return ; }
    // if (qry(x+k-1,y)==1){ print(x+k-1,y); return ; }
    ll l = x, r = y, mid, p = l;// while (l>r) r += n;
    if (d==1) l = x, r = y; else l = y, r = x; while (l>r) r += n;
    // else { }
    // printf("l = %lld , r = %lld , k = %lld\n",l,r,k);
    while (l<=r){
        // printf("\nl = %lld , r = %lld\n",l,r);
        mid = (l+r)>>1;
        if (qry(mid,y)==k-To(x,mid,d)){
            p = mid;
            if (d==1) l = mid+1;
            else r = mid-1;
            // l = mid+1, p = mid;
        }
        else{
            if (d==1) r = mid-1;
            else l = mid+1;
            // r = mid-1;
        }
    }
    // printf("p = %lld\n",p);
    // ll p2 = ;
    // if (d==1) 
    // p2 = y - (k-1-To(x,p,d));
    // else p2 = y + (k-1-To(x,p,d));
    ll p2 = y - (k-1-To(x,p,d));
    if (qry(p,p2)!=1) p2 = 2*y-p2;
    l = p, r = p2;
    // l = p, r = y - (qry(l,y)-1);
    print(l,r); return ;
}
int main(){
	// freopen("a.in","r",stdin);
//	freopen(".out","w",stdout);
    ll qt; read(qt);
    while (qt--) work();
    return 0;
}
//g++ a.cpp -o a -Wall -Wl,--stack=512000000 -std=c++11 -O2

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
6
2
2
2
1
1
1
1
4
1
1
1

output:

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

result:

ok ok (2 test cases)

Test #2:

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

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #3:

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

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #4:

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

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #5:

score: 0
Accepted
time: 6ms
memory: 3712kb

input:

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

output:

? 1 15
? 1 15
? 29 15
? 8 15
? 4 15
? 2 15
? 3 15
? 3 8
! 3 22
? 1 15
? 1 15
? 28 15
? 22 15
? 26 15
? 24 15
? 23 15
? 24 8
! 24 8
? 1 16
? 1 16
? 30 16
? 8 16
? 4 16
? 2 16
? 3 16
? 2 15
! 2 17
? 1 15
? 1 15
? 29 15
? 8 15
? 4 15
? 2 15
? 3 15
? 2 13
! 2 13
? 1 15
? 1 15
? 28 15
? 22 15
? 26 15
? 2...

result:

ok ok (1000 test cases)

Test #6:

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

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #7:

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

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #8:

score: 0
Accepted
time: 15ms
memory: 3712kb

input:

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

output:

? 1 19
? 2 20
? 2 20
? 1 20
? 11 20
? 16 20
? 18 20
? 19 20
? 18 20
! 18 20
? 1 19
? 1 19
? 36 19
? 28 19
? 33 19
? 35 19
? 34 19
? 35 19
! 35 19
? 1 19
? 1 19
? 36 19
? 10 19
? 5 19
? 2 19
? 3 19
? 4 19
? 4 10
! 4 10
? 1 19
? 1 19
? 36 19
? 10 19
? 5 19
? 2 19
? 3 19
? 4 19
? 3 17
! 3 17
? 1 19
? 2...

result:

ok ok (1000 test cases)

Test #9:

score: 0
Accepted
time: 15ms
memory: 3712kb

input:

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

output:

? 1 19
? 1 19
? 37 19
? 28 19
? 23 19
? 25 19
? 26 19
? 27 19
? 27 14
! 27 14
? 1 19
? 1 19
? 36 19
? 28 19
? 23 19
? 25 19
? 26 19
? 27 19
? 28 12
! 28 26
? 1 20
? 1 20
? 38 20
? 10 20
? 5 20
? 7 20
? 8 20
? 7 18
! 7 18
? 1 19
? 1 19
? 37 19
? 10 19
? 15 19
? 12 19
? 13 19
? 14 19
? 13 17
! 13 21
?...

result:

ok ok (1000 test cases)

Test #10:

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

input:

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

output:

? 1 20
? 1 20
? 39 20
? 10 20
? 15 20
? 12 20
? 13 20
? 14 20
? 13 15
! 13 25
? 1 20
? 1 20
? 38 20
? 29 20
? 34 20
? 31 20
? 32 20
? 33 20
? 33 19
! 33 21
? 1 20
? 2 21
? 3 22
? 3 22
? 2 22
? 12 22
? 17 22
? 14 22
? 15 22
? 16 22
? 15 18
! 15 26
? 1 20
? 1 20
? 39 20
? 10 20
? 5 20
? 2 20
? 3 20
? ...

result:

ok ok (1000 test cases)

Test #11:

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

input:

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

output:

? 1 21
? 1 21
? 40 21
? 11 21
? 5 21
? 8 21
? 6 21
? 7 21
? 7 16
! 7 26
? 1 21
? 1 21
? 40 21
? 11 21
? 16 21
? 13 21
? 12 21
? 12 15
! 12 27
? 1 21
? 1 21
? 40 21
? 11 21
? 5 21
? 2 21
? 3 21
? 4 21
? 3 9
! 3 33
? 1 21
? 1 21
? 40 21
? 11 21
? 5 21
? 2 21
? 1 21
? 1 14
! 1 14
? 1 21
? 1 21
? 40 21
...

result:

ok ok (1000 test cases)

Test #12:

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

input:

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

output:

? 1 22
? 1 22
? 42 22
? 11 22
? 5 22
? 8 22
? 6 22
? 7 22
? 6 17
! 6 17
? 1 21
? 1 21
? 41 21
? 31 21
? 37 21
? 40 21
? 38 21
? 38 9
! 38 33
? 1 21
? 1 21
? 41 21
? 31 21
? 37 21
? 40 21
? 38 21
? 39 21
? 40 16
! 40 16
? 1 21
? 1 21
? 41 21
? 31 21
? 37 21
? 34 21
? 35 21
? 36 21
? 36 16
! 36 16
? 1...

result:

ok ok (1000 test cases)

Test #13:

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

input:

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

output:

? 1 22
? 1 22
? 43 22
? 11 22
? 5 22
? 2 22
? 3 22
? 4 22
? 3 21
! 3 21
? 1 22
? 1 22
? 42 22
? 11 22
? 17 22
? 14 22
? 15 22
? 16 22
? 16 20
! 16 20
? 1 22
? 1 22
? 43 22
? 11 22
? 5 22
? 8 22
? 6 22
? 5 21
! 5 21
? 1 22
? 1 22
? 43 22
? 33 22
? 39 22
? 36 22
? 34 22
? 35 22
? 35 14
! 35 14
? 1 22
...

result:

ok ok (1000 test cases)

Test #14:

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

input:

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

output:

? 1 23
? 2 24
? 3 25
? 3 25
? 2 25
? 14 25
? 8 25
? 5 25
? 6 25
? 7 25
? 6 9
! 6 41
? 1 23
? 1 23
? 44 23
? 12 23
? 6 23
? 3 23
? 4 23
? 5 23
? 5 17
! 5 29
? 1 22
? 1 22
? 43 22
? 33 22
? 39 22
? 36 22
? 34 22
? 35 22
? 36 20
! 36 24
? 1 22
? 1 23
? 2 23
? 2 24
? 3 24
? 3 24
? 2 24
? 13 24
? 19 24
?...

result:

ok ok (1000 test cases)

Test #15:

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

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #16:

score: 0
Accepted
time: 7ms
memory: 3712kb

input:

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

output:

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

result:

ok ok (1000 test cases)

Test #17:

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

input:

1000
1000000000
499999999
499999999
499999998
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
3720...

output:

? 1 500000001
? 1 500000001
? 1000000000 500000001
? 750000001 500000001
? 875000001 500000001
? 812500001 500000001
? 843750001 500000001
? 859375001 500000001
? 867187501 500000001
? 871093751 500000001
? 873046876 500000001
? 872070313 500000001
? 871582032 500000001
? 871826172 500000001
? 87194...

result:

ok ok (1000 test cases)

Test #18:

score: 0
Accepted
time: 35ms
memory: 3712kb

input:

1000
1000000000
499999969
499999969
499999970
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
9674909...

output:

? 1 500000001
? 1 500000001
? 1000000000 500000001
? 250000001 500000001
? 375000001 500000001
? 437500001 500000001
? 406250001 500000001
? 390625001 500000001
? 398437501 500000001
? 402343751 500000001
? 404296876 500000001
? 403320313 500000001
? 402832032 500000001
? 403076172 500000001
? 40319...

result:

ok ok (1000 test cases)

Test #19:

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

input:

1000
1000000000
474148191
474148191
474148192
250000000
349148192
286648192
255398192
239773192
242187500
238281250
237820067
237304687
237331786
237087646
237182616
237121581
237091063
237075804
237080017
237076203
237074296
237074850
237074373
237074134
237074177
237074118
237074104
237074103
2370...

output:

? 1 500000001
? 1 500000001
? 1000000000 500000001
? 250000001 500000001
? 125000000 500000001
? 187500000 500000001
? 218750000 500000001
? 234375000 500000001
? 242187500 500000001
? 238281250 500000001
? 236328125 500000001
? 237304687 500000001
? 236816406 500000001
? 237060546 500000001
? 23718...

result:

ok ok (1000 test cases)

Test #20:

score: 0
Accepted
time: 44ms
memory: 3712kb

input:

1000
1000000000
230485382
230485382
230485381
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
1152...

output:

? 1 500000001
? 1 500000001
? 1000000000 500000001
? 750000001 500000001
? 875000001 500000001
? 937500001 500000001
? 906250001 500000001
? 890625001 500000001
? 882812501 500000001
? 886718751 500000001
? 884765626 500000001
? 883789063 500000001
? 884277344 500000001
? 884521485 500000001
? 88464...

result:

ok ok (1000 test cases)

Test #21:

score: 0
Accepted
time: 30ms
memory: 3712kb

input:

1000
1000000000
288090905
288090905
288090904
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
2462...

output:

? 1 500000001
? 1 500000001
? 1000000000 500000001
? 750000001 500000001
? 875000001 500000001
? 937500001 500000001
? 968750001 500000001
? 953125001 500000001
? 960937501 500000001
? 957031251 500000001
? 958984376 500000001
? 958007813 500000001
? 958496094 500000001
? 958251953 500000001
? 95812...

result:

ok ok (1000 test cases)

Test #22:

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

input:

1000
999999999
499999998
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
28138...

output:

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

result:

ok ok (1000 test cases)

Test #23:

score: 0
Accepted
time: 27ms
memory: 3712kb

input:

1000
999999999
499999957
499999957
499999956
249999957
124999999
187499999
218749956
203124956
195312456
191406206
189453081
188476518
187988280
188232377
188110350
188171385
188201859
188186600
188178971
188175199
188177063
188176152
188176586
188176347
188176228
188176168
188176140
188176153
18817...

output:

? 1 500000000
? 1 500000000
? 999999999 500000000
? 750000000 500000000
? 624999999 500000000
? 687499999 500000000
? 718749999 500000000
? 703124999 500000000
? 695312499 500000000
? 691406249 500000000
? 689453124 500000000
? 688476561 500000000
? 687988280 500000000
? 688232420 500000000
? 688110...

result:

ok ok (1000 test cases)

Test #24:

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

input:

1000
999999999
324545945
324545945
324545946
250000000
199545946
187500000
168295946
171875000
164062500
164389696
162436571
163085937
162597656
162353515
162314501
162292480
162283984
162277221
162276355
162273406
162274448
162273494
162273017
162273167
162273048
162272988
162272988
162272973
16227...

output:

? 1 500000000
? 1 500000000
? 999999999 500000000
? 250000000 500000000
? 125000000 500000000
? 187500000 500000000
? 156250000 500000000
? 171875000 500000000
? 164062500 500000000
? 160156250 500000000
? 162109375 500000000
? 163085937 500000000
? 162597656 500000000
? 162353515 500000000
? 162231...

result:

ok ok (1000 test cases)

Test #25:

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

input:

1000
999999999
487015083
487015083
487015082
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
24350...

output:

? 1 500000000
? 1 500000000
? 999999999 500000000
? 750000000 500000000
? 875000000 500000000
? 812500000 500000000
? 781250000 500000000
? 765625000 500000000
? 757812500 500000000
? 753906250 500000000
? 755859375 500000000
? 756835937 500000000
? 756347656 500000000
? 756591796 500000000
? 756469...

result:

ok ok (1000 test cases)

Test #26:

score: 0
Accepted
time: 31ms
memory: 3712kb

input:

1000
999999999
265285129
265285129
265285130
250000000
374264884
311764884
280514884
264889884
257472630
260983634
259030509
258053946
257565665
257321524
257350560
257289525
257291006
257275747
257281896
257278082
257276175
257275221
257275270
257275031
257275102
257275043
257275013
257275016
25727...

output:

? 1 500000000
? 1 500000000
? 999999999 500000000
? 250000000 500000000
? 125000000 500000000
? 62500000 500000000
? 31250000 500000000
? 15625000 500000000
? 7812500 500000000
? 11718750 500000000
? 9765625 500000000
? 8789062 500000000
? 8300781 500000000
? 8056640 500000000
? 7934570 500000000
? ...

result:

ok ok (1000 test cases)

Test #27:

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

input:

1000
536870912
261621269
261621269
261621268
127403541
67108863
93849108
77071892
75497471
79691775
78290726
77242150
76717862
76809748
76678676
76652326
76645908
76635942
76637716
76633620
76633894
76632870
76633108
76632852
76632742
76632788
76632756
76632740
76632734
76632736
76632734
76632733
1
...

output:

? 1 268435457
? 1 268435457
? 536870912 268435457
? 402653185 268435457
? 335544320 268435457
? 369098752 268435457
? 352321536 268435457
? 343932928 268435457
? 348127232 268435457
? 350224384 268435457
? 351272960 268435457
? 351797248 268435457
? 352059392 268435457
? 351928320 268435457
? 351862...

result:

ok ok (1000 test cases)

Test #28:

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

input:

1000
536870911
244408485
244408485
244408484
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
18002...

output:

? 1 268435456
? 1 268435456
? 536870911 268435456
? 402653184 268435456
? 469762048 268435456
? 503316480 268435456
? 486539264 268435456
? 478150656 268435456
? 473956352 268435456
? 471859200 268435456
? 472907776 268435456
? 472383488 268435456
? 472645632 268435456
? 472514560 268435456
? 472449...

result:

ok ok (1000 test cases)

Extra Test:

score: 0
Extra Test Passed