Submission #878319

# Submission time Handle Problem Language Result Execution time Memory
878319 2023-11-24T08:13:31 Z konber Xor Sort (eJOI20_xorsort) C++14
25 / 100
98 ms 14116 KB
#include <iostream>
#include <vector>

using namespace std;

vector<int> a;
vector<pair<int, int>> k;
int N;

void bubble_sort(){
    for(int j=0; j < N; j++){
        for(int i=N-1; i > j; i--){
            if(a[i] < a[i-1]){
                swap(a[i], a[i-1]);
                k.push_back(make_pair(i-1, i));
                k.push_back(make_pair(i, i-1));
                k.push_back(make_pair(i-1, i));
            }
        }
    }
}

int main()
{
    int S;
    scanf("%d%d", &N, &S);
    a.resize(N);
    for(int i=0; i < N; i++)
        scanf("%d", &a[i]);
    bubble_sort();

    printf("%d\n", k.size());
    for(int i=0; i < k.size(); i++){
        printf("%d %d\n", k[i].first+1, k[i].second+1);
    }
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:32:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   32 |     printf("%d\n", k.size());
      |             ~^     ~~~~~~~~
      |              |           |
      |              int         std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |             %ld
xorsort.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0; i < k.size(); i++){
      |                  ~~^~~~~~~~~~
xorsort.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d%d", &N, &S);
      |     ~~~~~^~~~~~~~~~~~~~~~
xorsort.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 500 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 728 KB Output is correct
6 Correct 4 ms 692 KB Output is correct
7 Correct 3 ms 728 KB Output is correct
8 Correct 3 ms 796 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 6 ms 984 KB Output is correct
13 Correct 5 ms 984 KB Output is correct
14 Correct 5 ms 984 KB Output is correct
15 Correct 5 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 500 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 3 ms 728 KB Output is correct
6 Correct 4 ms 692 KB Output is correct
7 Correct 3 ms 728 KB Output is correct
8 Correct 3 ms 796 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 3 ms 728 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 6 ms 984 KB Output is correct
13 Correct 5 ms 984 KB Output is correct
14 Correct 5 ms 984 KB Output is correct
15 Correct 5 ms 984 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 3 ms 728 KB Output is correct
18 Correct 4 ms 816 KB Output is correct
19 Correct 5 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 5 ms 1236 KB Output is correct
24 Correct 4 ms 812 KB Output is correct
25 Correct 4 ms 980 KB Output is correct
26 Incorrect 8 ms 1488 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 4 ms 984 KB Output is correct
5 Incorrect 98 ms 14116 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -