QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#391803#6303. InversionCore_65536WA 1ms3652kbC++231.5kb2024-04-16 19:56:332024-04-16 19:56:35

Judging History

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

  • [2024-04-16 19:56:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3652kb
  • [2024-04-16 19:56:33]
  • 提交

answer

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

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

bool cmp(int l,int r){
    if(r-l==1){
        int ans;
        if(mp.count({l,r})) return (!mp[{l,r}]);
        cout<<"? "<<l<<" "<<r<<endl;    fflush(stdout);
        cin>>ans;
        mp[{l,r}]=ans;
        return (!ans);
    }
    int a=0,b=0,c=0,d=0;
    if(l!=r){
        if(mp.count({l,r})) {a = mp[{l,r}];goto L;}
        cout<<"? "<<l<<" "<<r<<endl;    fflush(stdout);
        cin>>a;
        mp[{l,r}]=a;
    }
    L:;
    if(l+1!=r){
        if(mp.count({l+1,r})) {b = mp[{l+1,r}];goto R;}
        cout<<"? "<<l+1<<" "<<r<<endl;  fflush(stdout);
        cin>>b;
        mp[{l+1,r}]=b;
    }
    R:;
    if(l!=r-1){
        if(mp.count({l,r-1})) {c = mp[{l,r-1}];goto J;}
        cout<<"? "<<l<<" "<<r-1<<endl;    fflush(stdout);
        cin>>c;
        mp[{l,r-1}]=c;
    }
    J:;
    if(l+1!=r-1){
        if(mp.count({l+1,r-1})) {d = mp[{l+1,r-1}];goto K;}
        cout<<"? "<<l+1<<" "<<r-1<<endl;  fflush(stdout);
        cin>>d;
        mp[{l+1,r-1}]=d;
    }
    K:;
    return (a-b-c+d)!=0;
}

void solve(){
    int n;  cin>>n;
    int ans[n+1];
    for(int i=1;i<=n;i++){
        ans[i]=i;
    }
    sort(ans+1,ans+n+1,cmp);
    
    cout<<"! ";
    for(int i=1;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: 0
Wrong Answer
time: 1ms
memory: 3652kb

input:

3

output:

? 2 1

result:

wrong output format Unexpected end of file - int32 expected