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;
}
}
long long end = i;
if(cr[i]<0){
end = i+1;
}
//cout<<end<<endl;
for(long long j=pos;j>end;j--){
if(j-1 < end){
break;
}
ans++;
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... |