Submission #383211

# Submission time Handle Problem Language Result Execution time Memory
383211 2021-03-29T08:31:05 Z aris12345678 Xor Sort (eJOI20_xorsort) C++14
0 / 100
1 ms 364 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, ans[i].second);
    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]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -