QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#219567#6303. Inversionucup-team198WA 0ms3760kbC++231.4kb2023-10-19 16:20:132023-10-19 16:20:14

Judging History

你现在查看的是最新测评结果

  • [2023-10-19 16:20:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3760kb
  • [2023-10-19 16:20:13]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
// #define debug(x) cout<<"[debug]"#x<<"="<<x<<endl
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ld eps=1e-8;
const int INF=0x3f3f3f3f,mod=998244353;
const ll INFF=0x3f3f3f3f3f3f3f3f;

#ifndef ONLINE_JUDGE
#define debug(...)
#include<debug>
#else
#define debug(...)
#endif

const int N=2003;
int a[N];
int n;
int res[N];
int ask(int l,int r)
{
    if(l>=r) return 0;
    cout<<"? "<<l<<" "<<r<<endl;
    int ans;
    cin>>ans;
    return ans;
}
vector<int> cdq_merge(int l,int r)
{
    if(l==r)
    {
        return {l};
    }
    int mid=l+r>>1;
    auto vl=cdq_merge(l,mid),vr=cdq_merge(mid+1,r);
    vector<int> all;
    int idl=0,idr=0;
    while(idl<vl.size()&&idr<vr.size())
    {
        int L=vl[idl];
        int R=vr[idr];
        int ans=ask(L,R)^ask(L+1,R)^ask(L,R-1)^ask(L+1,R-1);
        if(!ans)
        {
            all.push_back(vl[idl]);
            idl++;
        }
        else
        {
            all.push_back(vr[idr]);
            idr++;
        }
    }
    while(idl<vl.size()) all.push_back(vl[idl++]);
    while(idr<vr.size()) all.push_back(vr[idr++]);
    return all;
}
int main()
{
    scanf("%d",&n);
    vector<int> all=cdq_merge(1,n);
    for(int i=0;i<n;i++)
    {
        res[all[i]]=i+1;
    }
    for(int i=1;i<=n;i++) printf("%d ",res[i]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
0
1
0

output:

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

result:

wrong output format Unexpected end of file - int32 expected