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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> s) {
long long sz = s.size();
vector<bool> vis(sz);
map<long long,queue<long long>> mp;
for (long long i = 0; i<sz; i++){
mp[s[i]].push(i);
}
long long ans = 0;
for (long long i = 0; i<sz; i++){
if (vis[i]) continue;
mp[s[i]].pop();
long long rev = -s[i];
long long v = mp[rev].front();
vis[v] = true;
mp[rev].pop();
ans += v-i-(s[i]<0);
}
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... |