# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314194 | ShiftyBlock | 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.
int count_swaps(vector<int> arr){
int N=arr.size();
int total=0;
for (int i = 0; i < N; ++i)
{
if(arr[i]==0) continue;
int free=0;
int end=-1;
rep(j,i+1,N){
if(arr[j]==-arr[i]){
end=j; break;
}
if(arr[j]==0) free++;
}
arr[end]=0;
if(arr[i]<0) total--;
total+=end-i;
}
return total;
}