| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 977981 | kilkuwu | Arranging Shoes (IOI19_shoes) | C++17 | 1080 ms | 3288 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>
long long count_swaps(std::vector<int> s) {
int n = (int) s.size() / 2;
long long ans = 0;
for (int i = 0; i < n; i++) {
int f = 2 * i;
// find first neg
int fn = -1;
for (int j = f; j < 2 * n; j++) {
if (s[j] < 0) {
fn = j;
break;
}
}
ans += fn - f;
std::rotate(s.begin() + f, s.begin() + fn, s.begin() + fn + 1);
int target = -s[f];
for (int j = f + 1; j < 2 * n; j++) {
if (s[j] == target) {
fn = j;
break;
}
}
ans += fn - (f + 1);
std::rotate(s.begin() + f + 1, s.begin() + fn, s.begin() + fn + 1);
}
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... | ||||
