Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- //#define double long double
- const int M = 1010;
- const double eps = 1e-7;
- struct Point {
- double x, y;
- Point(): x(0), y(0) {}
- Point(double x, double y): x(x), y(y) {}
- Point operator + (const Point &to) const {
- return Point(x + to.x, y + to.y);
- }
- Point operator - (const Point &to) const {
- return Point(x - to.x, y - to.y);
- }
- Point operator * (const double c) const {
- return Point(x * c, y * c);
- }
- Point operator / (const double c) const {
- return Point(x / c, y / c);
- }
- bool operator == (const Point &to) const {
- return fabs(x - to.x) + fabs(y - to.y) <= eps;
- }
- double sqlen() const {
- return x * x + y * y;
- }
- double len() const {
- return sqrt(sqlen());
- }
- Point norm() const {
- return Point(x / len(), y / len());
- }
- Point perp() const {
- return Point(-y, x);
- }
- double ang() {
- if (x >= 0 && y >= 0)
- return y;
- if (x < 0 && y >= 0)
- return 1 - x;
- if (x < 0 && y < 0)
- return 2 - y;
- if (x >= 0 && y < 0)
- return 3 + x;
- }
- };
- const Point zero;
- int n;
- Point p[M];
- double r;
- void read() {
- cin >> n;
- for (int i = 0; i < n; ++i)
- cin >> p[i].x >> p[i].y;
- cin >> r;
- }
- int run(Point pivot) {
- for (int i = 0; i < n; ++i)
- p[i] = p[i] - pivot;
- int bon = 0, tot = 0, ans = 0;
- vector<pair<double, int>> segments;
- for (int i = 0; i < n; ++i)
- if (p[i] == zero) {
- ++bon;
- } else {
- Point d = p[i] / 2.0;
- Point perp = d.perp().norm();
- if (d.sqlen() > r * r)
- continue;
- double len = sqrt(r * r - d.sqlen());
- Point from = d - (perp * len);
- Point to = d + (perp * len);
- assert(fabs(from.len() - r) <= eps);
- assert(fabs(to.len() - r) <= eps);
- double fromAng = from.norm().ang() - eps;
- double toAng = to.norm().ang() + eps;
- if (fromAng > toAng)
- ++tot;
- segments.emplace_back(toAng, -1);
- segments.emplace_back(fromAng, 1);
- }
- sort(segments.begin(), segments.end());
- for (int i = 0; i < (int) segments.size(); ++i) {
- pair<double, int> x = segments[i];
- ans = max(ans, tot);
- tot += x.second;
- assert(tot >= 0);
- }
- ans = max(ans, tot);
- return ans + bon;
- }
- void kill() {
- int ans = 0;
- for (int i = 0; i < n; ++i)
- ans = max(ans, run(p[i]));
- cout << ans << "\n";
- }
- int main() {
- #ifndef LOCAL
- freopen("bombing.in", "r", stdin);
- freopen("bombing.out", "w", stdout);
- #endif
- read();
- kill();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement