QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201637#5156. Going in CirclesVengeful_Spirit#TL 0ms0kbC++141.7kb2023-10-05 15:44:532023-10-05 15:44:53

Judging History

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

  • [2023-10-05 15:44:53]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-10-05 15:44:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int x;
int move_left(){
    cout<<"? left"<<endl;
    cin>>x;
    return x;
}
int move_right(){
    cout<<"? right"<<endl;
    cin>>x;
    return x;
}
int set_bit(int p){
    if(x!=p){
        cout<<"? flip"<<endl;
        cin>>x;
        return 1;
    }
    return 0;
}
/*
int p=0,C=50;
int a[100];
int move_left(){
  //  cout<<"left"<<endl;
    p=(p-1+C)%C;
    x=a[p];
    return a[p];
}
int move_right(){
    
 //   cout<<"right"<<endl;
    p=(p+1+C)%C;
    x=a[p];
    return a[p];
}
int set_bit(int po){
    if(x!=po){
        
  //  cout<<"flip"<<endl;
        a[p]^=1;
        x=a[p];
        return 1;
    }
    return 0;
}
*/
int check(int mid){
    for(int i=1;i<=mid;i++){
        set_bit(0);
        move_right();
    }
    int ans=(x==0);
    for(int i=1;i<=mid;i++){
        move_left();
        set_bit(1);
    }
    return ans;
}

int main(){
    cin>>x;
    for(int i=1;i<=30;i++){
        set_bit(1);
        move_left();
    }
    int l=3,r=30,mid=-1,res=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(mid))res=mid,r=mid-1;
        else l=mid+1;
    }
    if(res!=-1){
        cout<<"! "<<res<<endl;
        return 0;
    }
    int mod=0;
    for(int i=0;i<30;i++){
        int cur=rand()%2;
        mod<<=1;
        if(cur)mod|=1;
        set_bit(cur);
     //   cout<<x<<" ";
        move_right();
    }
    cout<<endl;
    int my=0,cnt=0;
    cout<<mod<<endl;
    while(1){
        my<<=1;
        my|=x;
        my&=((1<<30)-1);
        cnt++;
        move_right();
        if(my==mod){
            cout<<"! "<<cnt<<endl;
            return 0;
        }
    }
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

0
1
1
0
1
1
0
1
1
0
1
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
1
0
1
1
0
1
1
0
1
1
0
1
1
0
1
1
1
1
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
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
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
1
...

output:

? flip
? left
? left
? flip
? left
? left
? flip
? left
? left
? flip
? left
? left
? left
? flip
? left
? flip
? left
? flip
? left
? flip
? left
? flip
? left
? flip
? left
? flip
? left
? left
? flip
? left
? flip
? left
? left
? flip
? left
? left
? flip
? left
? left
? flip
? left
? left
? flip...

result: