| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 909939 | vjudge1 | Arranging Shoes (IOI19_shoes) | C++17 | 1100 ms | 3248 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>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int searchNumberLeftMost(vector<int> &shoes, int target) {
for (int i = 1; i < shoes.size(); i++)
if (shoes[i] == target)
return i;
return -1;
}
ll solve(vector<int> &shoes) {
if (shoes.size() == 2)
return shoes[0] > shoes[1];
int shoe = shoes[0];
int right = searchNumberLeftMost(shoes, -shoe);
shoes.erase(shoes.begin());
shoes.erase(shoes.begin() + right - 1);
int distance = right;
if (shoe < 0)
distance--;
return distance + solve(shoes);
}
ll count_swaps(vector<int> shoes) { return solve(shoes); }
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... | ||||
