답안 #383213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383213 2021-03-29T08:31:31 Z aris12345678 Xor Sort (eJOI20_xorsort) C++14
25 / 100
164 ms 12616 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 1e6+5;
int a[mxN];

int main() {
    int n, s;
    scanf("%d%d", &n, &s);
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    vector<pair<int, int> > ans;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n-i-1; j++) {
            if(a[j] > a[j+1]) {
                swap(a[j], a[j+1]);
                ans.push_back({j, j+1}), ans.push_back({j+1, j}), ans.push_back({j, j+1});
            }
        }
    }
    printf("%lu\n", ans.size());
    for(int i = 0; i < ans.size(); i++)
        printf("%d %d\n", ans[i].first+1, ans[i].second+1);
    return 0;
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < ans.size(); i++)
      |                    ~~^~~~~~~~~~~~
xorsort.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d%d", &n, &s);
      |     ~~~~~^~~~~~~~~~~~~~~~
xorsort.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 4 ms 620 KB Output is correct
5 Correct 4 ms 748 KB Output is correct
6 Correct 4 ms 748 KB Output is correct
7 Correct 4 ms 748 KB Output is correct
8 Correct 5 ms 748 KB Output is correct
9 Correct 5 ms 748 KB Output is correct
10 Correct 5 ms 748 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 8 ms 1000 KB Output is correct
13 Correct 8 ms 1000 KB Output is correct
14 Correct 8 ms 1000 KB Output is correct
15 Correct 8 ms 1000 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 4 ms 620 KB Output is correct
5 Correct 4 ms 748 KB Output is correct
6 Correct 4 ms 748 KB Output is correct
7 Correct 4 ms 748 KB Output is correct
8 Correct 5 ms 748 KB Output is correct
9 Correct 5 ms 748 KB Output is correct
10 Correct 5 ms 748 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 8 ms 1000 KB Output is correct
13 Correct 8 ms 1000 KB Output is correct
14 Correct 8 ms 1000 KB Output is correct
15 Correct 8 ms 1000 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 5 ms 748 KB Output is correct
18 Correct 7 ms 872 KB Output is correct
19 Correct 7 ms 872 KB Output is correct
20 Correct 7 ms 872 KB Output is correct
21 Correct 7 ms 1004 KB Output is correct
22 Correct 7 ms 872 KB Output is correct
23 Correct 7 ms 872 KB Output is correct
24 Correct 7 ms 872 KB Output is correct
25 Correct 7 ms 872 KB Output is correct
26 Incorrect 12 ms 1252 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 7 ms 872 KB Output is correct
5 Incorrect 164 ms 12616 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -