This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <array>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFOR(i,start,end) for(int i = start; i>end; i--)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define mt make_tuple
#define mp make_pair
#define v vector
#define sf scanf
#define pf printf
#define dvar(x) cout << #x << " := " << x << "\n"
#define darr(x,n) FOR(i,0,n) cout << #x << "[" << i << "]" << " := " << x[i] << "\n"
typedef long long ll;
typedef long double ld;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
//template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }
void io() {
#ifdef LOCAL_PROJECT
freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
#else
#endif
ios_base::sync_with_stdio(false); cin.tie(NULL);
}
const ll INF = 1e14;
/***********************CEOI 2014 D1 Fangorn*****************************************/
ll ccw(pii a, pii b, pii c) {
int dx1 = b.first - a.first;
int dy1 = b.second - a.second;
int dx2 = c.first - a.first;
int dy2 = c.second - a.second;
return 1ll * dx1 * dy2 - 1ll * dy1 * dx2;
}
bool cmp(pii a, pii b) {
bool flg1 = a < mp(0, 0);
bool flg2 = b < mp(0, 0);
if (flg1 != flg2) return flg1 < flg2;
return ccw(mp(0, 0), a, b) > 0;
}
pii sub(pii a, pii b) {
return{ a.first - b.first, a.second - b.second };
}
pii mypos;
v<pii> potDest;
int n;
pii obst[2000];
void input() {
cin >> mypos.first >> mypos.second;
cin >> mypos.first >> mypos.second;
int c; cin >> c;
potDest.resize(c);
FOR(i, 0, c)
cin >> potDest[i].first >> potDest[i].second;
cin >> n;
FOR(i, 0, n)
cin >> obst[i].first >> obst[i].second;
}
void getDividers(v<pii> &ans, int x) {
ans.reserve(n - 1);
FOR(i, 0, n) if (i != x)
ans.push_back(sub(obst[x], obst[i]));
sort(all(ans), cmp);
}
int getIndex(v<pii> ÷rs, pii pnt) {
if (cmp(dividers.back(), pnt))
return 0;
if (cmp(pnt, dividers.front()))
return 0;
int x = lower_bound(all(dividers), pnt, cmp) - dividers.begin();
return x;
}
int main() {
io();
input();
FOR(i, 0, n) {
v<pii> dividers;
getDividers(dividers, i);
v<pii> okDest;
int target = getIndex(dividers, sub(mypos, obst[i]));
for (auto d : potDest)
if (getIndex(dividers, sub(d, obst[i])) == target)
okDest.push_back(d);
potDest = okDest;
/* cout << "after tree " << i << "\n";
for (auto p : potDest)
cout << p.first << ", " << p.second << "\n";*/
}
cout << potDest.size() << "\n";
}
# | 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... |