답안 #640181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640181 2022-09-13T21:13:28 Z Urvuk3 Xor Sort (eJOI20_xorsort) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
#define pb push_back
#define PRINTvec(niz) { cerr<<#niz<<"="; for(auto _i:niz) cerr<<_i<<" "; cerr<<endl; }

void Solve(){
    int N,S; cin>>N>>S;
    vector<int> a(N+1); for(int i=1;i<=N;i++) cin>>a[i];
    vector<int> b=a;

    function<void(int,int)> Swap=[&](int i,int j){
        cout<<i<<" "<<j<<endl;
        b[i]^=b[j];
        cout<<j<<" "<<i<<endl;
        b[j]^=b[i];
        cout<<i<<" "<<j<<endl;
        b[i]^=b[j];
    };

    if(S==1){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N-1;j++){
                if(a[j]>a[j+1]){
                    Swap(j,j+1); swap(a[j],a[j+1]);
                }
            }
        }
    }
    else{
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N-1;j++){
                if(a[j]<a[j+1]){
                    Swap(j,j+1); swap(a[j],a[j+1]);
                }
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        Solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Not adjacent
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Not adjacent
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Not adjacent
2 Halted 0 ms 0 KB -