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 <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> v)
{
int n = v.size();
long long swa = 0;
for (int i = 0; i < 2 * n; i += 2)
{
for (int j = i + 1; j < 2 * n; j++)
{
if (abs(v[j]) == abs(v[i]))
{
for (int k = j; k > i + 1; k--)
swap(v[k], v[k - 1]);
swa += (j - 1 - i);
if (v[i + 1] < 0)
{
swap(v[i], v[i + 1]);
swa++;
}
break;
}
}
}
return swa;
}
# | 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... |