Irrigation Interlock
From Codeforces 2181I "Irrigation Interlock" (2025-2026 ICPC NERC Northern Eurasia Finals).
Two irrigation cooperatives share the same valley. The first maintains pumps, the second supervises reservoirs. Whenever both cooperatives lay a pair of new pipes, the pipes must intersect so a joint valve can be installed. A pipe is a straight line segment between two distinct pumps or between two distinct reservoirs. Two pipes intersect if they share at least one common point; touching and overlapping pipes count as intersecting.
Given the coordinates of every pump and every reservoir, decide whether the first cooperative can pick two distinct pumps and the second cooperative can pick two distinct reservoirs so that the two pipes intersect, and report their indices.
Platform input mapping
The Codeforces statement is multi-test and prints one line per scenario. This problem is adapted to a single scenario per call:
- argument
pumpsis an array of[x, y]integer pairs,|x|, |y| <= 10^9, all distinct. - argument
reservoirsis an array of[u, v]integer pairs, all distinct, and no pump equals any reservoir. - both arrays contain at least 2 points.
Return a four-element array [p1, p2, r1, r2] of 1-based indices (p1 < p2, r1 < r2) such that segment pumps[p1-1] -> pumps[p2-1] intersects segment reservoirs[r1-1] -> reservoirs[r2-1].
If no such intersection exists, return [-1].
The official problem accepts any valid quadruple. This content keeps a deterministic canonical answer for exact test comparison: among all crossing pairs, report the first found by enumerating p1 ascending, then p2 ascending, then r1 ascending, then r2 ascending. A semantic checker (see checker.mjs) accepts any valid quadruple instead.
Irrigation Interlock
**From Codeforces 2181I "Irrigation Interlock"** (2025-2026 ICPC NERC Northern Eurasia Finals).