QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#694294#8939. Permutationsusanzhishen#WA 1ms3648kbC++20919b2024-10-31 17:40:042024-10-31 17:40:05

Judging History

This is the latest submission verdict.

  • [2024-10-31 17:40:05]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3648kb
  • [2024-10-31 17:40:04]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> PII;
const int N=3e5+10;
const int M=1e3+10;
int mod=1e9+7;
// int a[N];
int ask(int l,int r){
    cout<<"? "<<l<<" "<<r<<endl;
    int x;cin>>x;
    return x;
}
void solve(){
    int n;cin>>n;
    double c=0.3;
    int pos=ask(1,n);
    int l=1,r=n;
    while(l<r){
        int mid=l+c*(r-l+1);
        if(l+1==r){
            cout<<"! "<<r-pos+l<<endl;
            return ;
        }
        if(ask(l,mid)==pos){
            r=mid;
        }else{
            pos=ask(mid+1,r);
            l=mid+1;
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int _;
    _=1;
    cin>>_;
    while(_--){
        solve();
    }
}

详细

Test #1:

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

input:

3
5
3
1
3

output:

? 1 5
? 1 2
? 3 5
? 3 3

result:

wrong answer Integer 3 violates the range [4, 5] (test case 1)