# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
232399 | jam_xd_ | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 0 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(std::vector<int> s) {
/* 10 puntitios :D, ez
if(s[0] < 0 and s[1] > 0)return 0;
if(s[0] > 1 and s[1] < 0)return 1;
*/
int contador=0;
swaps = 0;
int aux;
for(int i=0;i<s.size();i++){
if(s[i] > 0 && i%2 == 0){
for(int j=i;j<s.size();j++){
contador++;
if(s[j] > 0 && i%2==0){
swaps = swaps + contador;
aux = s[i];
s[i] = s[j];
s[j] = aux;
contador = 0;
break;
}
}
}
if(s[i] < 0 && i%2 != 0){
for(int k=i;k<s.size();k++){
contador++;
if(s[j] > 0 && i%2==0){
swaps = swaps + contador;
aux = s[i];
s[i] = s[j];
s[j] = aux;
contador = 0;
break;
}
}
}
}
return swaps;
}