#include #include #include #include #include #include #include #include #include #include #include typedef long long llong; const int MAXN = 100000 + 10; const int INTINF = 1e9; const llong INF = 1e18; const int MAXLOG = 17; int n; struct Point { llong x, y; }; llong size(Point a, Point b, Point c) { return a.x * b.y + a.y * c.x + b.x * c.y - b.y * c.x - a.x * c.y - a.y * b.x; } llong myAbs(llong num) { if (num < 0) return -num; return num; } bool shouldAdd; struct Line { Point b, e; bool lies(Point p) { return myAbs(size(b, e, p)) == 0; } std::pair intersection(std::pair A, std::pair B, std::pair C, std::pair D) { // Line AB represented as a1x + b1y = c1 llong a = B.second - A.second; llong b = A.first - B.first; llong c = a*(A.first) + b*(A.second); // Line CD represented as a2x + b2y = c2 llong a1 = D.second - C.second; llong b1 = C.first - D.first; llong c1 = a1*(C.first)+ b1*(C.second); llong det = a*b1 - a1*b; if (det == 0) { shouldAdd = false; return std::make_pair(0, 0); } else { shouldAdd = true; if ((myAbs(b1*c - b*c1)) % det != 0) { shouldAdd = false; return {0, 0}; } if ((myAbs(a*c1 - a1*c)) % det != 0) { shouldAdd = false; return {0, 0}; } llong x = (b1*c - b*c1)/det; llong y = (a*c1 - a1*c)/det; return std::make_pair(x, y); } } Point intersection(Line a, Line b) { std::pair A = {a.b.x, a.b.y}; std::pair B = {a.e.x, a.e.y}; std::pair C = {b.b.x, b.b.y}; std::pair D = {b.e.x, b.e.y}; std::pair res = intersection(A, B, C, D); return {res.first, res.second}; } }; Line lines[MAXN]; void solve() { std::mt19937 rng(std::chrono::steady_clock().now().time_since_epoch().count()); while (true) { int x = rng() % n + 1; int y = rng() % (n - 1) + 1; if (y >= x) y++; // std::cout << "try: " << x << ' ' << y << '\n'; Point res = lines[x].intersection(lines[x], lines[y]); if (!shouldAdd) { continue; } std::vector curr; for (int i = 1 ; i <= n ; ++i) { // std::cout << "here: " << i << ' ' << if (lines[i].lies(res)) { curr.push_back(i); } } if (curr.size() >= n / 4) { std::cout << res.x << ' ' << res.y << '\n'; std::cout << curr.size() << '\n'; for (const int &idx : curr) { std::cout << idx << ' '; } std::cout << '\n'; exit(0); } } } void input() { std::cin >> n; for (int i = 1 ; i <= n ; ++i) { std::cin >> lines[i].b.x >> lines[i].b.y >> lines[i].e.x >> lines[i].e.y; if (lines[i].b.x > lines[i].e.x) std::swap(lines[i].b, lines[i].e); } } void fastIOI() { freopen("intersection.in", "r", stdin); freopen("intersection.out", "w", stdout); std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIOI(); input(); solve(); return 0; }