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 <cmath>
#include <iostream>
using namespace std;
long long count_swaps(vector<int> s)
{
int N = (int)s.size();
long long result = 0;
for(int curPos = 0; curPos < N; curPos += 2)
{
int valide = 0;
for(int pot = curPos + 1; pot < N; pot++)
{
if(abs(s[pot]) == abs(s[curPos]) && s[pot] + s[curPos] == 0)
{
valide = pot;
break;
}
}
//cout << curPos << " " << valide << endl;
for(int i = valide; i > curPos + 1; i--)
{
swap(s[i], s[i - 1]);
result++;
}
if(s[curPos + 1] < 0)
{
swap(s[curPos + 1], s[curPos]);
result++;
}
}
return result;
}
# | 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... |