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
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
long long count_swaps(std::vector<int> s) {
int n=s.size()/2;
vector<int> idx[2*n+1];
ll ans=0;
for(int i=0;i<2*n;i++){
if(idx[n-s[i]].empty())idx[n+s[i]].pb(i);
else{
int j=idx[n-s[i]].back();
idx[n-s[i]].pop_back();
ans+=(ll)(i-j-1);
if(s[i]<0)ans++;
}
}
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... |