답안 #503634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503634 2022-01-08T13:34:28 Z uncripted Xor Sort (eJOI20_xorsort) C++11
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
int pas[40005][3];
int a[2000002];
pair<int,int> aa[2000002];
int a1[2000002];
int n;

int main(){
	int s;
	
	cin>>n;
	cin>>s;

	int k=0;
	
	for(int i=1; i<=n; i++){
		cin>>a[i];
		a1[i]=a[i];
		aa[i].f=a[i];
		aa[i].s=i;
	}
	sort(aa+1, aa+n+1);
//	for(int i=1; i<=n; i++){
//		cout<<aa[i].f<<" "<<aa[i].s<<" ";
//	}
//	cout<<endl;
	int lastsort=n;
	while(lastsort!=1){
		int maxi=aa[lastsort].s;
		//cout<<lastsort;
		cout<<aa[lastsort].f<<" asd "<<endl;
		cout<<maxi<<"maxi"<<endl;
		for(int i=1; i<=lastsort-1; i++ ){
			k++;
			pas[k][1]=i;
			pas[k][2]=i+1; 
		//	cout<<a1[i]<<" "<<a1[i+1]<<" "<<a[i]<<"cri1"<<endl;
			a1[i]=a1[i]^a1[i+1];
	//	cout<<a1[i]<<" "<<a1[i+1]<<" "<<a[i]<<"crine1"<<endl;
		}
		for(int i=maxi+1; i<=lastsort; i++){
			k++;
			pas[k][1]=i;
			pas[k][2]=i-1;
	///	cout<<a1[i]<<" "<<a1[i-1]<<" "<<a[i]<<"cri2"<<endl;
			a1[i]=a1[i]^a1[i-1];
	//		cout<<a1[i]<<" "<<a1[i-1]<<" "<<a[i]<<"crine2"<<endl;
		}
		for(int i=maxi-2; i>=1; i--){
			k++;
			pas[k][1]=i;
			pas[k][2]=i+1;
		//	cout<<a1[i]<<" "<<a1[i+1]<<" "<<a[i]<<"cri3"<<endl;
			a1[i]=a1[i]^a1[i+1];
		//	cout<<a1[i]<<" "<<a1[i+1]<<" "<<a[i]<<"crine3"<<endl;
			
		}
		cout<<a1[lastsort]<<" cr "<<endl;
	for(int i=1; i<=n; i++){
		if(aa[i].s>maxi){
			aa[i].s--;
		}
	}
		lastsort--;
		
	}
	for(int i=1; i<=n-1; i++){
		k++;
		pas[k][1]=i;
		pas[k][2]=i+1;
		a1[i]=a1[i]^a1[i+1];
	}


	cout<<k<<endl;
	for(int i=1; i<=k; i++){
		cout<<pas[i][1]<<" "<<pas[i][2]<<endl;
	}
	
	cout<<endl;
	for(int i=1; i<=n; i++){
		cout<<a1[i]<<" ";
	}
	

	
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer 886023 violates the range [0, 40000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer 886023 violates the range [0, 40000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer 780714 violates the range [0, 40000]
2 Halted 0 ms 0 KB -