답안 #1014325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014325 2024-07-04T16:33:35 Z delrey Xor Sort (eJOI20_xorsort) C++14
25 / 100
7 ms 1488 KB
#include <bits/stdc++.h>
using namespace std;

int n, s, a[1000];
vector<pair<int, int> > res;

int main() {
    cin>>n>>s;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < n; i++) {
        int m = i;
        for(int j = i + 1; j < n; j++)
            if(a[m] > a[j])
                m = j;
        for(int j = m; j > i; j--) {
            res.push_back({j, j - 1});
            res.push_back({j - 1, j});
            if(s == 1) {
                res.push_back({j, j - 1});
                swap(a[j - 1], a[j]);
            } else {
                a[j] ^= a[j - 1];
                a[j - 1] ^= a[j];
            }
        }
    }
    cout<<res.size()<<'\n';
    for(auto i : res)
        cout<<i.first + 1<<" "<<i.second + 1<<'\n';
    //for(int i = 0; i < n; i++)
    //    cout<<a[i]<<" ";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 820 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 3 ms 728 KB Output is correct
8 Correct 2 ms 728 KB Output is correct
9 Correct 3 ms 728 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 984 KB Output is correct
13 Correct 6 ms 984 KB Output is correct
14 Correct 4 ms 1008 KB Output is correct
15 Correct 4 ms 984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 820 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 3 ms 728 KB Output is correct
8 Correct 2 ms 728 KB Output is correct
9 Correct 3 ms 728 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 984 KB Output is correct
13 Correct 6 ms 984 KB Output is correct
14 Correct 4 ms 1008 KB Output is correct
15 Correct 4 ms 984 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 2 ms 728 KB Output is correct
18 Correct 4 ms 984 KB Output is correct
19 Correct 4 ms 984 KB Output is correct
20 Correct 4 ms 984 KB Output is correct
21 Correct 4 ms 984 KB Output is correct
22 Correct 4 ms 984 KB Output is correct
23 Correct 4 ms 984 KB Output is correct
24 Correct 4 ms 984 KB Output is correct
25 Correct 3 ms 984 KB Output is correct
26 Incorrect 7 ms 1488 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 Incorrect 0 ms 444 KB Not sorted
3 Halted 0 ms 0 KB -