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 get_dist(vector<int> ord)
{
ll sol = 0;
for (int i = 0; i < (int) ord.size(); i++)
{
sol += abs(ord[i] - i);
}
return sol / 2;
}
long long count_swaps(vector<int> a)
{
int n = (int) a.size() / 2;
if (n == 1)
{
if (a[0] < 0)
{
return 0;
}
else
{
return 1;
}
}
bool sim_sub = 1;
for (int i = 0; i < n; i++)
{
sim_sub &= (a[i] < 0 && a[i + n] > 0 && a[i] == -a[i + n]);
}
if (sim_sub)
{
vector<int> ord;
for (int i = 0; i < n; i++)
{
ord.push_back(i);
ord.push_back(i + n);
}
return get_dist(ord);
}
return 0;
}
# | 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... |