#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;
int k = 0;
int t = 1;
while (t < 1e6) {
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 |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Not sorted |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Not sorted |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
6 ms |
840 KB |
Output is correct |
6 |
Correct |
6 ms |
840 KB |
Output is correct |
7 |
Correct |
6 ms |
840 KB |
Output is correct |
8 |
Correct |
6 ms |
804 KB |
Output is correct |
9 |
Correct |
6 ms |
808 KB |
Output is correct |
10 |
Correct |
6 ms |
840 KB |
Output is correct |
11 |
Correct |
6 ms |
840 KB |
Output is correct |
12 |
Correct |
6 ms |
840 KB |
Output is correct |
13 |
Correct |
7 ms |
840 KB |
Output is correct |
14 |
Correct |
6 ms |
840 KB |
Output is correct |
15 |
Correct |
10 ms |
964 KB |
Output is correct |