This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll count_swaps(vector<int> S) {
ll res = 0;
int n = S.size();
for (int i = 0; i < n; i ++) {
if (i % 2 == 0) {
int j;
for (j = i; j < n; j ++)
if (S[j] < 0)
break;
while (j > i) {
swap(S[j - 1], S[j]);
j --;
res ++;
}
}
else {
int j;
for (j = i; j < n; j ++)
if (S[j] == -S[i - 1])
break;
while (j > i) {
swap(S[j - 1], S[j]);
j --;
res ++;
}
}
}
return res;
}
# | 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... |