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>
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second;
using namespace std;
long long count_swaps(std::vector<int> s) {
ll ans = 0;
vi arr = s;
int n = s.size();
for(int i = 0; i < n; i+=2){
int target = arr[i] * -1;
int j = i + 1;
while(j < n && arr[j] != target){
j++;
}
//cout<<i<<" "<<j<<endl;
for(int at = j; at > i + 1; at--){
swap(arr[at], arr[at-1]);
ans++;
}
if(arr[i] > 0){
swap(arr[i], arr[i+1]);
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... |