#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
using namespace std;
typedef pair<int,int> pii;
vector<pii> res;
void uradi(int l,int r,vector<int> &niz){
for(int i=r;i>l;i--){
res.pb(mp(i,i-1));
res.pb(mp(i-1,i));
res.pb(mp(i,i-1));
swap(niz[i],niz[i-1]);
}
}
int main()
{
srand(time(NULL));
int n,s;
cin>>n>>s;
vector<int> niz(n);
for(int i=0;i<n;i++) cin>>niz[i];
vector<int> niz2=niz;
bool bio=true;
if(true){
int koliko=rand()%500;
while(res.size()>40000 || bio){
niz=niz2;
res.clear();
bio=false;
koliko=rand()%500;
int wtf=koliko;
while(wtf--){
int koji=rand()%n;
int gde=rand()%2;
if(gde==0 && koji>0){
niz[gde]=niz[gde]^niz[gde-1];
res.pb(mp(gde+1,gde));
}
if(gde==1 && koji<n-1){
niz[gde]=niz[gde]^niz[gde+1];
res.pb(mp(gde+1,gde+2));
}
}
int gde=0;
for(int j=0;j<n;j++){
int mini=INT_MAX;
int minp=-1;
for(int i=gde;i<n;i++){
if(mini==niz[i]) continue;
mini=min(mini,niz[i]);
if(mini==niz[i]) minp=i;
}
uradi(gde,minp,niz);
gde++;
}
}
}else{
}
cout<<res.size()<<"\n";
for(pii i:res){
cout<<i.xx+1<<" "<<i.yy+1<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Not sorted |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Not sorted |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |