# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294914 | ASDF123 | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 0 KiB |
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 szof(s) (int)s.size()
using namespace std;
const int N = (int)2e5 + 5;
ll count_swaps(vector<int> s) {
ll ans = 0;
int n = szof(s) / 2;
for (int i = 0; i < n * 2; i += 2) {
int pos = -1;
for (int j = i + 1; j < n * 2; j++) {
if (s[j] == -s[i]) {
pos = j;
break;
}
}
while (pos > i + 1) {
swap(s[pos], s[pos - 1]);
pos--;
ans++;
}
if (s[pos] < 0) {
swap(s[pos], s[pos - 1]);
ans++;
}
}
return ans;
}
//signed main() {
}