제출 #1014325

#제출 시각아이디문제언어결과실행 시간메모리
1014325delreyXor Sort (eJOI20_xorsort)C++14
25 / 100
7 ms1488 KiB
#include <bits/stdc++.h>
using namespace std;

int n, s, a[1000];
vector<pair<int, int> > res;

int main() {
    cin>>n>>s;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < n; i++) {
        int m = i;
        for(int j = i + 1; j < n; j++)
            if(a[m] > a[j])
                m = j;
        for(int j = m; j > i; j--) {
            res.push_back({j, j - 1});
            res.push_back({j - 1, j});
            if(s == 1) {
                res.push_back({j, j - 1});
                swap(a[j - 1], a[j]);
            } else {
                a[j] ^= a[j - 1];
                a[j - 1] ^= a[j];
            }
        }
    }
    cout<<res.size()<<'\n';
    for(auto i : res)
        cout<<i.first + 1<<" "<<i.second + 1<<'\n';
    //for(int i = 0; i < n; i++)
    //    cout<<a[i]<<" ";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...