# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
291555 | juggernaut | 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"
using namespace std;
typedef long long int ll;
long long count_swaps(vector<int>v){
ll cnt=0,q=0,i=0,j;
if(v.size()>2000){
for(;i<v.size();i++)
if(v[i]<0){
cnt+=abs(i-q);
q+=2;
}
return cnt;
}
for(;i<v.size();i+=2){
for(j=i;j<v.size();j++)if(a[i]==-a[j]){
q=j;
break;
}
while(q!=i+1){
swap(v[q],v[q-1]);
q--;
cnt++;
}
if(a[i]>a[i+1])cnt++;
}
return cnt;
}