| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 633796 | devvops | Xor Sort (eJOI20_xorsort) | C++17 | 1 ms | 212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define int long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define speed ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define file freopen("palindrome.in", "r", stdin), freopen("palindrome.out", "w", stdout);
const int N = (int) 5 * 1e5, inf = INT_MAX;
int a[2000], b[2000];
main() {
speed;
int n, S;
cin >> n >> S;
vector<pair<int, int>> v;
for(int i = 1; i <= n; i++){
cin >> a[i];
b[i] = a[i];
}
sort(b + 1, b + 1 + n);
for(int i = n; i >= 1; i--){
if(b[i] == a[i]){
continue;
}
int x;
for(int j = 1; j <= n; j++){
if(a[j] == b[i]){
x = j;
break;
}
}
while(x != i){
v.pb({x + 1, x});
v.pb({x, x + 1});
v.pb({x + 1, x});
swap(a[x], a[x + 1]);
x++;
}
}
cout << v.size() << "\n";
for(int i = 1; i <= v.size(); i++){
cout << v[i].F << " " << v[i].S << '\n';
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
