#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>0&&((arr[i]<arr[i-1]&&(arr[i]^arr[i-1])>arr[i-1])||(i<n-1&&arr[i]>arr[i+1]&&(arr[i]^arr[i-1])<arr[i+1]))){vct.push_back({i+1,i});bl=true;arr[i]^=arr[i-1];}
if(i<n-1&&((i>0&&arr[i]<arr[i-1]&&(arr[i]^arr[i+1])>arr[i-1])||(arr[i]>arr[i+1]&&(arr[i]^arr[i+1])<arr[i+1]))){vct.push_back({i+1,i+2});bl=true;arr[i]^=arr[i+1];}
}
}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
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
642 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
642 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |