# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314195 | ShiftyBlock | 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 <bits/stdc++.h>
#include "shoes.h"
#define rep(i,a,b) for(int i=a; i<b; i++)
// #define int long long
using namespace std;
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;
}