Submission #465732

# Submission time Handle Problem Language Result Execution time Memory
465732 2021-08-16T17:19:50 Z idas Xor Sort (eJOI20_xorsort) C++11
25 / 100
11 ms 1228 KB
#include<bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PB push_back
#define F first
#define S second

const int INF=1e9;
const long long LINF=1e18;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef map<int, int> mii;

const int N=210;
int n, a[N], s;
vector<pii> ans;

int main()
{
    FAST_IO;
    cin >> n >> s;
    FOR(i, 0, n) cin >> a[i];

    bool going=true;
    while(going){
        going=false;
        FOR(i, 1, n)
        {
            if(a[i-1]>a[i]){
                swap(a[i-1], a[i]);
                ans.PB({i, i+1});
                ans.PB({i+1, i});
                ans.PB({i, i+1});
                going=true;
            }
        }
    }

    cout << ans.size() << '\n';
    for(auto[x, y] : ans){
        cout << x << " " << y << '\n';
    }
}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:43:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |     for(auto[x, y] : ans){
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 4 ms 700 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 4 ms 592 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 4 ms 592 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 7 ms 848 KB Output is correct
13 Correct 7 ms 852 KB Output is correct
14 Correct 7 ms 976 KB Output is correct
15 Correct 7 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 4 ms 700 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 4 ms 592 KB Output is correct
9 Correct 4 ms 720 KB Output is correct
10 Correct 4 ms 592 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 7 ms 848 KB Output is correct
13 Correct 7 ms 852 KB Output is correct
14 Correct 7 ms 976 KB Output is correct
15 Correct 7 ms 848 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 4 ms 592 KB Output is correct
18 Correct 6 ms 828 KB Output is correct
19 Correct 6 ms 848 KB Output is correct
20 Correct 7 ms 876 KB Output is correct
21 Correct 6 ms 824 KB Output is correct
22 Correct 6 ms 844 KB Output is correct
23 Correct 6 ms 848 KB Output is correct
24 Correct 6 ms 848 KB Output is correct
25 Correct 7 ms 848 KB Output is correct
26 Incorrect 11 ms 1228 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 848 KB Output is correct
5 Runtime error 1 ms 460 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -