Submission #812554

#TimeUsernameProblemLanguageResultExecution timeMemory
812554tch1cherinSwap (BOI16_swap)C++17
10 / 100
48 ms280 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...