# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302482 | MasterTaster | 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 long long
using namespace std;
long long count_swaps(std::vector<int> s) {
int n=s.size();
if (n==2)
{
if (s[0]<0) return 0;
else return 1;
}
bool isti=true;
for (int i=1; i<n; i++)
if (abs(s[i])!=abs(s[i-1])) { isti=false; break; }
if (isti)
{
int gde=1;
ll ress=0;
for (int i=0; i<n; i++)
{
if (s[i]>0)
{
ress+=abs(i-gde);
gde+=2;
}
}
return ress;
}
else return
{
ll ress;
ress=(n/2)*(n/2-1)/2;
return ress;
}
}