# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
826631 | AlesL0 | Arranging Shoes (IOI19_shoes) | C++17 | 1079 ms | 2232 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 sol = 0;
void solve(ll i, vector <int> &s){
if (i < 0)return;
if (s[i] > 0){
ll ind;
for (int j = i-1; j >= 0; j--){
if (s[j] == -s[i]){
ind = j;
break;
}
}
for (int j = ind; j < i-1; j++){
swap(s[j], s[j+1]);
sol++;
}
solve(i-2, s);
}
else {
ll ind;
for (int j = i-1; j >= 0; j--){
if (s[j] == -s[i]){
ind = j;
break;
}
}
for (int j = ind; j < i; j++){
swap(s[j], s[j+1]);
sol++;
}
solve(i, s);
}
}
long long count_swaps(std::vector<int> s) {
solve(s.size()-1, s);
return sol;
}
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... |