This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "trilib.h"
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n = get_n();
vector<vector<int>> pts(2);
for (int i = 3; i <= n; i++) {
pts[!is_clockwise(1, 2, i)].push_back(i);
}
pts[1].push_back(2);
for (int it = 0; it < 2; it++) {
int sz = (int) pts[it].size();
vector<int> tmp(sz);
function<void(int, int)> Solve = [&](int L, int R) {
if (L == R) {
return;
}
int mid = (L + R) >> 1;
Solve(L, mid);
Solve(mid + 1, R);
for (int i = L; i <= R; i++) {
tmp[i] = pts[it][i];
}
int pl = L, pr = mid + 1;
int ptr = L;
while (pl <= mid || pr <= R) {
if (pl > mid) {
tmp[ptr++] = pts[it][pr++];
} else if (pr > R) {
tmp[ptr++] = pts[it][pl++];
} else if (is_clockwise(1, pts[it][pl], pts[it][pr])) {
tmp[ptr++] = pts[it][pl++];
} else {
tmp[ptr++] = pts[it][pr++];
}
}
for (int i = L; i <= R; i++) {
pts[it][i] = tmp[i];
}
};
Solve(0, sz - 1);
}
vector<int> v;
for (int i : pts[1]) {
v.push_back(i);
}
v.push_back(1);
for (int i : pts[0]) {
v.push_back(i);
}
vector<int> res;
int bef = 0;
for (int it = 0; it < 2; it++) {
bef = (int) res.size();
for (int i : v) {
while (res.size() >= 2 && is_clockwise(res.rbegin()[1], res.back(), i)) {
res.pop_back();
}
res.push_back(i);
}
}
cout << (int) res.size() - bef << endl;
return 0;
}
# | 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... |