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;
int pos[100001];
long long count_swaps(vector<int> s)
{
long long rez=0;
int n=s.size();
long long nn=n/2;
bool check=0;
for(int i=0;i+nn<n;i++)
{
if(s[i]>0 || s[i+nn]<0)
{
check=1;
break;
}
else if(-s[i]!=s[i+nn])
{
check=1;
break;
}
}
if(!check)
{
rez=(nn*(nn-1))/2;
return rez;
}
for(int i=0;i<n;i+=2)
{
for(int j=i+1;j<n;j++)
{
if(abs(s[i])==abs(s[j]) && s[i]*s[j]<0)
{
for(int k=j;k>i+1;k--)
{
swap(s[k],s[k-1]);
rez++;
}
if(s[i+1]<0)
{
swap(s[i],s[i+1]);
rez++;
}
break;
}
}
}
return rez;
}
# | 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... |