QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#291647#6303. InversionzzuqyWA 95ms6868kbC++142.6kb2023-12-27 01:33:252023-12-27 01:33:26

Judging History

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

  • [2023-12-27 01:33:26]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:6868kb
  • [2023-12-27 01:33:25]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#define ll long long
#define db double
#define INF 5000000000000000ll
#define inf 1000000000
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define pii pair<int,int>
#define mk make_pair
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define sq sqrt
#define l(w) t[w].l
#define r(w) t[w].r
#define m(w) t[w].m
#define mn(w) t[w].mn
#define c(w) t[w].c
#define s(w) t[w].s
#define tag(w) t[w].tag
#define S second
#define mod 1000000007
#define sc(A) scanf("%d",&A)
#define scs(A) scanf("%s",A);
#define put(A) printf("%d\n",A)
#define zz p<<1
#define yy p<<1|1
#define fep(p,n,cc) for(int cc=p;cc>=n;--cc)
#define scl(A) scanf("%lld",&A)
using namespace std;
const int MAXN = 2010;
int T;
int n,cnt;
int a[MAXN];
int c[MAXN];
map<int,int>H[MAXN];
int ask1(int l,int r)
{
	if(l==r)return 0;
	if(H[l].find(r)!=H[l].end())return H[l][r];
	++cnt;
	cout<<"?"<<' '<<l<<' '<<r<<endl;
	//T=0;
	cin>>T;
	H[l][r]=T;
	return T;
}
int ask(int l,int r)
{
	int w=0;
	if(l>r)
	{
		w=1;
		swap(l,r);
	}
	if(l+1==r)return ask1(l,r)^w;
	int w1=ask1(l,r)^ask1(l+1,r)^ask1(l,r-1)^ask1(l+1,r-1);
	return w1^w;
}
void CDQ(int l,int r)
{
	if(l==r)
	{
		return;
	}
	int mid=(l+r)>>1;
	random_shuffle(a+l,a+mid+1);
	CDQ(l,mid);
	random_shuffle(a+mid+1,a+1+r);
	CDQ(mid+1,r);
	int i=l,j=mid+1;
	rep(l,r,k)
	{
		if(j>r)c[k]=a[i],++i;
		else
		{
			if(i>mid||ask(a[i],a[j]))
			{
				c[k]=a[j]; 	
				++j;
			}
			else c[k]=a[i],++i;
		}
	}
	rep(l,r,k)a[k]=c[k];
}
int main()
{
	//freopen("1.in", "r", stdin);
	cin>>n;
	//cout<<endl;
	rep(1,n,i)a[i]=i;
	random_shuffle(a+1,a+1+n);
	random_shuffle(a+1,a+1+n);
	random_shuffle(a+1,a+1+n);
	random_shuffle(a+1,a+1+n);
	CDQ(1,n);
	rep(1,n,i)c[a[i]]=i;
	cout<<"!";
	rep(1,n,i)cout<<' '<<c[i];
	cout<<endl;
	//cout<<cnt<<endl;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3524kb

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: 95ms
memory: 6868kb

input:

1993
0
1
1
0
0
1
1
1
0
0
1
1
0
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
1
1
0
1
0
0
1
0
0
0
1
1
0
0
1
0
1
1
1
0
0
1
1
0
1
0
1
1
1
1
1
1
0
0
0
1
1
0
0
1
1
1
1
1
1
1
1
1
0
1
0
0
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
0
0
0
0
0
1
1
0
1
1
1
0
0
0
1
1
0
1
0
0
0
1
1
1
1
0
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
1
0
0
0
0
1
1
1
0
1
0
0...

output:

? 175 1528
? 176 1528
? 175 1527
? 176 1527
? 275 913
? 276 913
? 275 912
? 276 912
? 175 913
? 176 913
? 175 912
? 176 912
? 913 1528
? 914 1528
? 913 1527
? 914 1527
? 719 1149
? 720 1149
? 719 1148
? 720 1148
? 735 763
? 736 763
? 735 762
? 736 762
? 719 763
? 720 763
? 719 762
? 720 762
? 763 11...

result:

wrong output format Unexpected end of file - int32 expected