Submission #463951

# Submission time Handle Problem Language Result Execution time Memory
463951 2021-08-12T05:06:22 Z amunduzbaev Xor Sort (eJOI20_xorsort) C++14
0 / 100
0 ms 204 KB
#include "bits/stdc++.h"
using namespace std;

void solve(){
	int n, s; cin>>n>>s;
	vector<int> a(n);
	for(auto& x : a) cin>>x;
	
	vector<array<int, 2>> rr;
	auto swwap = [&](int i, int j){
		assert(abs(i - j) == 1);
		rr.push_back({i, j});
		rr.push_back({j, i});
		rr.push_back({i, j});
	}; 
	
	for(int i=0;i<n;i++){
		int p = i;
		for(int j=i+1;j<n;j++){
			if(a[j] < a[p]) p = j;
		}
		
		while(p > i){
			swap(a[p], a[p - 1]);
			swwap(p, p-1);
			p--;
		}
	}
	
	for(auto x : rr) cout<<x[0] + 1<<" "<<x[1] + 1<<"\n";
}

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int t = 1;
	//~ cin>>t;
	while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not adjacent
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not adjacent
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not adjacent
2 Halted 0 ms 0 KB -