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 <stdio.h>
#include <vector>
#include "shoes.h"
using namespace std;
long long count_swaps( vector <int> s ) {
int n, i, j, l;
long long nrSwaps;
n = s.size() / 2;
nrSwaps = 0;
for ( i = 0; i < n; i++ ) {
j = 2 * i;
while ( s[j] > 0 )
j++;
for ( l = j; l > 2 * i; l-- ) {
swap( s[l], s[l - 1] );
nrSwaps++;
}
j = 2 * i + 1;
while ( s[j] != -s[2 * i] )
j++;
for ( l = j; l > 2 * i + 1; l-- ) {
swap( s[l], s[l - 1] );
nrSwaps++;
}
}
return nrSwaps;
}
# | 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... |