← 返回 google 的题目列表Belt Packing with 2D Item Sizes (Distance Threshold Triplet)
类型:online_judge
Problem: 2D Triplet Packing (Distance Threshold)
Items arrive online. Each item is a 2D point p = [x, y].
A triplet p1, p2, p3 is packable if the maximum pairwise Euclidean distance among them is < threshold.
Implement Packer2D(threshold) with method add(p):
Insert point p.
If any valid triplet exists after insertion, return one such triplet and remove it from the system.
Otherwise return empty.
Constraints: up to 1e5 insertions; coordinates up to 1e9.
Note: This is a reconstructed version based on the interview write-up; the exact condition may differ.
Example
Input
threshold=3, points: (0,0),(1,1),(2,0)
Output
one valid triplet