This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef NOTSUBMIT
#include "shoes.h"
using namespace std;
#endif
int psh(std::vector<int>& s, int st, int ed){
int res = 0;
for (int j = st; j > ed; j--){
swap(s[j], s[j-1]);
res += 1;
}
return res;
}
long long count_swaps(std::vector<int> s) {
int n = s.size();
int ans = 0;
for (int i = 0; i < n; i += 2){
int p = 0;
for (int j = i; j < n; j++){
if (s[j] == -s[i]){ p = j; break; }
}
ans += psh(s, p, i+1);
if (s[i] > s[i+1]){ swap(s[i], s[i+1]); ans += 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... |