Submission #466471

# Submission time Handle Problem Language Result Execution time Memory
466471 2021-08-19T12:11:54 Z myvaluska Xor Sort (eJOI20_xorsort) C++14
25 / 100
1000 ms 11412 KB
// palindromefree.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
//long long int cifra[20]; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    int s;
    cin >> n;
    cin >> s;
    vector<int>v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    vector<pair<int, int>>vys;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n-1; j++)
        {
            if (v[j] > v[j + 1])
            {
                vys.push_back({ j,j + 1 });
                vys.push_back({ j + 1,j });
                vys.push_back({ j,j+1 });
                swap(v[j], v[j + 1]);
            }
        }
    }
    cout << vys.size() << endl;
    for (int i = 0; i < vys.size(); i++)
    {
        cout << vys[i].first + 1 << ' ';
        cout << vys[i].second + 1 << endl;
    }
    return 0;
    //std::cout << "Hello World!\n";
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < vys.size(); i++)
      |                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 26 ms 644 KB Output is correct
5 Correct 29 ms 680 KB Output is correct
6 Correct 29 ms 692 KB Output is correct
7 Correct 28 ms 612 KB Output is correct
8 Correct 28 ms 716 KB Output is correct
9 Correct 30 ms 648 KB Output is correct
10 Correct 30 ms 656 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 55 ms 888 KB Output is correct
13 Correct 62 ms 996 KB Output is correct
14 Correct 55 ms 872 KB Output is correct
15 Correct 57 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 26 ms 644 KB Output is correct
5 Correct 29 ms 680 KB Output is correct
6 Correct 29 ms 692 KB Output is correct
7 Correct 28 ms 612 KB Output is correct
8 Correct 28 ms 716 KB Output is correct
9 Correct 30 ms 648 KB Output is correct
10 Correct 30 ms 656 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 55 ms 888 KB Output is correct
13 Correct 62 ms 996 KB Output is correct
14 Correct 55 ms 872 KB Output is correct
15 Correct 57 ms 896 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 29 ms 704 KB Output is correct
18 Correct 54 ms 856 KB Output is correct
19 Correct 53 ms 848 KB Output is correct
20 Correct 48 ms 852 KB Output is correct
21 Correct 51 ms 880 KB Output is correct
22 Correct 55 ms 820 KB Output is correct
23 Correct 53 ms 860 KB Output is correct
24 Correct 49 ms 968 KB Output is correct
25 Correct 47 ms 840 KB Output is correct
26 Incorrect 116 ms 1196 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 48 ms 784 KB Output is correct
5 Execution timed out 1079 ms 11412 KB Time limit exceeded
6 Halted 0 ms 0 KB -