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