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>
#include "shoes.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
ll count_swaps(vi s) {
ll ats = 0;
int N = (int)s.size();
for (int i = 0; i < N; ++i)
{
// if (s[i] > 0) {
// int nx = i + 1;
// while (s[nx] > 0) nx++;
// int val = s[nx];
// s.erase(s.begin() + nx);
// s.insert(s.begin() + i, val);
// ats += nx - i;
// }
// s[i] < 0
int nx = i + 1;
while (s[nx] + s[i] != 0) nx++;
ats += nx - (i + 1);
s.erase(s.begin() + nx);
s.insert(s.begin() + i + 1, -s[i]);
if (s[i] > s[i + 1]) ats++;
i++;
}
return ats;
}
# | 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... |