QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#858100#8939. PermutationLe0ChanTL 0ms0kbC++14864b2025-01-16 14:07:482025-01-16 14:07:56

Judging History

This is the latest submission verdict.

  • [2025-01-16 14:07:56]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2025-01-16 14:07:48]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int inf=0x3f3f3f3f;
const ll lnf=1e18;
int n,as;
int qry(int l,int r){
    cout<<"? "<<l<<' '<<r<<endl;
    cin>>l;return l;
}
void sol(int l,int r,int p){
    if(l==r){as=l;return;}
    int len=(r-l+1)/3,rs=r-l+1-len*3;
    int p2=qry(l,l+2*len-1);
    if(p2==p) sol(l,l+2*len-1,p);
    else sol(l+2*len,r,qry(l+2*len,r));
}
void sv(){
    cin>>n;
    sol(1,n,qry(1,n));
    cout<<as<<'\n';
}
int main(){
    int _T;cin>>_T;
    while(_T--){
        sv();
    }
    return 0;
}
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    return Le0::main();
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3
5
3
1
3
3

output:

? 1 5
? 1 2
? 3 5
? 3 4
? 3 2

result: