이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "shoes.h"
#define all(x) x.begin(),x.end()
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 100100;
long long count_swaps(std::vector<int> s) {
if (sz(s) <= 2000) {
int n = sz(s) / 2;
ll ans = 0;
for (int i = 0; i < n; i++){
int loc = i + i;
int pos = -1;
for (int j = loc + 1; j < sz(s); j++)
if (s[j] == -s[loc]){
pos = j;
break;
}
assert(pos >= 0);
while (pos > loc + 1){
swap(s[pos], s[pos - 1]);
pos--;
ans++;
}
if (s[loc] > 0)
ans++;
}
return ans;
} else {
ll n = sz(s) / 2;
return n * (n - 1ll) / 2ll;
}
}
| # | 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... |