QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882736#9734. Identify ChordAllenJYLTL 0ms0kbC++143.1kb2025-02-05 11:02:122025-02-05 11:02:19

Judging History

This is the latest submission verdict.

  • [2025-02-05 11:02:19]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2025-02-05 11:02:12]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

//#define int long long
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
#define all(_array) (_array).begin(),(_array).end()
#define msp(_array) memset(_array,0x3f,sizeof _array)
#define ms0(_array) memset(_array,0,sizeof _array)
#define msn(_array) memset(_array,-1,sizeof _array)
#define mc(_tar,_array) memcpy(_tar,_array,sizeof _tar)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define TAK cout<<"TAK"<<endl
#define NIE cout<<"NIE"<<endl
#define OK cerr<<"OK"<<endl
#define pii pair<int,int>
// #define endl '\n'

bool bg_memory;
mt19937 rnd(time(0));
int Case=1;
const int mod=1e9+7;
const int inf=2147483647;
const int bs=233;
const double eps=1e-6;
const int N=1e5+7,M=1e5+7;

template<class _t1,class _t2>inline void cmax(_t1 &a,_t2 b){a=a<b?b:a;}
template<class _t1,class _t2>inline void cmin(_t1 &a,_t2 b){a=a>b?b:a;}
inline int qp(int a,int b,int p=mod){int res=1;while(b){if(b&1)res=1ll*res*a%p;a=1ll*a*a%p;b>>=1;}return res;}
inline int sqrt(int x,int r){int l=0,ans=0;while(l<=r){if(1ll*mid*mid<=x) ans=mid,l=mid+1;else r=mid-1;}return ans;}

int n;
int x,y;
int ask(int x,int y){
    cout<<"? "<<x+1<<" "<<y+1<<endl;
    int res;
    cin>>res;
    return res;
}
int add(int x,int f=1){return (x+f)%n;}
int dec(int x,int f=1){return (x+n-f)%n;}
void print(int x,int y){
    cout<<"! "<<x+1<<" "<<y+1<<endl;
    int res;
    cin>>res;
}
int solve(int w,int d){
    if(ask(w,add(y,d))==1) print(w,add(y,d));
    else print(w,dec(y,d));
}

void Main(){
    
    cin>>n;
    x=0,y=n/2;
    int res,now=0;
    while((res=ask(x,y))==n/2){
        if(n&1){
            if(now) x++;
            else y++;
        }else x++,y++;
        now^=1;
    }
    int rl=ask(dec(x),y);
    int rr=ask(add(x),y);
    if(rl>=res&&rr>=res) solve(x,res-1);
    else if(rl<res){
        int l=1,r=n/2,val=1;
        while(l<=r){
            if(ask(dec(x,mid),y)==res-mid) val=mid,l=mid+1;
            else r=mid-1;
        }
        solve(dec(x,val),res-val-1);
    }else{
        int l=1,r=n/2,val=1;
        while(l<=r){
            if(ask(add(x,mid),y)==res-mid) val=mid,l=mid+1;
            else r=mid-1;
        }
        solve(add(x,val),res-val-1);
    }
    
    return;
}
string RdFile="";
bool en_memory;

signed main(){
    auto bg_clock=chrono::high_resolution_clock::now();
#ifdef ONLINE_JUDGE
    // freopen((RdFile+".in").c_str(),"r",stdin);
    // freopen((RdFile+".out").c_str(),"w",stdout);
#endif
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    cin>>Case;
    while(Case--) Main();
    auto en_clock=chrono::high_resolution_clock::now();
    auto duration_clock=chrono::duration_cast<chrono::microseconds>(en_clock-bg_clock);
    double duration_count=duration_clock.count()*0.001;
    double memory_used=(&en_memory-&bg_memory)/1024.0/1024;
    // cerr<<"Time:"<<duration_count<<"ms"<<endl;
    // cerr<<"Memory: "<<memory_used<<"MB"<<endl;
    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

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

output:

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

result: