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(vector<int> s) {
int n=s.size();
int cnt=0;
for(int i=0;i<n;i++){
//cout<<i<<endl;
if(s[i]<0){
for(int j=0;j<n;j++){
if(s[j]+s[i]==0&&!(s[j]+s[j-1]==0&&j<i)){
int cur=j;
if(cur==i+1) break;
if(cur>i){
while(cur!=i+1){
swap(s[cur],s[cur-1]);
//cout<<cur<<" "<<cur-1<<endl;
cur--;
cnt++;
}
}
else{
while(cur!=i){
swap(s[cur],s[cur+1]);
//cout<<cur<<" "<<cur+1<<endl;
cur++;
cnt++;
}
}
break;
}
}
}
}
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... |