1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| #include <bits/stdc++.h> const double eps = 1e-7; const int MAXN = 2005; using namespace std; struct Point { double x, y, vx, vy; } a[MAXN], q; struct Vector { double x, y; inline friend bool operator < (const Vector &a, const Vector &b) { if (abs(atan2(a.y, a.x) - atan2(b.y, b.x)) < eps) return abs(a.x - b.x) < eps ? a.y < b.y : a.x < b.x; return atan2(a.y, a.x) < atan2(b.y, b.x); }; } b[MAXN]; inline double det(const Vector &a, const Vector &b) { return a.x * b.y - a.y * b.x; } double tmp[MAXN]; int ans; int n, tot; int main() { std::ios::sync_with_stdio(0), std::cin.tie(0), std::cin >> n; double x1, y1, x2, y2, t1, t2; for (register int i = 1; i <= n; i++) std::cin >> t1 >> x1 >> y1 >> t2 >> x2 >> y2, a[i].vx = (x2 - x1) / (t2 - t1), a[i].vy = (y2 - y1) / (t2 - t1), a[i].x = x1 - a[i].vx * t1, a[i].y = y1 - a[i].vy * t1; for (register int i = 1; i <= n; i++) { tot = 0; for (register int j = 1; j <= n; j++) { if (i ^ j) { q.x = a[j].x - a[i].x, q.y = a[j].y - a[i].y, q.vx = a[j].vx - a[i].vx, q.vy = a[j].vy - a[i].vy; double t = q.vx ? q.x / q.vx : q.y / q.vy; if ((abs(q.x - q.vx * t) < eps) && (abs(q.y - q.vy * t) < eps)) tmp[++tot] = t, b[tot].x = q.vx, b[tot].y = q.vy; } } std::sort(tmp + 1, tmp + tot + 1); for (register int j = 1, k; j <= tot; j = k) { k = j + 1; while (k <= tot && abs(tmp[k] - tmp[k - 1]) < eps) k++; ans = std::max(ans, k - j); } std::sort(b + 1, b + tot + 1); for (register int j = 1, k, max; j <= tot; j = k) { k = j + 1, max = (abs(b[k].x - b[k - 1].x) < eps && abs(b[k].y - b[k - 1].y) < eps); while (k <= tot && abs(det(b[k], b[k - 1])) < eps) { k++; if (k <= tot && abs(b[k].x - b[k - 1].x) < eps && abs(b[k].y - b[k - 1].y) < eps) max++; } ans = std::max(ans, k - j - max); } } std::cout << ans + 1; return 0; }
|