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 ();
map < int, int > c;
long long ans = 0;
for (int i = 0; i < n * 2; ++i)
if (c[-a[i]])
{
--c[-a[i]];
int j = i;
for (; j > 0 && a[j - 1] != -a[j]; --j, ++ans) swap (a[j - 1], a[j]);
if (a[j] < 0) swap (a[j - 1], a[j]), ++ans;
}
else ++c[a[i]];
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... |