QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#858184 | #8939. Permutation | zhouyuxuan3501 | WA | 0ms | 3840kb | C++14 | 716b | 2025-01-16 14:48:30 | 2025-01-16 14:48:30 |
Judging History
answer
#include<iostream>
#include<cmath>
using namespace std;
const double phi=0.6180339887;
int T,n;
int W(int a,int b)
{
int h;
cout<<"? "<<a<<" "<<b<<endl;
cin>>h;
return h;
}
int C(int a,int b,int p)
{
int h;
if(a==b)return a;
if(a+1==b)return a+b-p;
if(!p)p=W(a,b);
int l=max(2.0,(b-a+1)*phi);
if(p<a+l)
{
h=W(a,a+l-1);
if(h==p)return C(a,a+l-1,p);
return C(a+l,b,0);
}
else
{
h=W(a+l,b);
if(h==p)return C(b-l+1,b,p);
return C(a,b-l,0);
}
}
int main()
{
cin>>T;
while(T--)
{
scanf("%d",&n);
cout<<"! "<<C(1,n,0)<<endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
3 5
output:
! ? 1 5
result:
wrong answer format Expected integer, but "?" found (test case 1)