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>
using namespace std;
#define ll long long
int getIndex(vector<int> v, int K) {
auto it = find(v.begin(), v.end(), K);
if (it != v.end()) return it - v.begin();
else return -1;
}
int ans = 0;
ll count_swaps(vector<int> S) {
if (S.size() == 2) {
ans += (S[0] > 0) ? 1 : 0;
return ans;
} else if (S.size() < 2) return ans;
int in = getIndex(S, S[0]*-1);
ans += S[0] > 0 ? in : in-1;
S.erase(S.begin()+in);
S.erase(S.begin()+0);
return count_swaps(S);
}
# | 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... |