#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define endl '\n'
using namespace std;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,s;
cin>>n>>s;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
vector<pair<int,int>>vct;
bool bl;
do{
bl=false;
for(int i=0;i<n;i++){
if(i<n-1&&(arr[i]^arr[i+1])<arr[i]){arr[i]^=arr[i+1];vct.push_back({i+1,i+2});bl=true;}
if(i>0&&(arr[i]^arr[i-1])>arr[i]){arr[i]^=arr[i-1];vct.push_back({i+1,i});bl=true;}
}
}while(bl);
cout<<vct.size()<<endl;
for(auto i:vct)cout<<i.first<<' '<<i.second<<endl;
}
//5 1 1 1 6 5
//5 5 6 5 6
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Not sorted |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
332 KB |
Not sorted |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
5 ms |
1088 KB |
Output is correct |
6 |
Correct |
5 ms |
1100 KB |
Output is correct |
7 |
Correct |
6 ms |
1100 KB |
Output is correct |
8 |
Correct |
6 ms |
1100 KB |
Output is correct |
9 |
Correct |
6 ms |
1100 KB |
Output is correct |
10 |
Correct |
6 ms |
1140 KB |
Output is correct |
11 |
Correct |
6 ms |
1152 KB |
Output is correct |
12 |
Correct |
6 ms |
1228 KB |
Output is correct |
13 |
Correct |
5 ms |
1228 KB |
Output is correct |
14 |
Correct |
5 ms |
1212 KB |
Output is correct |
15 |
Correct |
6 ms |
1484 KB |
Output is correct |