제출 #702552

#제출 시각아이디문제언어결과실행 시간메모리
702552NemanjaSo2005Xor Sort (eJOI20_xorsort)C++14
40 / 100
56 ms992 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...