#include<bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PB push_back
#define F first
#define S second
const int INF=1e9;
const long long LINF=1e18;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef map<int, int> mii;
const int N=1e4+10;
int n, s, a[N];
int main()
{
FAST_IO;
cin >> n >> s;
FOR(i, 0, n)
{
cin >> a[i];
}
vector<pii> ans;
FOR(i, 1, n)
{
int xr=(a[i-1]^a[i]);
if(xr<a[i]){
a[i-1]=xr;
ans.PB({i, i+1});
}
else{
a[i]=xr;
ans.PB({i+1, i});
}
}
cout << ans.size() << '\n';
for(auto[x, y] : ans){
cout << x << " " << y << '\n';
}
}
Compilation message
xorsort.cpp: In function 'int main()':
xorsort.cpp:44:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
44 | for(auto[x, y] : ans){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Not sorted |
2 |
Halted |
0 ms |
0 KB |
- |