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;
#define ll long long
long long count_swaps(std::vector<int> s) {
ll n = s.size()/2;
ll ans = 0;
for(int i = 0;i < (2 * n);i+=2){
int idx = -1;
for(int j = i;j < (2*n);j++){
if(s[j] < 0){
idx = j;
break;
}
}
while(idx > i){
swap(s[idx], s[idx - 1]);
idx --;
ans ++;
}
idx = -1;
for(int j = i;j < (2*n);j++){
if(s[j] > 0 and abs(s[j]) == abs(s[i])){
idx = j;
break;
}
}
while(idx > i+1){
swap(s[idx], s[idx - 1]);
idx --;
ans ++;
}
}
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... |