This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> p(n);
for (int &v : p) {
cin >> v;
}
vector<int> ans = p;
for (int mask = 0; mask < (1 << n); mask += 2) {
vector<int> b = p;
for (int i = 1; i < n; i++) {
if ((mask >> i) & 1) {
swap(b[i], b[(i + 1) / 2 - 1]);
}
}
ans = min(ans, b);
}
for (int i = 0; i < n; i++) {
cout << ans[i] << " \n"[i + 1 == n];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |