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"
using namespace std;
vector<int>p[200001];
long long count_swaps(vector<int>s){
int n=s.size();
for(int i=n-1;0<=i;i--)p[s[i]+n].push_back(i);
long long r=0;
for(int i=0;i<n;i++){
if(p[s[i]+n].back()!=i)continue;
p[s[i]+n].pop_back();
if(s[i]<0)r+=p[n-s[i]].back()-i-1,p[n-s[i]].pop_back();
else r+=p[n-s[i]].back()-i,p[n-s[i]].pop_back();
}
return r;
}
# | 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... |