QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106829#6394. Turn on the Lightwhatever#AC ✓5ms3852kbC++173.0kb2023-05-19 14:15:012023-05-19 14:15:04

Judging History

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

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

answer

  #include<bits/stdc++.h>
  using namespace std;
  
  #define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i)
  #define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i)
  mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
  template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
  template<typename T>void chkmin(T&x,const T&y){if(y<x)x=y;}
  
  #define pb push_back
  #define ALL(x) (x).begin(),(x).end()
  #define mem(x) memset((x),0,sizeof(x))
  
  typedef double db;
  typedef long long ll;
  typedef vector<int>vi;
  typedef pair<int,int>pii;
  
  typedef unsigned u32;
  typedef unsigned uint;
  typedef unsigned long long u64;
  
  namespace orzjk{
    const int SZ=1e6;
    char buf[SZ],*p1=buf,*p2=buf;
    char nc(){
      return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
    }
    char fub[SZ],*p3=fub,*p4=fub+SZ;
    void pc(char c){
      p3==p4&&(fwrite(fub,1,SZ,stdout),p3=fub);
      *p3++=c;
    }
    void flush(){
      fwrite(fub,1,p3-fub,stdout),p3=fub;
    }
  }
  using orzjk::nc;
  using orzjk::pc;
  
  //#define nc getchar
  //#define pc putchar
  
  int read(){
    int x=0,f=1;char c=nc();
    while(c<48)c=='-'&&(f=-1),c=nc();
    while(c>47)x=x*10+(c^48),c=nc();
    return x*f;
  }
  template<class T>void write(T x){
    static char st[41];
    if(!x)return pc(48),void();
    char*p=st;
    if(x<0)x=-x,pc('-');
    for(;x;x/=10)*p++=x%10|48;
    do{
      pc(*--p);
    }while(p!=st);
  }
  
  //const int P=1e9+7;
  const int P=998244353;
  int qp(int a,int k){
    int res=1;for(;k;k>>=1,a=1ll*a*a%P)if(k&1)res=1ll*res*a%P;return res;
  }
  
  const int maxn=1e6+10;
  int n;
  int goal;
  
  int cnt;
  int ask(int v){
    printf("? %d\n",v);
    fflush(stdout);
    
//    cnt++;
    if(1){
      int x;
      scanf("%d",&x);
      return x;
    }else{
      static bool vis[maxn];
      vis[v]=1;
      int s=0;
      rep(i,1,goal-1)s+=vis[i];
      rep(i,goal+1,n)s-=vis[i];
      return abs(s);
    }
  }
  
  void ret(int x){
    if(1){
      printf("! %d\n",x);
      fflush(stdout);
    }
  //  cerr<<cnt<<endl;
    exit(0);
  }
  
  void solve(){
    cin>>n;
//    cin>>goal;
    int l=1,r=n,dt=0;
    while(1){
      int mid=(l+r)/2;
      int a=ask(mid);
      int b=ask(r);
      if(a==0){
        ret(mid);
      }
      if(b==1){
        ret(r);
      }
      if(b==0){
        l=mid+1,r-=1;
        continue;
      }
      if(b==2){
        r=mid-1;
        dt+=2;
      }
      GG:
      mid=(l+r+1)/2;
      a=ask(mid);
      b=ask(l);
      if(a==2){
        ret(mid);
      }
      if(b==3){
        ret(l);
      }
      if(b==2){
        l+=1,r=mid-1;
        goto GG;
      }
      if(b==0){
        l=mid+1;
        continue;
      }
      assert(0);
    }
  }
  
  signed main(){
  //  freopen(".in","r",stdin);
  //  freopen(".out","w",stdout);
  //  int T;cin>>T;while(T--)solve();
    solve();
    orzjk::flush();
    return 0;
  }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
0
1
0
0
0

output:

? 5
? 10
? 7
? 9
? 8
? 8
! 8

result:

ok Correct position at 8

Test #3:

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

input:

9
1
2
3
2
2
2

output:

? 5
? 9
? 3
? 1
? 2
? 2
! 2

result:

ok Correct position at 2

Test #4:

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

input:

8
1
0
1
1

output:

? 4
? 8
? 6
? 7
! 7

result:

ok Correct position at 7

Test #5:

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

input:

7
1
2
3
3

output:

? 4
? 7
? 2
? 1
! 1

result:

ok Correct position at 1

Test #6:

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

input:

6
1
0
1
1

output:

? 3
? 6
? 4
? 5
! 5

result:

ok Correct position at 5

Test #7:

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

input:

5
1
2
3
3

output:

? 3
? 5
? 2
? 1
! 1

result:

ok Correct position at 1

Test #8:

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

input:

4
1
1

output:

? 2
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0
0

output:

? 1
? 1
! 1

result:

ok Correct position at 1

Test #12:

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

input:

1000000
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 500000
? 1000000
? 750000
? 999999
? 625000
? 500001
? 562501
? 500002
? 531252
? 500003
? 515628
? 500004
? 507816
? 500005
? 503911
? 500006
? 501959
? 500007
? 500983
? 500008
? 500496
? 500009
? 500253
? 500010
? 500132
? 500011
? 500072
? 500012
? 500042
? 500013
? 500028
? 500014
? 500021
? ...

result:

ok Correct position at 500023

Test #13:

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

input:

999999
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 500000
? 999999
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 29
? 15
? 22
? 16
? 25
? 28
? 24
? 23
! 24

result:

ok Correct position at 24

Test #14:

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

input:

999998
1
0
1
0
1
0
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499999
? 999998
? 749998
? 999997
? 874997
? 999996
? 937496
? 999995
? 968745
? 999994
? 953121
? 937497
? 945309
? 937498
? 941404
? 937499
? 939452
? 937500
? 938476
? 937501
? 937989
? 937502
? 937746
? 937503
? 937625
? 937504
? 937565
? 937505
? 937535
? 937506
? 937521
? 937507
? 937514
? 9...

result:

ok Correct position at 937516

Test #15:

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

input:

999997
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499999
? 999997
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 29
? 15
? 22
? 16
? 25
? 28
? 24
? 23
! 24

result:

ok Correct position at 24

Test #16:

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

input:

999996
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499998
? 999996
? 749997
? 999995
? 624998
? 499999
? 562499
? 500000
? 531250
? 500001
? 515626
? 500002
? 507814
? 500003
? 503909
? 500004
? 501957
? 500005
? 500981
? 500006
? 500494
? 500007
? 500251
? 500008
? 500130
? 500009
? 500070
? 500010
? 500040
? 500011
? 500026
? 500012
? 500019
? 5...

result:

ok Correct position at 500021

Test #17:

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

input:

999995
1
2
3
2
3
2
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499998
? 999995
? 249999
? 1
? 125000
? 2
? 62501
? 3
? 93750
? 124999
? 78126
? 62502
? 70314
? 62503
? 66409
? 62504
? 64457
? 62505
? 63481
? 62506
? 62994
? 62507
? 62751
? 62508
? 62630
? 62509
? 62570
? 62510
? 62540
? 62511
? 62526
? 62512
? 62519
? 62513
? 62522
? 62525
? 62521
? 62520
! 6...

result:

ok Correct position at 62521

Test #18:

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

input:

999994
1
0
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499997
? 999994
? 749995
? 999993
? 874994
? 999992
? 812495
? 749996
? 781246
? 749997
? 765622
? 749998
? 757810
? 749999
? 753905
? 750000
? 751953
? 750001
? 750977
? 750002
? 750490
? 750003
? 750247
? 750004
? 750126
? 750005
? 750066
? 750006
? 750036
? 750007
? 750022
? 750008
? 750015
? 7...

result:

ok Correct position at 750017

Test #19:

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

input:

999993
1
2
3
2
3
2
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499997
? 999993
? 249999
? 1
? 125000
? 2
? 62501
? 3
? 93750
? 124999
? 78126
? 62502
? 70314
? 62503
? 66409
? 62504
? 64457
? 62505
? 63481
? 62506
? 62994
? 62507
? 62751
? 62508
? 62630
? 62509
? 62570
? 62510
? 62540
? 62511
? 62526
? 62512
? 62519
? 62513
? 62522
? 62525
? 62521
? 62520
! 6...

result:

ok Correct position at 62521

Test #20:

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

input:

999992
1
0
1
2
3
2
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499996
? 999992
? 749994
? 999991
? 624995
? 499997
? 562496
? 499998
? 593745
? 624994
? 578121
? 562497
? 570309
? 562498
? 566404
? 562499
? 564452
? 562500
? 563476
? 562501
? 562989
? 562502
? 562746
? 562503
? 562625
? 562504
? 562565
? 562505
? 562535
? 562506
? 562521
? 562507
? 562514
? 5...

result:

ok Correct position at 562516

Test #21:

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

input:

999991
1
2
3
2
3
2
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499996
? 999991
? 249998
? 1
? 125000
? 2
? 62501
? 3
? 93750
? 124999
? 78126
? 62502
? 70314
? 62503
? 66409
? 62504
? 64457
? 62505
? 63481
? 62506
? 62994
? 62507
? 62751
? 62508
? 62630
? 62509
? 62570
? 62510
? 62540
? 62511
? 62526
? 62512
? 62519
? 62513
? 62522
? 62525
? 62521
? 62520
! 6...

result:

ok Correct position at 62521

Test #22:

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

input:

1000000
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
2
1

output:

? 500000
? 1000000
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
! 43

result:

ok Correct position at 43

Test #23:

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

input:

999999
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 500000
? 999999
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 58
? 72
? 51
? 44
! 51

result:

ok Correct position at 51

Test #24:

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

input:

999998
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499999
? 999998
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 58
? 72
? 51
? 44
! 51

result:

ok Correct position at 51

Test #25:

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

input:

999997
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
2
1

output:

? 499999
? 999997
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 58
? 72
? 51
? 44
! 51

result:

ok Correct position at 51

Test #26:

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

input:

1000000
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
3
2
1
0
1
2
3
2
3
2
2
1

output:

? 500000
? 1000000
? 750000
? 999999
? 874999
? 999998
? 937498
? 999997
? 968747
? 999996
? 984371
? 999995
? 992183
? 999994
? 996088
? 999993
? 998040
? 999992
? 999016
? 999991
? 999503
? 999990
? 999746
? 999989
? 999867
? 999988
? 999807
? 999747
? 999777
? 999748
? 999792
? 999806
? 999785
? ...

result:

ok Correct position at 999781

Test #27:

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

input:

999999
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1

output:

? 500000
? 999999
? 749999
? 999998
? 874998
? 999997
? 937497
? 999996
? 968746
? 999995
? 984370
? 999994
? 992182
? 999993
? 996087
? 999992
? 998039
? 999991
? 999015
? 999990
? 999502
? 999989
? 999745
? 999988
? 999866
? 999987
? 999926
? 999986
? 999956
? 999985
? 999970
? 999984
? 999977
? 9...

result:

ok Correct position at 999980

Test #28:

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

input:

999998
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1

output:

? 499999
? 999998
? 749998
? 999997
? 874997
? 999996
? 937496
? 999995
? 968745
? 999994
? 984369
? 999993
? 992181
? 999992
? 996086
? 999991
? 998038
? 999990
? 999014
? 999989
? 999501
? 999988
? 999744
? 999987
? 999865
? 999986
? 999925
? 999985
? 999955
? 999984
? 999969
? 999983
? 999976
? 9...

result:

ok Correct position at 999979

Test #29:

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

input:

999997
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1

output:

? 499999
? 999997
? 749998
? 999996
? 874997
? 999995
? 937496
? 999994
? 968745
? 999993
? 984369
? 999992
? 992180
? 999991
? 996085
? 999990
? 998037
? 999989
? 999013
? 999988
? 999500
? 999987
? 999743
? 999986
? 999864
? 999985
? 999924
? 999984
? 999954
? 999983
? 999968
? 999982
? 999975
? 9...

result:

ok Correct position at 999978

Test #30:

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

input:

1000000
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
0
1
2
2
1

output:

? 500000
? 1000000
? 250000
? 1
? 375000
? 499999
? 437499
? 499998
? 468748
? 499997
? 484372
? 499996
? 492184
? 499995
? 496089
? 499994
? 498041
? 499993
? 499017
? 499992
? 499504
? 499991
? 499747
? 499990
? 499868
? 499989
? 499928
? 499988
? 499958
? 499987
? 499943
? 499929
? 499950
? 49995...

result:

ok Correct position at 499947

Test #31:

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

input:

999999
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
0
1
1

output:

? 500000
? 999999
? 749999
? 999998
? 625000
? 500001
? 562501
? 500002
? 531252
? 500003
? 515628
? 500004
? 507816
? 500005
? 503911
? 500006
? 501959
? 500007
? 500983
? 500008
? 500496
? 500009
? 500253
? 500010
? 500132
? 500011
? 500072
? 500012
? 500042
? 500013
? 500057
? 500071
? 500064
? 5...

result:

ok Correct position at 500070

Test #32:

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

input:

999998
1
0
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
3
2
3
2
2
1

output:

? 499999
? 999998
? 749998
? 999997
? 624999
? 500000
? 562500
? 500001
? 531251
? 500002
? 515627
? 500003
? 507815
? 500004
? 503910
? 500005
? 501958
? 500006
? 500982
? 500007
? 500495
? 500008
? 500252
? 500009
? 500131
? 500010
? 500071
? 500011
? 500101
? 500130
? 500086
? 500072
? 500079
? 5...

result:

ok Correct position at 500076

Test #33:

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

input:

999997
1
2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
0
1
2
3
3

output:

? 499999
? 999997
? 250000
? 1
? 374999
? 499998
? 437498
? 499997
? 468747
? 499996
? 484371
? 499995
? 492183
? 499994
? 496088
? 499993
? 498040
? 499992
? 499016
? 499991
? 499503
? 499990
? 499746
? 499989
? 499867
? 499988
? 499927
? 499987
? 499957
? 499986
? 499971
? 499985
? 499964
? 499958...

result:

ok Correct position at 499965

Test #34:

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

input:

1000000
1
0
1
2
1
0
1
2
1
0
1
2
3
2
1
0
1
2
3
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
0
0
1

output:

? 500000
? 1000000
? 750000
? 999999
? 625000
? 500001
? 687500
? 749999
? 656250
? 625001
? 671875
? 687499
? 664063
? 656251
? 660157
? 656252
? 662110
? 664062
? 661134
? 660158
? 660646
? 660159
? 660890
? 661133
? 660768
? 660647
? 660829
? 660889
? 660799
? 660769
? 660784
? 660770
? 660791
? ...

result:

ok Correct position at 660795

Test #35:

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

input:

999999
1
2
1
0
1
2
1
0
1
2
1
0
1
0
1
2
1
0
1
0
1
2
1
0
1
2
1
0
1
0
1
2
3
2
3
2
2
1

output:

? 500000
? 999999
? 250000
? 1
? 375000
? 499999
? 312500
? 250001
? 343750
? 374999
? 328125
? 312501
? 335937
? 343749
? 339843
? 343748
? 337890
? 335938
? 338866
? 339842
? 339354
? 339841
? 339110
? 338867
? 339232
? 339353
? 339171
? 339111
? 339201
? 339231
? 339216
? 339230
? 339209
? 339202...

result:

ok Correct position at 339205

Test #36:

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

input:

999998
1
0
1
0
1
0
1
0
1
0
1
0
1
2
1
0
1
2
3
2
1
0
1
2
1
0
1
2
3
2
1
0
1
0
1
0
0
1

output:

? 499999
? 999998
? 749998
? 999997
? 874997
? 999996
? 937496
? 999995
? 968745
? 999994
? 984369
? 999993
? 992181
? 999992
? 988275
? 984370
? 990228
? 992180
? 989252
? 988276
? 988764
? 988277
? 989008
? 989251
? 988886
? 988765
? 988947
? 989007
? 988917
? 988887
? 988902
? 988888
? 988909
? 9...

result:

ok Correct position at 988913

Test #37:

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

input:

999997
1
2
3
2
3
2
3
2
3
2
3
2
1
0
1
2
1
0
1
0
1
2
1
0
1
2
1
0
1
0
1
2
3
2
3
2
2
1

output:

? 499999
? 999997
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 11723
? 15628
? 9770
? 7818
? 10746
? 11722
? 11234
? 11721
? 10990
? 10747
? 11112
? 11233
? 11051
? 10991
? 11081
? 11111
? 11096
? 11110
? 11089
? 11082
? 11086
? 11083
? 11085
? 11084
! 11085

result:

ok Correct position at 11085

Test #38:

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

input:

1000000
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
3

output:

? 500000
? 1000000
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 29
? 15
? 22
? 16
? 19
? 17
! 17

result:

ok Correct position at 17

Test #39:

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

input:

999999
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
3

output:

? 500000
? 999999
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 29
? 15
? 22
? 16
? 19
? 17
! 17

result:

ok Correct position at 17

Test #40:

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

input:

999998
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
3

output:

? 499999
? 999998
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 29
? 15
? 22
? 16
? 19
? 17
! 17

result:

ok Correct position at 17

Test #41:

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

input:

999997
1
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
2
3
3

output:

? 499999
? 999997
? 250000
? 1
? 125001
? 2
? 62502
? 3
? 31253
? 4
? 15629
? 5
? 7817
? 6
? 3912
? 7
? 1960
? 8
? 984
? 9
? 497
? 10
? 254
? 11
? 133
? 12
? 73
? 13
? 43
? 14
? 29
? 15
? 22
? 16
? 19
? 17
! 17

result:

ok Correct position at 17

Test #42:

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

input:

1000000
1
1

output:

? 500000
? 1000000
! 1000000

result:

ok Correct position at 1000000

Test #43:

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

input:

1000000
1
2
3
3

output:

? 500000
? 1000000
? 250000
? 1
! 1

result:

ok Correct position at 1