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;
typedef long long ll;
ll count_swaps(vector<int> S) {
ll n = S.size(), ans = 0;
unordered_map<ll,vector<ll>> M;
for(int i = 0; i < n; i++) {
if(M[S[i]].size()) {
ans += i-M[S[i]].back()-(S[i]>0);
M[S[i]].pop_back();
}
else {
M[-S[i]].push_back(i);
}
}
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... |