# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
992513 | MuntherCarrot | Arranging Shoes (IOI19_shoes) | C++14 | 0 ms | 348 KiB |
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;
#define ll long long
#define all(x) x.begin(), x.end()
ll count_swaps(vector<int> vec){
auto prm = vec;
int n = vec.size();
sort(all(prm));
ll ans = LLONG_MAX;
do{
bool good = 1;
for(int i = 0; i < n; i += 2){
if(prm[i] > 0 || -prm[i] != prm[i + 1]){
good = 0;
}
}
if(good == 0) continue;
ll cnt = 0;
auto f = vec;
for(int i = 0; i < n - 1; i++){
int j = i;
while(f[j] != prm[i]) j++;
while(j > i){
cnt++;
swap(f[j], f[--j]);
}
}
ans = min(ans, cnt);
}while(next_permutation(all(prm)));
return ans;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |