# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465950 | Sench2006 | Xor Sort (eJOI20_xorsort) | C++14 | 0 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for(auto i = a; i < b; i++)
#define FORD(i, a, b) for(auto i = a - 1; i >= b; i--)
#define trav(x, v) for(auto x : v)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// ---------------------------------------- Solution ---------------------------------------- //
const int N = 1005;
int s, n;
pair<int, int> a[N];
void solve1() {
}
void solve2() {
vector <pair<int, int>> ans;
set <int> st;
for(int i = 1; i <= (1 << 20); i *= 2) {
for(int j = 0; j < n - 1; j++) {
if (i&a[j].first) {
if (!(i&a[j + 1].first)) {
ans.push_back({j + 1, j});
a[j + 1].first ^= a[j].first;
} else {
ans.push_back({j, j + 1});
a[j].first ^= a[j + 1].first;
}
}
}
}
cout << ans.size() << "\n";
FOR(i, 0, ans.size()) {
cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
}
}
void solve() {
cin >> n >> s;
FOR(i, 0, n) {
cin >> a[i].first;
a[i].second = i;
}
if (s == 1) solve1();
else solve2();
}
int main() {
fastio;
int tests = 1;
// cin >> tests;
while (tests--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |