QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#858189#8939. Permutationzhouyuxuan3501WA 0ms3456kbC++14764b2025-01-16 14:50:572025-01-16 14:52:09

Judging History

This is the latest submission verdict.

  • [2025-01-16 14:52:09]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3456kb
  • [2025-01-16 14:50:57]
  • Submitted

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()
{
    ios::sync_with_stdio(0);
    int h;
    cin>>T;
    while(T--)
    {
        cin>>n;
        h=C(1,n,0);
        cout<<"! "<<h<<endl;
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3456kb

input:

3
5
3
2

output:

? 1 5
? 1 3
! 9

result:

wrong answer Wrong prediction (test case 1)