# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423572 | schse | Arranging Shoes (IOI19_shoes) | C++17 | 1108 ms | 272656 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"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(std::vector<int> s)
{
vector<int> posadd(s.size());
vector<bool> sorted(s.size(), false);
vector<stack<int>> pleft(s.size() + 1), plright(s.size() + 1);
iota(posadd.begin(), posadd.end(), 0);
long long numswaps = 0;
for (int e, i = 0; i < s.size(); i++)
{
if (sorted[i])
continue;
for (e = i + 1; e < s.size(); e++)
{
if (s[i] == -s[e] && !sorted[e])
break;
}
sorted[i] = sorted[e] = true;
for (int c = i + 1; c < e; c++)
posadd[c]++;
numswaps += posadd[e] - posadd[i] - 1;
if (s[i] > 0)
numswaps++;
}
return numswaps;
}
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... |