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(s.empty()) 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));
s.erase(s.begin()+i);
s.erase(s.begin());
}
else
{
cnt+=(i-l);
s.erase(s.begin()+i);
s.erase(s.begin());
}
break;
}
}
n-=2;
resi(0,n-1,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... |