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;
long long count_swaps (vector < int > S)
{
int N = (int)S.size();
long long ans = 0;
for(int i = 0; i < N; i += 2)
{
int pos = 0;
for(int j = i + 1; j < N; ++j)
if(S[j] == -S[i])
{
pos = j;
break;
}
ans += (pos - i - 1);
for(int j = pos; j > i + 1; --j)
swap(S[j], S[j - 1]);
if(S[i] > 0)
++ans, swap(S[i], S[i + 1]);
}
return ans;
}
# | 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... |