답안 #369817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369817 2021-02-22T13:49:17 Z AdamGS Xor Sort (eJOI20_xorsort) C++14
25 / 100
159 ms 18640 KB
#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';
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:14:14: warning: unused variable 'l' [-Wunused-variable]
   14 |     ll n, s, l=0;
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 752 KB Output is correct
5 Correct 4 ms 1008 KB Output is correct
6 Correct 4 ms 1008 KB Output is correct
7 Correct 4 ms 1008 KB Output is correct
8 Correct 4 ms 1008 KB Output is correct
9 Correct 5 ms 1008 KB Output is correct
10 Correct 4 ms 1008 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 7 ms 1516 KB Output is correct
13 Correct 7 ms 1516 KB Output is correct
14 Correct 8 ms 1516 KB Output is correct
15 Correct 7 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 752 KB Output is correct
5 Correct 4 ms 1008 KB Output is correct
6 Correct 4 ms 1008 KB Output is correct
7 Correct 4 ms 1008 KB Output is correct
8 Correct 4 ms 1008 KB Output is correct
9 Correct 5 ms 1008 KB Output is correct
10 Correct 4 ms 1008 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 7 ms 1516 KB Output is correct
13 Correct 7 ms 1516 KB Output is correct
14 Correct 8 ms 1516 KB Output is correct
15 Correct 7 ms 1516 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 4 ms 1008 KB Output is correct
18 Correct 7 ms 1260 KB Output is correct
19 Correct 8 ms 1132 KB Output is correct
20 Correct 6 ms 1152 KB Output is correct
21 Correct 6 ms 1132 KB Output is correct
22 Correct 6 ms 1132 KB Output is correct
23 Correct 6 ms 1132 KB Output is correct
24 Correct 6 ms 1132 KB Output is correct
25 Correct 6 ms 1132 KB Output is correct
26 Incorrect 13 ms 1768 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 9 ms 1164 KB Output is correct
5 Incorrect 159 ms 18640 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -