QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#391798 | #6303. Inversion | Core_65536 | WA | 62ms | 6452kb | C++17 | 1.5kb | 2024-04-16 19:52:42 | 2024-04-16 19:52:42 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
map<pair<int,int>,int> mp;
bool cmp(int r,int l){
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;
}
stable_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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
3 0 0 1
output:
? 1 2 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=3
Test #2:
score: -100
Wrong Answer
time: 62ms
memory: 6452kb
input:
1993 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 1 1 1 0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 0 1 0 0 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 1 0 0 1 1 1 1 1 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 1 0 0 1...
output:
? 1 2 ? 2 3 ? 3 4 ? 4 5 ? 1 5 ? 2 5 ? 1 4 ? 2 4 ? 3 5 ? 4 6 ? 5 6 ? 6 7 ? 1 7 ? 2 7 ? 1 6 ? 2 6 ? 3 7 ? 3 6 ? 4 7 ? 5 7 ? 8 9 ? 8 10 ? 9 10 ? 10 11 ? 11 12 ? 12 13 ? 13 14 ? 9 14 ? 10 14 ? 9 13 ? 10 13 ? 8 14 ? 8 13 ? 11 14 ? 11 13 ? 15 16 ? 16 17 ? 15 17 ? 16 18 ? 17 18 ? 18 19 ? 15 19 ? 16 19 ? 15...
result:
wrong output format Unexpected end of file - int32 expected