QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#253598#6303. InversionSATSKYWA 30ms3440kbC++201.5kb2023-11-17 09:44:002023-11-17 09:44:01

Judging History

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

  • [2023-11-17 09:44:01]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:3440kb
  • [2023-11-17 09:44:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;const ll inf=3e18;const int M=1e9+7;
int o,o2,tc;
vector<int>res;
struct S
{
	vector<int>arr,r2,rev;int n;
	void ins(int siz,int pos)
	{
		//cout<<siz<<':'<<pos<<'\n';
		int pt=0;r2[pos]=siz;
		for(int i=1;i<=siz;i++)if(i!=pos)r2[i]=arr[++pt];
		swap(arr,r2);
	}
	int query(int l,int r)
	{
		if(l>r)return 0;
		cout<<"? "<<l<<" "<<r<<endl;
		int x=0;
		cin>>x;
		//for(int i=l;i<r;i++)for(int j=i+1;j<=r;j++)x^=(res[i]>res[j]);
		//cout<<l<<"#"<<r<<"#"<<x<<'\n';
		return x;
	}
	bool chk(int a,int b)//a<b 0:r[a]<r[b] 1:r[a]>r[b]
	{
		if(a>b)swap(a,b);int x=query(a,b)-query(a+1,b)-query(a,b-1)+query(a+1,b-1);
		//cout<<a<<"!!"<<b<<"!!"<<x<<'\n';
		return x;
	}
	void solve()
	{
		cin>>n;arr.resize(n+1),r2.resize(n+1);arr[1]=1;int kk;
		for(int i=1;i<=40000;i++)cout<<"? 1 1"<<endl,cin>>kk;
		//
		//res.resize(n+1);for(int i=1;i<=n;i++)cin>>res[i];
		//
		for(int i=2;i<=n;i++)
		{
			if(chk(arr[1],i)){ins(i,1);continue;}
			if(!chk(arr[i-1],i)){ins(i,i);continue;}
			int l=1,r=i;while(l<r-1)
			{
				int mid=(l+r)/2;chk(arr[mid],i)?r=mid:l=mid;
			}
			ins(i,r);
		}
		rev.resize(n+1);for(int i=1;i<=n;i++)rev[arr[i]]=i;
		cout<<"!";for(int i=1;i<=n;i++)cout<<' '<<rev[i];cout<<endl;
	}
};
int main()
{
	//freopen("3.in","r",stdin);
	//cout<<fixed<<setprecision(12);
	//ios::sync_with_stdio(0);cin.tie(0);
	int t=1;//cin>>t;o=(t>50);
	//clock_t a=clock();
	while(t--){S SS;SS.solve();}
	//cout<<"Time:"<<double(clock()-a)<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 30ms
memory: 3440kb

input:

3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
? 1 1
...

result:

wrong output format Unexpected end of file - int32 expected