# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151205 | outsider | 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 "shoes.h"
#include <bits/stdc++.h>
#define ll int
#define x first
#define y second
using namespace std;
ll count_swaps(vector<ll> a){
ll ans=0;
ll n=a.size()/2;
a.push_front(0);
for (int i=0;i<a.size();i++)
{
ll mt=0;
for (ll k=i+1;k<a.size();k++)
{
if (a[k]==-a[i])
{
ans+=mt;
if (a[i]>0)ans++;
a[k]=0;
break;
}
else
if (a[k]!=0)mt++;
}
}
return ans;
}