This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: tourist
* created:
**/
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
long long count_swaps(vector<int> a) {
int n = a.size() / 2;
long long swaps = 0;
for (int i = 0; i < 2 * n; i += 2) {
int index = -1;
for (int j = i + 1; j < 2 * n; j++) {
if (a[i] + a[j] == 0) {
index = j;
break;
}
}
while (a[i] > 0 || a[i] + a[i + 1] != 0) {
swap(a[index], a[index - 1]);
swaps++;
index--;
}
}
return swaps;
}
# | 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... |