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>
#define ll long long
using namespace std;
ll N,S,niz[1005],prefiks[1005];
int broj[1005],tosort[1005];
struct slog{
int x,y;
}pp;
queue<slog> Q;
void dodaj(int a,int b){
pp.x=a;
pp.y=b;
Q.push(pp);
}
void swapuj(int a,int b){
if(a>b)
swap(a,b);
pp.x=a;
pp.y=b;
Q.push(pp);
pp.x=b+1;
pp.y=b;
Q.push(pp);
return;
}
void ispis(){
cout<<Q.size()<<endl;
while(Q.size()){
pp=Q.front();
Q.pop();
cout<<pp.x<<" "<<pp.y<<endl;
}
exit(0);
}
int main(){
cin>>N>>S;
for(int i=1;i<=N;i++)
cin>>niz[i];
if(S==1){
return 0;
}
for(int step=(1<<19);step>=1;step/=2){
bool nemoj=true;
for(int i=1;i<=N;i++)
if(niz[i]&step)
nemoj=false;
if(nemoj)
continue;
for(int i=1;i<N;i++)
if((niz[i]&step)>0 and (niz[i+1]&step)==0){
niz[i+1]^=niz[i];
dodaj(i+1,i);
}
for(int i=1;i<N;i++){
if(niz[i]&step){
niz[i]^=niz[i+1];
dodaj(i,i+1);
}
}
N--;
}
ispis();
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... |