QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#858184#8939. Permutationzhouyuxuan3501WA 0ms3840kbC++14716b2025-01-16 14:48:302025-01-16 14:48:30

Judging History

This is the latest submission verdict.

  • [2025-01-16 14:48:30]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3840kb
  • [2025-01-16 14:48:30]
  • 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()
{
    cin>>T;
    while(T--)
    {
        scanf("%d",&n);
        cout<<"! "<<C(1,n,0)<<endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

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)