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 <map>
using namespace std;
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
int main()
{
int n, s;
cin >> n >> s;
vector<int> a(n);
int siz = n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
a[i] = x;
}
vector<pair<int, int>> ans;
cout << ans.size();
int k = 0;
int t = 1;
while (t < 1000) {
t *= 2;
}
t = t / 2;
while(t > 0){
for (int j = 0; j < siz - 1; j++) {
if (a.empty()) {
break;
}
if (a[j] >= t) {
if (a[j + 1] >= t) {
a[j] = a[j] ^ a[j + 1];
k++;
ans.push_back({ j, j + 1 });
}
else {
a[j+1] = a[j] ^ a[j + 1];
k++;
ans.push_back({ j+1, j});
a[j] = a[j] ^ a[j + 1];
k++;
ans.push_back({ j, j + 1 });
}
}
}
if (a.size()) {
if (a[a.size() - 1] >= t) {
a.pop_back();
siz--;
}
}
t = t/2;
}
cout << k << "\n";
for (int i = 0; i < k; i++) {
cout << ans[i].first+1 << ' ' << ans[i].second+1 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |