| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 500285 | pavement | Arranging Shoes (IOI19_shoes) | C++17 | 865 ms | 351428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
int seg[400005];
ll ans;
bool ed[400005];
vector<int> s;
queue<int> has[400005];
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ft[400005];
inline int ls(int x) { return x & -x; }
pair<int, int> qry(int p, int x) {
pair<int, int> r = make_pair(0, 0);
p = s.size() - p + 2;
for (; p; p -= ls(p)) {
r.first += ft[p].order_of_key(x);
r.second += ft[p].size() - ft[p].order_of_key(x);
}
return r;
}
void upd(int p, int v) {
p = s.size() - p + 2;
for (; p <= s.size(); p += ls(p)) ft[p].insert(v);
}
ll count_swaps(vector<int> _s) {
s = _s;
for (int i = 0; i < s.size(); i++) {
if (!has[-s[i] + s.size() / 2].empty()) {
seg[i] = has[-s[i] + s.size() / 2].front();
ed[i] = 1;
if (s[i] < 0) ans++;
has[-s[i] + s.size() / 2].pop();
} else has[s[i] + s.size() / 2].push(i);
}
for (int i = 0; i < s.size(); i++) {
if (!ed[i]) continue;
pair<int, int> tmp = qry(seg[i] + 1, seg[i]);
upd(i, seg[i]);
ans += (ll)tmp.first + (ll)tmp.second * 2ll;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
