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;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
deque<int> build_hull(deque<int> v, bool inv) {
sort(v.begin() + 1, v.end(), [=](int x, int y) {
return is_clockwise(v[0], x, y) ^ inv;
});
deque<int> h;
for (int x : v) {
while (h.size() > 1 && !(is_clockwise(*(h.end() - 2), *(h.end() - 1), x) ^ inv)) {
h.pop_back();
}
h.push_back(x);
}
return h;
}
const int N = 1e5;
bool ban[N];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int n = get_n();
deque<int> v1 = { 1 }, v2 = { 1 };
for (int i = 3; i <= n; i++) {
if (is_clockwise(1, 2, i)) {
v2.push_back(i);
}
else {
v1.push_back(i);
}
}
v1.push_back(2);
v2.push_back(2);
v1 = build_hull(v1, 0);
v2 = build_hull(v2, 1);
// for (int i : v1)
// cout << i << " ";
// cout << "\n";
// for (int i : v2)
// cout << i << " ";
// return 0;
v2.pop_front();
v2.pop_back();
for (int x : v2) {
while (v1.size() > 1 && is_clockwise(v1[1], v1[0], x)) {
ban[v1.front()] = 1;
v1.pop_front();
}
v1.push_front(x);
}
reverse(all(v2));
for (int x : v2) {
while (v1.size() > 1 && !is_clockwise(*(v1.end() - 2), *(v1.end() - 1), x)) {
ban[v1.back()] = 1;
v1.pop_back();
}
v1.push_back(x);
}
sort(all(v1));
v1.erase(unique(all(v1)), v1.end());
int ans = 0;
for (int i : v1) {
if (!ban[i])
ans++;
}
cout << ans;
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... |