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 count_swaps(std::vector<int> s) {
vector<int> cr = s;
long long ans = 0;
long long n = cr.size();
long long i=0;
while(i<n){
long long pos = 0;
for(long long j=i+1;j<n;j++){
if(cr[j]*-1 == cr[i]){
pos=j;
break;
}
}
//cout<<pos<<endl;
long long end = i;
ans += (pos - i - 1);
if(cr[i]<0){
end = i+1;
}else{
ans++;
}
for(long long j=pos;j>=1;j--){
if(j-1 == end){
break;
}
swap(cr[j],cr[j-1]);
}
i+=2;
}
return ans;
}
# | 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... |