# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537290 | ERH | Arranging Shoes (IOI19_shoes) | C++14 | 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 <iostream>
#include <vector>
using namespace std;
int lista[100000][2];
long long count_swaps(vector<int> v){
long long int total=0;
for(int i=0; i<v.size(0); ++i){
int a=lista[i];
if(a<0){
a=-a;
lista[a][1]=i+1;
if(lista[a][0]){
total+=lista[a][1]-lista[a][0];
lista[a][1]=lista[a][0]=0;
}
} else {
lista[a][0]=i+1;
if(lista[a][1]){
total+=lista[a][0]-lista[a][1]-1;
lista[a][1]=lista[a][0]=0;
}
}
}
return total;
}