# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
295030 | SamAnd | Arranging Shoes (IOI19_shoes) | C++17 | 1086 ms | 2816 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;
#define m_p make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 200005;
int n;
int a[N];
long long count_swaps(std::vector<int> s)
{
n = sz(s) / 2;
for (int i = 1; i <= n * 2; ++i)
a[i] = s[i - 1];
ll ans = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = (i - 1) * 2 + 1; j <= n * 2; ++j)
{
if (a[j] == -a[(i - 1) * 2 + 1])
{
for (int k = j; k > (i - 1) * 2 + 2; --k)
{
++ans;
swap(a[k], a[k - 1]);
}
break;
}
}
if (a[(i - 1) * 2 + 1] > 0)
{
++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... |