이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MN 10071
#define ML 20
using namespace std;
int n, s, A[MN], B[MN];
int F[(1<<21)];
vector<pair<int, int> > SOL;
void xo(int a, int b) {
A[a] ^= A[b];
SOL.push_back({a, b});
}
int main() {
cin >> n >> s;
for(int i = 1; i <= n; ++i)
cin >> A[i];
if(s == 1 || n <= ML){
for(int i = 1; i <= n; ++i) B[i] = A[i];
for(int i = 1; i < n; ++i) xo(i, i+1);
int pma = 0;
for(int i = 0; i < n-1; ++i){
pma = 0;
for(int j = 1; j <= n - i; ++j)
if(B[j] > B[pma]) pma = j;
for(int j = pma+1; j <= n - i; ++j){
xo(j, j-1);
swap(B[j], B[j-1]);
}
for(int j = max(pma-1, 1); j < n-i; ++j)
xo(j, j+1);
}
} else {
for(int j = (ML-1); j >= 0; --j){
for(int i = 1; i < n + j - (ML-1); ++i){
if((A[i] & (1<<j)) && A[i+1] & (1<<j)) xo(i, i + 1);
else if((A[i] & (1<<j))){
xo(i+1, i);
xo(i, i + 1);
}
}
}
}
cout << SOL.size() << "\n";
for(auto it : SOL) cout << it.first << " " << it.second << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |