Submission #443133

#TimeUsernameProblemLanguageResultExecution timeMemory
443133AdamGSXor Sort (eJOI20_xorsort)C++14
40 / 100
10 ms976 KiB
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define pb push_back
#define st first
#define nd second
const int LIM=1e3+7;
int T[LIM], n;
void solve2() {
	vector<pair<int,int>>ans;
	for(int i=19; i>=0; --i) {
		if(!n) break;
		rep(j, n-1) {
			if(T[j]&(1<<i)) {
				if(!(T[j+1]&(1<<i))) {
					ans.pb({j+1, j});
					T[j+1]^=T[j];
				}
				ans.pb({j, j+1});
				T[j]^=T[j+1];
			}
		} 
		--n;
	}
	cout << ans.size() << '\n';
	for(auto i : ans) cout << i.st+1 << " " << i.nd+1 << '\n';
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int typ;
	cin >> n >> typ;
	rep(i, n) cin >> T[i];
	if(typ==2) solve2();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...