Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using Point = complex<long long>;
- int quad(const Point& p) {
- int x = p.real(), y = p.imag();
- assert(x || y);
- if (y < 0) return (x >= 0) + 2;
- if (y > 0) return (x <= 0);
- return (x <= 0) * 2;
- }
- long long cross(Point a, Point b) {
- return (conj(a) * b).imag();
- }
- long long det(Point a, Point b, Point c) {
- return cross(b - a, c - a);
- }
- int Solve(vector<Point> pts) {
- int n = pts.size();
- if (n == 1) return 1;
- vector<Point> v;
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < n; ++j) {
- if (j == i) continue;
- Point d = pts[j] - pts[i];
- v.push_back(d);
- }
- }
- auto by_angle = [&](Point a, Point b) {
- if (quad(a) != quad(b))
- return quad(a) < quad(b);
- return cross(a, b) > 0;
- };
- sort(v.begin(), v.end(), by_angle);
- // v.erase(unique(v.begin(), v.end(), by_angle), v.end());
- vector<int> order(n);
- for (int i = 0; i < n; ++i) {
- order[i] = i;
- }
- int total = 0;
- for (auto p : v) {
- for (int i = 0; i < n; ++i) {
- int at = i;
- while (at > 0) {
- long long d1 = cross(p, pts[order[at]]);
- long long d2 = cross(p, pts[order[at - 1]]);
- if (d1 < d2) {
- swap(order[at], order[at - 1]);
- --at;
- } else break;
- }
- }
- int now = 0;
- for (int i = 0; i < n;) {
- int j = i + 1;
- while (j < n && cross(p, pts[order[i]]) == cross(p, pts[order[j]]))
- ++j;
- int cnt = j - i;
- if (cnt > 1)
- now += cnt;
- i = j;
- }
- now -= now % 2; now += 2;
- now = min(now, n);
- total = max(total, now);
- }
- return total;
- }
- int main() {
- // Test();
- int t; cin >> t;
- for (int tt = 1; tt <= t; ++tt) {
- int n; cin >> n;
- vector<Point> pts;
- for (int i = 0; i < n; ++i) {
- long long x, y; cin >> x >> y;
- pts.emplace_back(x, y);
- }
- cout << "Case #" << tt << ": " << Solve(pts) << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement