답안 #976616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976616 2024-05-06T21:07:17 Z raul2008487 Xor Sort (eJOI20_xorsort) C++17
25 / 100
91 ms 19784 KB
#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define pb push_back
#define vl vector<ll>
#define fi first
#define se second
#define in insert
#define all(v) v.begin(), v.end()
#define bpc(x) __builtin_popcount(x)
#define endl "\n"

using namespace std;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int sz = 4e5 + 5;
const int LG = 21;
// using namespace __gnu_pbds;
// tree <ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> rbt;
vector<array<ll, 2>> res;
void makeswap(ll x, ll y){
    res.pb({y, x});
    res.pb({x, y});
    res.pb({y, x});
}
void solve(){
    ll n, S, i, j;
    cin >> n >> S;
    S = (S - 1) ^ 1;
    vl v(n);
    for(i = 0; i < n; i++){
        cin >> v[i];
    }
    for(i = 0; i < (n - 1); i++){
        for(j = 0; j < n - i - 1; j++){
            if((v[j] + S) > v[j + 1]){
                makeswap(j + 1, j + 2);
                swap(v[j], v[j + 1]);
            }
        }
    }
    cout << res.size() << endl;
    for(array<ll, 2> x: res){
        cout << x[0] << ' ' << x[1] << endl;
    }




}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}
/*

4 100
10 30
30 70
20 40
60 20


4 100

60 20
10 30
20 40
30 70
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 736 KB Output is correct
5 Correct 3 ms 992 KB Output is correct
6 Correct 3 ms 992 KB Output is correct
7 Correct 2 ms 992 KB Output is correct
8 Correct 3 ms 992 KB Output is correct
9 Correct 3 ms 992 KB Output is correct
10 Correct 3 ms 992 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1496 KB Output is correct
13 Correct 5 ms 1496 KB Output is correct
14 Correct 6 ms 1496 KB Output is correct
15 Correct 5 ms 1500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 736 KB Output is correct
5 Correct 3 ms 992 KB Output is correct
6 Correct 3 ms 992 KB Output is correct
7 Correct 2 ms 992 KB Output is correct
8 Correct 3 ms 992 KB Output is correct
9 Correct 3 ms 992 KB Output is correct
10 Correct 3 ms 992 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1496 KB Output is correct
13 Correct 5 ms 1496 KB Output is correct
14 Correct 6 ms 1496 KB Output is correct
15 Correct 5 ms 1500 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 992 KB Output is correct
18 Correct 5 ms 1244 KB Output is correct
19 Correct 4 ms 1244 KB Output is correct
20 Correct 4 ms 1244 KB Output is correct
21 Correct 4 ms 1104 KB Output is correct
22 Correct 4 ms 1244 KB Output is correct
23 Correct 4 ms 1244 KB Output is correct
24 Correct 4 ms 1244 KB Output is correct
25 Correct 4 ms 1244 KB Output is correct
26 Incorrect 8 ms 1748 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 1244 KB Output is correct
5 Incorrect 91 ms 19784 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -