# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
501666 | 2022-01-04T09:27:31 Z | LucaIlie | Xor Sort (eJOI20_xorsort) | C++17 | 6 ms | 972 KB |
#include <iostream> #define MAX_N 1000 #define MAX_K 40000 using namespace std; struct answer { int x, y; }; int v[MAX_N + 1]; answer ans[MAX_K]; int main() { int n, s, k, i, j, p; cin >> n >> s; for ( i = 1; i <= n; i++ ) cin >> v[i]; k = 0; for ( i = 1; i <= n; i++ ) { for ( j = 1; j <= n - 1; j++ ) { if ( v[j] > v[j + 1] ) { ans[k] = { j, j + 1 }; v[j] ^= v[j + 1]; ans[k + 1] = { j + 1, j }; v[j + 1] ^= v[j]; ans[k + 2] = { j, j + 1 }; v[j] ^= v[j + 1]; k += 3; } } } cout << k << "\n"; for ( i = 0; i < k; i++ ) cout << ans[i].x << " " << ans[i].y << "\n"; return 0; }
Compilation message
# | 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 | 4 ms | 460 KB | Output is correct |
5 | Correct | 3 ms | 460 KB | Output is correct |
6 | Correct | 3 ms | 460 KB | Output is correct |
7 | Correct | 3 ms | 460 KB | Output is correct |
8 | Correct | 3 ms | 460 KB | Output is correct |
9 | Correct | 3 ms | 460 KB | Output is correct |
10 | Correct | 3 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 5 ms | 716 KB | Output is correct |
13 | Correct | 5 ms | 688 KB | Output is correct |
14 | Correct | 6 ms | 648 KB | Output is correct |
15 | Correct | 5 ms | 716 KB | Output is correct |
# | 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 | 4 ms | 460 KB | Output is correct |
5 | Correct | 3 ms | 460 KB | Output is correct |
6 | Correct | 3 ms | 460 KB | Output is correct |
7 | Correct | 3 ms | 460 KB | Output is correct |
8 | Correct | 3 ms | 460 KB | Output is correct |
9 | Correct | 3 ms | 460 KB | Output is correct |
10 | Correct | 3 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 5 ms | 716 KB | Output is correct |
13 | Correct | 5 ms | 688 KB | Output is correct |
14 | Correct | 6 ms | 648 KB | Output is correct |
15 | Correct | 5 ms | 716 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 3 ms | 532 KB | Output is correct |
18 | Correct | 5 ms | 716 KB | Output is correct |
19 | Correct | 6 ms | 716 KB | Output is correct |
20 | Correct | 6 ms | 716 KB | Output is correct |
21 | Correct | 5 ms | 716 KB | Output is correct |
22 | Correct | 5 ms | 716 KB | Output is correct |
23 | Correct | 5 ms | 716 KB | Output is correct |
24 | Correct | 4 ms | 680 KB | Output is correct |
25 | Correct | 4 ms | 716 KB | Output is correct |
26 | Runtime error | 1 ms | 972 KB | Execution killed with signal 11 |
27 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 5 ms | 680 KB | Output is correct |
5 | Runtime error | 2 ms | 972 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |