# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645369 | rc_catunta | Arranging Shoes (IOI19_shoes) | C++17 | 17 ms | 1860 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;
long long count_swaps(vector<int> s) {
if(s.size()/2 <= 8){
int n = s.size()/2;
// Etiquetar los zapatos
map<int, int> m;
int id = 1;
for(auto zapato: s){
if(zapato<0){
m[id]=-zapato;
id++;
}
}
// Creamos el vector de posibilidades
vector<int> v;
for(int i=1;i<=n;i++) v.push_back(i);
int res = 100000000;
// Generador de posibilidades
int it=0;
int pasos = 0;
vector<int> cs = s;
for(int i=0;i<v.size();i++){
int tam = m[v[i]];
// Colocar el izquierdo
// Buscamos el izquierdo
for(int j=i*2;j<cs.size();j++){
if(cs[j]==-tam){
for(int k=j-1;k>=i*2;k--){
swap(cs[k],cs[k+1]);
pasos++;
}
break;
}
}
// Buscamos el izquierdo
for(int j=i*2+1;j<cs.size();j++){
if(cs[j]==tam){
for(int k=j-1;k>=i*2+1;k--){
swap(cs[k],cs[k+1]);
pasos++;
}
break;
}
}
}
res = min(res,pasos);
return res;
}
else return 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... |