Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using ld = long double;
- using ll = long long;
- #define double ld
- #define long ll
- using namespace std;
- int cmp(double a, double b) {
- const double EPS = 1e-9;
- if (abs(a - b) <= EPS) {
- return 0;
- } else if (a < b) {
- return -1;
- } else {
- return +1;
- }
- }
- struct Point {
- ld x, y;
- Point(ld a, ld b) {
- x = a;
- y = b;
- }
- Point() {
- x = 0;
- y = 0;
- }
- };
- istream &operator>>(istream &in, Point &p) {
- int x, y;
- in >> x >> y;
- p.x = x;
- p.y = y;
- return in;
- }
- ostream &operator<<(ostream &out, Point p) {
- return out << p.x << " " << p.y;
- }
- ld operator%(Point a, Point b) {
- return a.x * b.y - a.y * b.x;
- }
- Point operator-(Point a, Point b) {
- return {a.x - b.x, a.y - b.y};
- }
- Point operator+(Point a, Point b) {
- return {a.x + b.x, a.y + b.y};
- }
- const int N = 2e5;
- int n;
- Point p[N];
- int turn(Point a, Point b, Point c) {
- return cmp((b - a) % (c - a), 0);
- }
- bool query(Point x) {
- bool precond = turn(p[0], p[1], x) >= 0 && turn(p[0], p[n - 1], x) <= 0;
- if (!precond) {
- return false;
- }
- int l = 0, r = n - 1;
- while (r - l > 1) {
- assert(turn(p[0], p[l], x) >= 0);
- assert(turn(p[0], p[r], x) <= 0);
- assert(turn(p[0], p[l], p[r]) >= 0);
- int m = (l + r) / 2;
- if (turn(p[0], p[m], x) >= 0) {
- l = m;
- } else {
- r = m;
- }
- }
- assert(turn(p[0], p[l], x) >= 0);
- assert(turn(p[0], p[r], x) <= 0);
- assert(turn(p[0], p[l], p[r]) >= 0);
- return turn(p[l], p[r], x) >= 0;
- }
- int main() {
- #ifdef LC
- assert(freopen("input.txt", "r", stdin));
- #else
- assert(freopen("theodore.in", "r", stdin));
- assert(freopen("theodore.out", "w", stdout));
- #endif
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout << fixed << setprecision(10);
- int m, k;
- cin >> n >> m >> k;
- for (int i = 0; i < n; ++i) {
- cin >> p[i];
- }
- p[n] = p[0];
- int answer = 0;
- for (int i = 0; i < m; ++i) {
- Point q;
- cin >> q;
- bool r = query(q);
- answer += r;
- }
- if (answer >= k) {
- cout << "YES\n";
- } else {
- cout << "NO\n";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment