QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#631057#8939. PermutationyanchengzhiWA 1ms3648kbC++201.4kb2024-10-11 21:43:092024-10-11 21:43:14

Judging History

This is the latest submission verdict.

  • [2024-10-11 21:43:14]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3648kb
  • [2024-10-11 21:43:09]
  • Submitted

answer

#include <iostream>
using namespace std;
const int N = 1e5 + 3;
// const double D = 1 / 2.5874;
const double D = 0.4;
int T;
int n, num, ret;

int query(int l, int r){
    if(l == r) {
        return -1;
    }
    cout << "? " << l << " " << r << endl;
    cin >> ret;
    return ret;
}
void ans(int x){    cout << "! " << x << endl;}
int solve(int l, int r) {
    // <= 2
    if(l == r) {
        return l;
    }
    int x = query(l, r);
    if(l + 1 == r) {
        return (l == x) ? r : l;
    }
    while(1) {
        if(l == r) {
            return l;
        }
        if(l + 1 == r) {
            return (l == x) ? r : l;
        }
        int len = D * (r - l + 1);
        if(r - len + 1 > x) {
            int y = query(l, r - len);
            if(y == x) {
                r = r - len;
            }
            else {
                return solve(r - len + 1, r);
            }
        }
        else {
            int y = query(l + len, r);
            if(y == x) {
                l = l + len;
            }
            else {
                return solve(l, l + len - 1);
            }
        }
    }
    
}
void work(){
    cin >> n; 
    int pos = solve(1, n);
    ans(pos);
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    for(int i = 1; i <= 10; i++) {
        cout << (int)(i * D) << ' ';
    }
    cin >> T;
    while(T--){
        work();
    }    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3648kb

input:

3
5

output:

0 0 1 1 2 2 2 3 3 4 ? 1 5

result:

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