# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1030708 | Zicrus | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 348 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 <bits/stdc++.h>
#include "shoes.h"
using namespace std;
typedef long long ll;
ll count_swaps(vector<int> a) {
ll n = a.size() / 2;
vector<vector<ll>> seenQNeg(n+10);
vector<vector<ll>> seenQPos(n+10);
ll res = 0;
for (int i = 0; i < a.size(); i++) {
auto &q = a[i] < 0 ? seenQNeg[-a[i]] : seenQPos[a[i]];
auto &pairQ = a[i] > 0 ? seenQNeg[a[i]] : seenQPos[-a[i]];
if (pairQ.empty()) {
(a[i] < 0 ? seenQNeg[abs(a[i])] : seenQPos[abs(a[i])]).push_back(i);
}
else {
ll id = pairQ.back();
pairQ.pop_back();
if (a[i] < 0) {
res += abs(id - i);
}
else {
res += abs(id - i) - 1;
}
}
}
return res;
}
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... |