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 <bits/stdc++.h>
#include "shoes.h"
#define fi first
#define sz(x) (int)x.size()
#define se second
#define pll pair <ll,ll>
#define pii pair <int,int>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N = 2e5;
long long count_swaps(vector<int> s) {
ll n = sz(s) / 2, ans = 0;
vector <int> b = s;
for(int i = 0; i < n * 2; i += 2){
if(b[i] < 0){
int j = i + 1;
while(-b[j] != b[i])j++;
while(j > i + 1)swap(b[j], b[j - 1]), j--, ans++;
}else{
int j = i + 1;
while(-b[j] != b[i])j++;
while(j > i)swap(b[j], b[j - 1]), j--, 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... |