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>
typedef long long ll;
using namespace std;
ll count_swaps(vector<int> S)
{
ll ans = 0;
ll found = 0;
for (ll i = 0; i < (int)S.size(); i += 2)
{
found = find(S.begin() + i, S.end(), -S[i]) - S.begin();
ans += (found - i - (S[i] < 0 ? 1 : 0));
S.insert(S.begin() + i + (S[i] < 0 ? 1 : 0), -S[i]);
S.erase(S.begin() + found + 1);
}
return ans;
}
# | 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... |