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