답안 #445079

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445079 2021-07-16T11:17:55 Z Valaki2 Xor Sort (eJOI20_xorsort) C++14
25 / 100
7 ms 976 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

int n, type;
vector<int> val;
vector<pii > ans;

void doSwap(int i, int j) {
    ans.pb(mp(i, j));
    ans.pb(mp(j, i));
    ans.pb(mp(i, j));
    swap(val[i], val[j]);
}

void solve1() {
    val.assign(1 + n, 0);
    for(int i = 1; i <= n; ++i) cin >> val[i];
    for(int i = n; i > 1; --i) {
        for(int j = 1; j < i; ++j) {
            if(val[j] > val[j + 1]) {
                doSwap(j, j + 1);
            }
        }
    }
    cout << ans.size() << "\n";
    for(pii p : ans) {
        cout << p.fi << " " << p.se << "\n";
    }
}

void solve() {
    cin >> n >> type;
    if(n <= 150 && type == 1) solve1();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 572 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 4 ms 592 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 4 ms 696 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 4 ms 592 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 7 ms 848 KB Output is correct
13 Correct 7 ms 848 KB Output is correct
14 Correct 7 ms 848 KB Output is correct
15 Correct 7 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 572 KB Output is correct
5 Correct 4 ms 592 KB Output is correct
6 Correct 4 ms 592 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 4 ms 696 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 4 ms 592 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 7 ms 848 KB Output is correct
13 Correct 7 ms 848 KB Output is correct
14 Correct 7 ms 848 KB Output is correct
15 Correct 7 ms 976 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 4 ms 592 KB Output is correct
18 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -