QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#694294 | #8939. Permutation | susanzhishen# | WA | 1ms | 3648kb | C++20 | 919b | 2024-10-31 17:40:04 | 2024-10-31 17:40:05 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> PII;
const int N=3e5+10;
const int M=1e3+10;
int mod=1e9+7;
// int a[N];
int ask(int l,int r){
cout<<"? "<<l<<" "<<r<<endl;
int x;cin>>x;
return x;
}
void solve(){
int n;cin>>n;
double c=0.3;
int pos=ask(1,n);
int l=1,r=n;
while(l<r){
int mid=l+c*(r-l+1);
if(l+1==r){
cout<<"! "<<r-pos+l<<endl;
return ;
}
if(ask(l,mid)==pos){
r=mid;
}else{
pos=ask(mid+1,r);
l=mid+1;
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int _;
_=1;
cin>>_;
while(_--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3648kb
input:
3 5 3 1 3
output:
? 1 5 ? 1 2 ? 3 5 ? 3 3
result:
wrong answer Integer 3 violates the range [4, 5] (test case 1)