# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
301222 | eagle30 | Arranging Shoes (IOI19_shoes) | C++14 | 1139 ms | 814420 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;
int mi(vector<int> vi, vector<int> pe, multiset<int> mu, int s){
int n=vi.size();
if(s==n){
int coun=0;
for(int i=0; i<n; i++){
for(int j=i; j<n; j++){
if(pe[i]==vi[j]){
for(int k=j-1; k>=i; k--)
swap(vi[k], vi[k+1]), coun++;
break;
}
}
}
return coun;
}
int mini=2e9;
vector<int> asdf;
for(auto x:mu){
asdf.push_back(x);
}
for(int i=0; i<asdf.size(); i++){
pe[s]=-asdf[i];
pe[s+1]=asdf[i];
mu.erase(mu.find(asdf[i]));
mini=min(mini, mi(vi, pe, mu, s+2));
mu.insert(asdf[i]);
}
return mini;
}
long long count_swaps(vector<int> s) {
vector<int> yo;
int n=s.size();
yo.assign(n, 0);
map<int, int> mp;
for(int i=0; i<n; i++)
mp[abs(s[i])]++;
multiset<int> mu;
for(auto x:mp){
for(int i=0; i<x.second/2; i++)
mu.insert(x.first);
}
return mi(s, yo, mu, 0);
}
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... |