QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250992 | #6303. Inversion | DepletedPrism | WA | 120ms | 17404kb | C++17 | 2.5kb | 2023-11-13 23:26:41 | 2023-11-13 23:26:41 |
Judging History
answer
/*
* @Author: zxxzy
* @Date: 2023-06-26 23:15:27
*/
#include <iostream>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <set>
#include <cmath>
#include <vector>
#include <map>
#include <cassert>
//#define int long long
#define space ' '
// #define endl '\n'
#define de(x) cout<<"** "<<x<<" **"<<endl;
#define N 2001
using namespace std;
using ll=long long;
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double eps=1e-6;
int pos[N],bin[N],tmp;
int dp[N][N];
int vis[N][N];
int val[N][N];
int cnt=0;
int pr(int l,int r){
// if(l==r)return 0;
// if(!vis[l][r]){
// cnt++;
// assert(cnt<=40000);
// cout<<"? "<<l<<space<<r<<endl;
// cin>>tmp;
// vis[l][r]=1;
// val[l][r]=tmp;
// return tmp;
// }else{
// return val[l][r];
// }
if(l==r)return 0;
cout<<"? "<<l<<space<<r<<endl;
cin>>tmp;
return tmp;
}
bool ch(int mid,int poss){
mid=bin[mid];
if(poss==mid+1){
return pr(mid,poss);
}
return pr(mid,poss)^pr(mid+1,poss)^dp[mid+1][poss-1]^dp[mid][poss-1];
}
int bnrsch(int l,int r,int poss){
int mid;
while(l+1<r){
mid=(l+r)>>1;
(ch(mid,poss)?r:l)=mid;
}
return ch(r,poss)?l:r;
}
signed main(){
#ifdef LOCAL
freopen("D:\\code2023\\test\\input.txt", "r", stdin);
freopen("D:\\code2023\\test\\output.txt", "w", stdout);
#endif
std::ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
if(n==1){
cout<<"! 1"<<endl;
}else{
if(pr(1,2)){
pos[1]=bin[1]=2;
pos[2]=bin[2]=1;
dp[1][2]=1;
}else{
pos[1]=bin[1]=1;
pos[2]=bin[2]=2;
}
for(int i=3;i<=n;i++){
int t=bnrsch(1,i-1,i);
if(t==1&&ch(bin[1],i)){
t--;
}
// de(t)
for(int j=1;j<i;j++){
if(pos[j]>t){
pos[j]++;
}
}
pos[i]=t+1;
int ans=0;
for(int j=i-1;j>=1;j--){
if(pos[j]>pos[i])ans++;
dp[j][i]=dp[j][i-1]+ans;
}
for(int j=1;j<=i;j++){
bin[pos[j]]=j;
}
}
cout<<"! ";
for(int i=1;i<=n;i++){
cout<<pos[i]<<space;
}
cout<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
input:
3 0 1 0 1
output:
? 1 2 ? 2 3 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=4
Test #2:
score: -100
Wrong Answer
time: 120ms
memory: 17404kb
input:
1993 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 1 1 1 1...
output:
? 1 2 ? 2 3 ? 2 4 ? 3 4 ? 3 4 ? 2 5 ? 3 5 ? 2 5 ? 3 5 ? 1 5 ? 2 5 ? 2 6 ? 3 6 ? 1 6 ? 2 6 ? 1 6 ? 2 6 ? 4 6 ? 5 6 ? 1 7 ? 2 7 ? 5 7 ? 6 7 ? 1 7 ? 2 7 ? 1 8 ? 2 8 ? 5 8 ? 6 8 ? 7 8 ? 1 8 ? 2 8 ? 8 9 ? 5 9 ? 6 9 ? 7 9 ? 8 9 ? 8 9 ? 8 10 ? 9 10 ? 7 10 ? 8 10 ? 9 10 ? 9 10 ? 9 11 ? 10 11 ? 7 11 ? 8 11 ?...
result:
wrong output format Unexpected end of file - int32 expected