#include "shoes.h"
#include "bits/stdc++.h"
using namespace std;
long long count_swaps(vector<int> v)
{
long long result = 0;
int n = v.size();
for (int i = 0; i < n; i += 2)
{
if (v[i] < 0)
{
int fl = -1;
for (int j = i + 1; j < n; ++j)
{
if (-v[i] == v[j])
{
fl = j;
break;
}
}
for (int j = fl; j > i + 1; --j)
{
swap(v[j], v[j - 1]);
result = 1LL * result + 1LL;
}
}
else
{
int fl = -1;
for (int j = i + 1; j < n; ++j)
{
if (-v[i] == v[j])
{
fl = j;
break;
}
}
for (int j = fl; j > i; --j)
{
swap(v[j], v[j - 1]);
result = 1LL * result + 1;
}
}
}
return result;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |