QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#554076#8939. PermutationCharizard2021WA 0ms3860kbC++141.5kb2024-09-09 04:57:342024-09-09 04:57:35

Judging History

This is the latest submission verdict.

  • [2024-09-09 04:57:35]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3860kb
  • [2024-09-09 04:57:34]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
long double phi = (sqrt(5.0) - 1.0)/2.0;
int solve(int low, int high, int cur){
    if(low == high){
        return low;
    }
    if(cur == INT_MIN){
        cout << "? " << low << " " << high << "\n";
        cout.flush();
        cin >> cur;
    }
    if(low + 1 == high){
        if(cur == low){
            return high;
        }
        else{
            return low;
        }
    }
    int val = (int)((long double)(high - low + 1) * (long double)phi + (long double)0.9);
    int mid;
    if(cur <= val + low){
        mid = val + low;
    }
    else{
        mid = high - val;
    }
    if(cur <= mid){
        cout << "? " << low << " " << mid << "\n";
        cout.flush();
        int x;
        cin >> x;
        if(x == cur){
            return solve(low, mid, x);
        }
        else{
            return solve(mid + 1, high, INT_MIN);
        }
    }
    else{
        cout << "? " << mid + 1 << " " << high << "\n";
        cout.flush();
        int x;
        cin >> x;
        if(x == cur){
            return solve(mid + 1, high, x);
        }
        else{
            return solve(low, mid, INT_MIN);
        }
    }
}
int main(){
    cout << fixed << setprecision(9) << phi << "\n";
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int res = solve(1, n, INT_MIN);
        cout << "! " << res << "\n";
        cout.flush();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
5

output:

0.618033989
? 1 5

result:

wrong answer Token parameter [name=type] equals to "0.618033989", doesn't correspond to pattern "?|!" (test case 1)