# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121397 | BThero | Triangles (CEOI18_tri) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include"trilib.c"
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int MAXN = (int)4e4 + 5;
vector<int> A, B, V;
int idx[MAXN];
bool cmp(int a, int b) {
return is_clockwise(n, a, b);
}
void solve() {
int n = get_n();
int pivot = 1;
for (int i = 2; i < n; ++i) {
if (is_clockwise(n, i, pivot)) {
A.pb(i);
}
else {
B.pb(i);
}
}
sort(all(A), cmp);
sort(all(B), cmp);
int tmp = 0;
for (int x : A) {
idx[++tmp] = x;
}
idx[++tmp] = pivot;
for (int x : B) {
idx[++tmp] = x;
}
V.pb(n);
V.pb(idx[1]);
tmp = 2;
for (int i = 2; i <= n - 1; ++i) {
while (tmp >= 2 && !is_clockwise(V[tmp - 2], V.back(), idx[i])) {
V.pop_back();
--tmp;
}
V.pb(idx[i]);
++tmp;
}
while (V.size() > 3 && !is_clockwise(V.back(), V.front(), V[1])) {
V.erase(V.begin());
}
while (V.size() > 3 && !is_clockwise(V[V.size() - 2], V.back(), V.front())) {
V.pop_back();
}
give_answer(V.size());
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}