QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250878 | #6303. Inversion | DepletedPrism# | WA | 19ms | 25000kb | C++17 | 2.0kb | 2023-11-13 20:17:41 | 2023-11-13 20:17:42 |
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>
//#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 vis[N][N];
int val[N][N];
int pr(int l,int r){
if(l==r)return 0;
if(!vis[l][r]){
cout<<"? "<<l<<space<<r<<endl;
cin>>tmp;
vis[l][r]=1;
val[l][r]=tmp;
return tmp;
}else{
return val[l][r];
}
}
bool ch(int mid,int pos){
if(pos==mid+1){
return pr(mid,pos);
}
return pr(mid,pos)^pr(mid+1,pos)^pr(mid+1,pos-1)^pr(mid,pos-1);
}
void merge(int l,int r){
int mid=(l+r)>>1;
int rr=mid+1;
int num=0;
while(l<=mid&&rr<=mid+1){
if(ch(l,rr)){
pos[rr++]=++num;
}else{
pos[l++]=++num;
}
}
while(l<=mid){
pos[l++]=++num;
}
while(rr<=r){
pos[rr++]=++num;
}
}
void build(int l,int r){
if(l==r){
pos[l]=1;
return ;
}
int mid=(l+r)>>1;
build(l,mid);
build(mid+1,r);
merge(l,r);
}
int bnrsch(int l,int r,int now){
int mid;
while(l+1<r){
mid=(l+r)>>1;
(ch(mid,now)?r:l)=mid;
}
return ch(r,now)?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{
build(1,n);
cout<<"! ";
for(int i=1;i<=n;i++){
cout<<pos[i]<<space;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
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: 19ms
memory: 25000kb
input:
1993 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 0 0 1 0 1 0 1 1 0 0 0 1 1 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 1 1 1 0 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0...
output:
? 1 2 ? 3 4 ? 1 3 ? 2 3 ? 5 6 ? 7 8 ? 5 7 ? 6 7 ? 1 5 ? 2 5 ? 2 4 ? 1 4 ? 9 10 ? 11 12 ? 9 11 ? 10 11 ? 13 14 ? 15 16 ? 13 15 ? 14 15 ? 9 13 ? 10 13 ? 10 12 ? 9 12 ? 11 13 ? 12 13 ? 1 9 ? 2 9 ? 2 8 ? 1 8 ? 3 9 ? 3 8 ? 17 18 ? 19 20 ? 17 19 ? 18 19 ? 21 22 ? 23 24 ? 21 23 ? 22 23 ? 17 21 ? 18 21 ? 18...
result:
wrong answer Wa.