#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> s) {
int n=s.size()/2;
vector<int> x;
for(int i=0; i<2*n; i++){
if(s[i]<0){
x.push_back(s[i]);
}
}
sort(x.begin(), x.end());
long long mx=100000000000000;
do{
long long cnt=0;
for(int i=0; i<n; i++){
for(int j=2*i; j<2*n; j++){
if(s[j]==x[i]){
while(s[2*i]!=x[i]){
cnt++;
swap(s[j], s[j-1]);
j--;
}
break;
}
}
for(int j=2*i+1; j<2*n; j++){
if(s[j]==-x[i]){
while(s[2*i+1]!=-x[i]){
cnt++;
swap(s[j], s[j-1]);
j--;
}
break;
}
}
}
mx=min(mx, cnt);
}while(next_permutation(x.begin(), x.end()));
return mx;
}
/*int main(){
cout<<count_swaps({2, 1, -1, -2});
} */
# | 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... |