답안 #834273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834273 2023-08-22T12:31:31 Z GordonRemzi007 Xor Sort (eJOI20_xorsort) C++17
25 / 100
96 ms 12544 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, s;
    cin >> n >> s;
    vector<int> a(n), b(n);
    vector<pair<int,int>> op;
    map<int,int> pos;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
        pos[a[i]] = i;
    }
    sort(b.begin(), b.end());
    for(int i = 0; i < n; i++) {
        for(int j = pos[b[i]]; j > i; j--) {
            op.push_back({j-1, j});
            op.push_back({j, j-1});
            op.push_back({j-1, j});
            pos[a[j-1]] = j;
            a[j] = a[j-1];
        }
        pos[b[i]] = i;
        a[i] = b[i];
    }
    cout << op.size() << "\n";
    for(auto i : op) cout << i.first+1 << " " << i.second+1 << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 616 KB Output is correct
8 Correct 3 ms 684 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 5 ms 848 KB Output is correct
13 Correct 5 ms 944 KB Output is correct
14 Correct 5 ms 868 KB Output is correct
15 Correct 5 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 616 KB Output is correct
8 Correct 3 ms 684 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 5 ms 848 KB Output is correct
13 Correct 5 ms 944 KB Output is correct
14 Correct 5 ms 868 KB Output is correct
15 Correct 5 ms 848 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 5 ms 848 KB Output is correct
19 Correct 4 ms 848 KB Output is correct
20 Correct 4 ms 848 KB Output is correct
21 Correct 7 ms 892 KB Output is correct
22 Correct 4 ms 848 KB Output is correct
23 Correct 6 ms 848 KB Output is correct
24 Correct 5 ms 848 KB Output is correct
25 Correct 4 ms 848 KB Output is correct
26 Incorrect 8 ms 1356 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 4 ms 848 KB Output is correct
5 Incorrect 96 ms 12544 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -