이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "shoes.h"
long long count_swaps(std::vector<int> s) {
int n = (int)s.size() / 2;
int N = 2 * n;
long long ans = 0;
for(int pos = 0; pos < n; pos++) {
//printf("pos = %d\n", pos);
int target = -s[2 * pos];
int fnd = -1;
for(int i = 2 * pos + 1; i < N; i++) {
if(s[i] == target) {
fnd = i;
break;
}
}
assert(fnd + 1);
for(int i = fnd - 1; i >= 2 * pos + 1; i--) {
swap(s[i], s[i + 1]);
ans += 1;
}
if(s[2 * pos] > 0) {
swap(s[2 * pos], s[2 * pos + 1]);
ans += 1;
}
//printf("ans = %d\n", ans);
}
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... |