QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#392591#6303. InversionCore_65536WA 78ms7400kbC++231.4kb2024-04-17 17:41:232024-04-17 17:41:23

Judging History

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

  • [2024-04-17 17:41:23]
  • 评测
  • 测评结果:WA
  • 用时:78ms
  • 内存:7400kb
  • [2024-04-17 17:41:23]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;
map<pair<int,int>,int>  mp;

int query(int l,int r){
    if(mp.count({l,r})) return mp[{l,r}];
    if(l==r)    return 0;
    cout<<"? "<<l<<" "<<r<<endl;
    int x;  cin>>x;
    mp[{l,r}]=x;
    return x;
}

bool cmp(int l,int r){
    int flag=0;
    if(l>r) swap(l,r),flag=1;
    //cout<<"cmp "<<l<<" "<<r<<endl;
    if(r==l+1)
        if(!flag)   return !query(l,r);
        else    return query(l,r);
    int ans=query(l,r)-query(l+1,r)-query(l,r-1)+query(l+1,r-1);
    if(flag)    return ans;
    return !ans;
}

void solve(){
    int n;  cin>>n;

    //sort
    vector<int> ans;    ans.push_back(1); 
    if(cmp(1,2))  
        ans.insert(ans.begin(),2);
    else    
        ans.push_back(2);   
    for(int i=3;i<=n;++i){
        //binary_search
        int l=0,r=ans.size()-1;
        while(l<r){
            int mid=(l+r)/2;
            //cout<<i<<" "<<ans[mid]<<endl;
            if(cmp(i,ans[mid])){
                r=mid;
            }else{
                l=mid+1;
            }
        }
        ans.insert(ans.begin()+l+1,i);
    }

    cout<<"! ";
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
}

signed main(){
    ios::sync_with_stdio(0);
    int T=1;    //cin>>T;
    while(T--)  solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3528kb

input:

3
0
1

output:

? 1 2
? 2 3
! 2 3 1 

result:

ok OK, guesses=2

Test #2:

score: -100
Wrong Answer
time: 78ms
memory: 7400kb

input:

1993
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
1
0
0
1
0
1
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
1
0
0
0
0
1
0
0
0
1
1
1
1
1
0
0
0
1
1
1
1
1
0
1
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
1
0
1
1
0
0
0
0
0
1
1
0
1
1
1
1
0
0
1
1
0
0
0
0
1
0
1
1
0
1
0
0
0
0
0
1
0...

output:

? 1 2
? 2 3
? 1 4
? 2 4
? 1 3
? 1 5
? 2 5
? 3 5
? 3 4
? 1 6
? 2 6
? 5 6
? 1 7
? 2 7
? 5 7
? 6 7
? 3 7
? 3 6
? 1 8
? 2 8
? 3 8
? 4 8
? 4 7
? 6 8
? 7 8
? 1 9
? 2 9
? 3 9
? 4 9
? 6 9
? 7 9
? 6 10
? 7 10
? 5 10
? 5 9
? 8 10
? 8 9
? 1 11
? 2 11
? 1 10
? 2 10
? 3 11
? 4 11
? 3 10
? 4 10
? 9 11
? 10 11
? 9...

result:

wrong output format Unexpected end of file - int32 expected