QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#522557#5702. Colorsbachbeo20070 0ms0kbC++23854b2024-08-17 01:42:152024-08-17 01:42:15

Judging History

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

  • [2024-08-17 01:42:15]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-08-17 01:42:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int query(int x){
    cout << "? " << x << endl;
    int a;cin >> a;
    return a;
}
void solve(){
    int n;cin >> n;
    int pre=0,l=1,r=n-1,d=0,Min=0,Max=0;
    while(r>=l){
        int mid=(r+l)/2;
        if(d) pre+=mid;
        else pre-=mid;
        d^=1;Min=min(Min,pre);Max=max(Max,pre);
        l=mid+1;
    }
    pre=-Min+1;query(pre);
    r=n-1;l=1;d=0;
    int ans=n;
    while(r>=l){
        int mid=(r+l)/2,x=0;
        if(d){x=query(pre+mid);pre+=mid;}
        else{x=query(pre-mid);pre-=mid;}
        d^=1;
        if(x){r=mid-1;ans=mid;}
        else l=mid+1;
    }
    cout << "= " << ans << endl;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t;cin >> t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

7

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%