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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long count_swaps(std::vector<int> s) {
ll N = s.size() / 2;
int shoes[2 * N];
for (int i = 0; i < 2 * N; i++) {
shoes[i] = s[i];
}
int counter = 0;
for (int i = 0; i < 2 * N; i += 2) {
int find = -shoes[i];
int pos = -1;
for (int j = i + 1; j < 2 * N; j++) {
if (shoes[j] == find)
pos = j;
}
for (int j = pos; j > i; j--) {
swap(shoes[j], shoes[j + 1]);
counter++;
}
if (shoes[i] > shoes[i + 1]) {
swap(shoes[i], shoes[i + 1]);
counter++;
}
}
return counter;
}
# | 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... |