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 <iostream>
typedef long long ll;
ll count_swaps(std::vector<int> s) {
ll answer = 0;
for (int i = 0; i < (int) s.size(); i += 2) {
int j = i + 1;
while (s[i] != -s[j]) {
j++;
}
if (s[i] < 0) {
answer += j - i - 1;
} else {
answer += j - i;
}
while (j - 1 > i) {
std::swap(s[j], s[j - 1]);
j--;
}
if (s[i] > 0) {
std::swap(s[i], s[i + 1]);
}
}
return answer;
}
# | 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... |