# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
149070 | nandonathaniel | Arranging Shoes (IOI19_shoes) | C++14 | 3 ms | 376 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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100],V[100];
long long count_swaps(vector<int> s) {
LL n=(LL)s.size(),now=0;
n/=2;
for(LL i=0;i<s.size();i++){
if(s[i]>0){
now++;
a[now]=s[i];
V[now]=now;
}
}
LL ans=1e18;
do{
LL res=0;
vector<LL> hasil;
for(LL i=1;i<=n;i++){
hasil.push_back(-a[V[i]]);
hasil.push_back(a[V[i]]);
}
//for(LL i=1;i<=2*n;i++)cout << hasil[i-1] << endl;
for(LL i=0;i<s.size();i++){
LL no;
for(LL j=i;j<s.size();j++){
if(s[j]==hasil[i]){
no=j;
break;
}
}
for(LL j=no;j>=i+1;j--){
swap(s[j],s[j-1]);
res++;
}
}
ans=min(ans,res);
}while(next_permutation(V+1,V+n+1));
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... |