# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631757 | Stavab | 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.
using namespace std;
long long count_swaps(vector<int> S)
{
long long sum = 0;
int temp;
for(int i = 0; i < S.size() - 1; i += 2)
{
temp = 0;
for(int j = i + 1; j < S.size(); j++)
{
if(temp)
swap(temp, S[j]);
else
temp = S[j];
if(temp == -S[i])
{
if(temp < 0)
sum += j - i;
else
sum += j - i - 1;
break;
}
}
}
return sum;
}