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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> s) {
int n = s.size();
int p[n / 2];
for (int i = 0; i < n/2; i++)
p[i] = -1;
for (int i = 0; i < n; i++)
{
int k = abs(s[i]) - 1;
if (p[k] == -1)
p[k] = i;
else
p[k] = s[i] > 0? i - p[k] - 1: i - p[k];
}
int sum = 0;
for (int i = 0; i < n/2; i++)
sum += p[i];
return sum;
}
# | 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... |