P1302 Visible Squares
Description
Given $n$ pairwise non-overlapping (their common area is zero) squares on the plane, whose vertex coordinates are all integers. Let the origin be $O(0,0)$. For any square $R$, if there exist two distinct points $A$ and $B$ on the boundary of $R$ such that the interior of $\triangle OAB$ has no common point with any other square, then we say that $R$ is visible from $O$.
Given these $n$ pairwise non-overlapping squares, compute the number of squares visible from the origin $O$.
Input Format
The first line contains the number of squares $n$ ($1 \le n \le 1000$).
Each of the next $n$ lines contains three integers $X,Y,L$ describing a square. Here $X$ and $Y$ are the coordinates of the lower-left vertex, and $L$ is the side length, where $1 \le X, Y, L \le 10000$.
Output Format
Output a single line containing one integer, the number of squares visible from the origin $O$.
Explanation/Hint
Translated by ChatGPT 5