제출 #369817

#제출 시각아이디문제언어결과실행 시간메모리
369817AdamGSXor Sort (eJOI20_xorsort)C++14
25 / 100
159 ms18640 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(ll a = 0; a < (b); ++a)
#define lg(a) (!a?0:64-__builtin_clzll(a))
#define st first
#define nd second
#define pb push_back
const ll LIM=1e3+7;
ll T[LIM];
vector<pair<ll,ll>>ans;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n, s, l=0;
    cin >> n >> s;
    rep(i, n) cin >> T[i];
    /*for(int i=20; i; --i) {
        int p=0;
        rep(j, n-l) {
            if(lg(T[j])==i) {
                p=1;
                if(lg(T[j])!=lg(T[j+1])) {
                    ans.pb({j+1, j});
                    T[j+1]^=T[j];
                }
                ans.pb({j, j+1});
                T[j]^=T[j+1];
            }
        }
        l+=p;
    }*/
    rep(i, n) rep(j, n-i-1) {
        if(T[j]>T[j+1]) {
            swap(T[j], T[j+1]);
            ans.pb({j, j+1});
            ans.pb({j+1, j});
            ans.pb({j, j+1});
        }
    }
    cout << ans.size() << '\n';
    for(auto i : ans) cout << i.st+1 << " " << i.nd+1 << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

xorsort.cpp: In function 'int main()':
xorsort.cpp:14:14: warning: unused variable 'l' [-Wunused-variable]
   14 |     ll n, s, l=0;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...