# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087953 |
2024-09-13T15:24:25 Z |
SulA |
Xor Sort (eJOI20_xorsort) |
C++17 |
|
75 ms |
12636 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define bitcount __builtin_popcountll
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int n,s; cin >> n >> s;
int a[n]; for (int i = 0; i < n; cin >> a[i++]);
vector<pair<int,int>> operations;
auto oper = [&](int& x, int& y) {
x ^= y;
};
auto swap = [&](int i, int j) {
oper(a[i], a[j]);
oper(a[j], a[i]);
oper(a[i], a[j]);
operations.emplace_back(i, j);
operations.emplace_back(j, i);
operations.emplace_back(i, j);
};
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (a[j] > a[j + 1])
swap(j, j + 1);
}
}
cout << operations.size() << '\n';
for (auto [i, j] : operations) cout << 1+i << " " << 1+j << '\n';
}
# |
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 |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
736 KB |
Output is correct |
7 |
Correct |
2 ms |
736 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
3 ms |
840 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
992 KB |
Output is correct |
13 |
Correct |
4 ms |
992 KB |
Output is correct |
14 |
Correct |
5 ms |
1244 KB |
Output is correct |
15 |
Correct |
4 ms |
992 KB |
Output is correct |
# |
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 |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
736 KB |
Output is correct |
7 |
Correct |
2 ms |
736 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
3 ms |
840 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
992 KB |
Output is correct |
13 |
Correct |
4 ms |
992 KB |
Output is correct |
14 |
Correct |
5 ms |
1244 KB |
Output is correct |
15 |
Correct |
4 ms |
992 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
3 ms |
736 KB |
Output is correct |
18 |
Correct |
5 ms |
1032 KB |
Output is correct |
19 |
Correct |
3 ms |
988 KB |
Output is correct |
20 |
Correct |
4 ms |
992 KB |
Output is correct |
21 |
Correct |
3 ms |
992 KB |
Output is correct |
22 |
Correct |
4 ms |
860 KB |
Output is correct |
23 |
Correct |
4 ms |
992 KB |
Output is correct |
24 |
Correct |
5 ms |
992 KB |
Output is correct |
25 |
Correct |
3 ms |
992 KB |
Output is correct |
26 |
Incorrect |
7 ms |
1244 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
992 KB |
Output is correct |
5 |
Incorrect |
75 ms |
12636 KB |
Integer 764742 violates the range [0, 40000] |
6 |
Halted |
0 ms |
0 KB |
- |