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;
#define ll long long
ll count_swaps(vector<int> s){
int n = s.size()/2;
map<int,queue<int>> m;
for (int i=0; i<2*n; i++) m[s[i]].push(i);
ll res = 0;
int x = 0;
vector<bool> done(2*n, false);
for (int i=0; i<2*n; i++){
if (done[i]){
x--;
continue;
}
int j = m[-s[i]].front();
m[-s[i]].pop();
res += j-i;
if (s[i] < 0) res--;
done[i] = true;
done[j] = true;
x++;
}
return res;
}
# | 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... |