Submission #499275

# Submission time Handle Problem Language Result Execution time Memory
499275 2021-12-27T18:07:28 Z LucaIlie Xor Sort (eJOI20_xorsort) C++17
0 / 100
0 ms 204 KB
#include <iostream>

#define MAX_N 1000
#define MAX_K 40000

using namespace std;

struct answer {
    int x, y;
};

int v[MAX_N];
answer ans[MAX_K];

int main() {
    int n, s, k, i, j, p;

    cin >> n >> s;
    for ( i = 0; i < n; i++ )
        cin >> v[i];

    k = 0;
    for ( i = 0; i < n; i++ ) {
        p = i;
        for ( j = i + 1; j < n; j++ ) {
            if ( v[j] < v[p] )
                p = j;
        }
        if ( p != i ) {
            swap( v[i], v[p] );

            while ( p > i ) {
                ans[k] = { p, p + 1 };
                ans[k + 1] = { p + 1, p };
                ans[k + 2] = { p, p + 1 };
                k += 3;
                p--;
            }
        }
    }

    cout << k << "\n";
    for ( i = 0; i < k; i++ )
        cout << ans[i].x << " " << ans[i].y << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not sorted
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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Not sorted
3 Halted 0 ms 0 KB -