# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152483 | WLZ | Arranging Shoes (IOI19_shoes) | C++17 | 1083 ms | 1936 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;
long long count_swaps(vector<int> s) {
long long ans = 0;
int n = (int) s.size() / 2;
for (int i = 0; i < n; i++) {
int pos = i * 2;
if (s[pos] > 0) {
int other;
for (int j = pos + 1; j < 2 * n; j++) {
if (s[j] < 0) {
other = j;
break;
}
}
for (int j = other; j > pos; j--) {
swap(s[j], s[j - 1]);
ans++;
}
}
if (s[pos + 1] != -s[pos]) {
int other;
for (int j = pos + 2; j < 2 * n; j++) {
if (s[j] == -s[pos]) {
other = j;
break;
}
}
for (int j = other; j > pos + 1; j--) {
swap(s[j], s[j - 1]);
ans++;
}
}
}
return ans;
}
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... |