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;
long long count_swaps(vector<int> s)
{
long long n = s.size(), ret = 0;
for (int i = 0; i < n; i++)
{
if (i % 2 == 0)
{
int j;
for (j = i; s[j] != -abs(s[i]); j++);
ret += j - i;
int t = s[j];
for (int k = j - 1; k >= i; k--)
s[k + 1] = s[k];
s[i] = t;
}
else
{
int j;
for (j = i; s[j] != -s[i - 1]; j++);
ret += j - i;
int t = s[j];
for (int k = j - 1; k >= i; k--)
s[k + 1] = s[k];
s[i] = t;
}
/*for (int i : s)
cerr << setw(2) << i << ' ';
cerr << '\n';*/
}
return ret;
}
# | 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... |