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;
#include "shoes.h"
long long count_swaps(std::vector<int> a) {
int n = a.size () / 2;
map < int, int > c;
long long ans = 0;
for (int i = 0; i < n; ++i)
{
int j = i * 2 + 1;
while (a[j] != -a[i * 2]) ++j;
while (j != i * 2 + 1) swap (a[j], a[j - 1]), --j, ++ans;
if (a[i * 2] > 0) swap (a[i * 2], a[i * 2 + 1]), ++ans;
}
return ans;
}
# | 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... |