QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250887 | #6303. Inversion | DepletedPrism# | WA | 32ms | 30508kb | C++17 | 2.3kb | 2023-11-13 20:33:37 | 2023-11-13 20:33:37 |
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],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 tmpl,tmpr;
tmpl=l,tmpr=mid+1;
vector<int> binl(mid-l+2),binr(r-mid-1+2),bin;
for(int i=l;i<=mid;i++){
binl[pos[i]]=i;
}
for(int i=mid+1;i<=r;i++){
binr[pos[i]]=i;
}
while(tmpl<=mid&&tmpr<=r){
if(ch(binl[tmpl-l+1],binr[tmpr-mid-1+1])){
bin.push_back(binr[tmpr-mid-1+1]);
tmpr++;
}else{
bin.push_back(binl[tmpl-l+1]);
tmpl++;
}
// de(3)
}
while(tmpl<=mid){
bin.push_back(binl[tmpl-l+1]);
tmpl++;
// de(4)
}
while(tmpr<=r){
bin.push_back(binr[tmpr-mid]);
tmpr++;
// de(5)
}
for(int i=0;i<bin.size();i++){
pos[bin[i]]=i+1;
}
}
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);
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3392kb
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: 32ms
memory: 30508kb
input:
1993 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 1 0 1 1 1 1 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0...
output:
? 1 2 ? 3 4 ? 1 3 ? 2 3 ? 5 6 ? 7 8 ? 5 7 ? 6 7 ? 5 8 ? 6 8 ? 1 7 ? 2 7 ? 2 6 ? 1 6 ? 1 5 ? 2 5 ? 2 4 ? 1 4 ? 1 8 ? 2 8 ? 3 8 ? 3 7 ? 4 8 ? 4 7 ? 9 10 ? 11 12 ? 10 11 ? 9 11 ? 9 12 ? 10 12 ? 13 14 ? 15 16 ? 14 15 ? 13 15 ? 13 16 ? 14 16 ? 10 14 ? 11 14 ? 11 13 ? 10 13 ? 12 14 ? 12 13 ? 11 15 ? 12 15...
result:
wrong output format Unexpected end of file - int32 expected