Submission #468851

# Submission time Handle Problem Language Result Execution time Memory
468851 2021-08-29T20:47:08 Z mychecksedad Xor Sort (eJOI20_xorsort) C++17
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main(){
	cin.tie(0); ios::sync_with_stdio(0);
	int n, s, arr[1010];
	cin >> n >> s;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	vector<pair<int, int>> ans;
	if(s == 1){

	}else{
		for(int bit = 20; bit >= 0; bit--){
			for(int i = 1; i < n; i++){
				if((1<<bit)&arr[i]){
					if((1<<bit)&(arr[i + 1])){
						ans.pb({i+1, i});
						ans.pb({i, i+1});
						arr[i + 1] ^= (1<<bit);
						arr[i] ^= (1<<bit);
					}else{
						ans.pb({i, i+1});
						arr[i] ^= (1<<bit);
					}
				}
			}
		}
	}
	cout << ans.size() << '\n';
	for(auto k: ans) cout << k.first << ' ' << k.second << '\n';


	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -