# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
906243 | bobbilyking | Arranging Shoes (IOI19_shoes) | C++17 | 61 ms | 9404 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>
using namespace std;
using ll = long long;
#define F(i, l, r) for (ll i = l; i < (r); ++i)
using vl = vector<ll>;
#define A(a) (a).begin(), (a).end()
long long count_swaps(std::vector<int> s) {
ll n = s.size();
map<ll, ll> cnt;
F(i, 0, s.size()) cnt[abs(s[i])]++;
if (n <= 8) {
vl perm; for (auto [k, v]: cnt) {
v/=2;
while(v-- ) perm.push_back(k);
}
sort(A(perm));
ll ans = 1e9;
do {
vl ts(A(s));
ll tans = 0;
for (auto v: perm) {
auto x = find(A(ts), -v);
tans += x - ts.begin();
ts.erase(x);
x = find(A(ts), v);
tans += x - ts.begin();
ts.erase(x);
}
ans = min(ans, tans);
} while (next_permutation(A(perm)));
return ans;
}
if (cnt.size() == 1) {
}
bool subtask4 = 1;
F(i, 0, n) {
subtask4 &= abs(s[i]) == abs(s[i + n/2]);
subtask4 &= s[i] < 0;
subtask4 &= s[i + n/2] > 0;
}
if (subtask4) return n * (n-1)/2;
return -1;
}
Compilation message (stderr)
# | 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... |