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>
long long count_swaps(std::vector<int> s)
{
int n=s.size();
if(n==2)
{
if(s[0]>0)
return 1;
return 0;
}
int p=abs(s[0]);
int t=1;
for(int i=1;i<n;i++)
{
if(abs(s[i])!=p)
t=0;
}
int arr[101010];
int idx=0;
if(t)
{
long long answer=0;
for(int i=0;i<n;i++)
{
if(s[i]==p)
{
arr[idx]=i;
idx++;
}
}
for(int i=0;i<idx;i++)
answer+=abs(arr[i]-2*i-1);
return answer;
}
return 0;
}
# | 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... |