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(std::vector<int> s) {
int n=s.size()/2;
vector<int> v[2*n+1];
for(int i=0;i<2*n;i++)v[s[i]+n].push_back(i);
for(int i=0;i<=2*n;i++)reverse(v[i].begin(),v[i].end());
int ans=0;
for(int i=0;i<2*n;i+=2){
int x;
for(int j=0;j<=2*n;j++){
for(int k:v[j]){
if(k==i)x=j-n;
}
}
int idx=v[-x+n].back();
v[-x+n].pop_back();
v[x+n].pop_back();
ans+=idx-1-i+(x>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... |