Submission #445079

#TimeUsernameProblemLanguageResultExecution timeMemory
445079Valaki2Xor Sort (eJOI20_xorsort)C++14
25 / 100
7 ms976 KiB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

int n, type;
vector<int> val;
vector<pii > ans;

void doSwap(int i, int j) {
    ans.pb(mp(i, j));
    ans.pb(mp(j, i));
    ans.pb(mp(i, j));
    swap(val[i], val[j]);
}

void solve1() {
    val.assign(1 + n, 0);
    for(int i = 1; i <= n; ++i) cin >> val[i];
    for(int i = n; i > 1; --i) {
        for(int j = 1; j < i; ++j) {
            if(val[j] > val[j + 1]) {
                doSwap(j, j + 1);
            }
        }
    }
    cout << ans.size() << "\n";
    for(pii p : ans) {
        cout << p.fi << " " << p.se << "\n";
    }
}

void solve() {
    cin >> n >> type;
    if(n <= 150 && type == 1) solve1();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...