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 cnt=0;
void resi(int l,int r,int n,std::vector<int> s)
{
if(l>r) return;
int prva=s[l];
for(int i=l+1;i<=r;i++)
{
if(s[i]==(prva*(-1)))
{
if(prva<0)
{
cnt+=(i-(l+1));
swap(s[i],s[l+1]);
}
else
{
cnt+=(i-l);
swap(s[i],s[l+1]);
swap(s[l],s[l+1]);
}
break;
}
}
resi(l+2,r,n,s);
}
long long count_swaps(std::vector<int> s) {
int n=s.size();
int l=0;
int r=n-1;
resi(l,r,n,s);
return cnt;
}
# | 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... |