# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034909 | Tob | Triangles (CEOI18_tri) | C++14 | 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.
#include <bits/stdc++.h>
#include "trilib.h"
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;
typedef pair <ld, ld> pdd;
const int N = 40007;
bool cmp(int x, int y) {
return is_clockwise(1, x+1, y+1);
}
void rek(vector <int>& v) {
if (v.size() <= 1) return;
int m = (v.size())/2;
vector <int> a, b;
for (int i = 0; i < m; i++) a.pb(v[i]);
for (int i = m; i < v.size(); i++) b.pb(v[i]);
rek(a); rek(b);
for (int i = 0, j = 0, k = 0; k < v.size(); k++) {
if (i == a.size()) v[k] = b[j++];
else if (j == b.size()) v[k] = a[i++];
else {
if (cmp(a[i], b[j])) v[k] = a[i++];
else v[k] = b[j++];
}
}
}
int bio[N];
int give_answer () {
int n = get_n();
// for (int i = 1; i <= n; i++) cin >> co[i].F >> co[i].S;
vector <int> v[2];
for (int i = 2; i < n; i++) v[cmp(1, i)].pb(i);
rek(v[1]);
rek(v[0]);
vector <int> u;
auto dod = [&](int x) {while (u.size() > 1 && !is_clockwise(u[u.size()-2]+1, u.back()+1, x+1)) u.pop_back(); u.pb(x);};
for (int ii = 0; ii < 2; ii++) {
dod(0); dod(1);
for (int x : v[1]) dod(x);
dod(0);
for (int x : v[0]) dod(x);
}
reverse(all(u));
int cnt = 0;
memset(bio, -1, sizeof bio);
for (int i = 0; i < n; i++) {
if (bio[u[i]] != -1) {
cnt -= bio[u[i]];
break;
}
cnt++;
bio[u[i]] = i;
}
return cnt;
}