# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289815 | IgorI | Arranging Shoes (IOI19_shoes) | C++17 | 1091 ms | 3200 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 <vector>
#include <cstdio>
#include <string>
#include <set>
#include <cstdlib>
#include <iostream>
#include <map>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int (i) = 0; (i) < (n); (i)++)
long long count_swaps(vector<int> a)
{
int n = a.size() / 2;
long long ans = 0;
for (int i = 0; i < a.size(); i += 2)
{
int p;
for (int j = i; j < a.size(); j++)
{
if (a[j] == -a[i])
{
p = j;
break;
}
}
while (p != i + 1)
{
swap(a[p], a[p - 1]);
p--;
ans++;
}
if (a[i] > a[i + 1])
{
swap(a[i], a[i + 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... |