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 <vector>
#include <bits/stdc++.h>
long long count_swaps(std::vector<int> arr)
{
int n=arr.size();
long long cnt=0;
for(int k=0;k<n*2;k+=2)
{
int sal=0;
for(int i=k+1;i<n*2;i++)
{
if(arr[i]*-1==arr[k])
{
sal=i;
break;
}
}
for(int i=sal;i>k;i--)
{
int l1=arr[i-1];
arr[i-1]=arr[i];
arr[i]=l1;
cnt++;
}
if(arr[k]>arr[k+1])
{
int l1=arr[k];
arr[k]=arr[k+1];
arr[k+1]=l1;
cnt++;
}
}
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... |