#K70637. Detect Overlapping Stalls
Detect Overlapping Stalls
Detect Overlapping Stalls
You are given n stalls along with their coordinates in a 2D plane. Each stall is represented by its x and y coordinates. Your task is to determine whether any two stalls share the same coordinates.
Input Format: The input is read from standard input (stdin). The first line contains an integer n denoting the number of stalls. The following n lines each contain two space-separated integers representing the coordinates of a stall.
Output Format: Print a single line containing YES
if there exists at least one pair of stalls with identical coordinates, and NO
otherwise.
Example:
Input:
3
1 1
2 2
3 3
Output:
NO
In mathematical notation, if the set of stalls is given by \( \{(x_i,y_i) : i=1,2,\ldots,n \} \), determine if there exists indices \( i \neq j \) such that \( (x_i,y_i) = (x_j,y_j) \).
inputFormat
The first line of input contains an integer \( n \) indicating the number of stalls. Each of the next \( n \) lines contains two space-separated integers \( x \) and \( y \) representing the coordinates of a stall.
outputFormat
Output a single line containing YES
if there exists at least one pair of overlapping stalls, otherwise output NO
.
3
1 1
2 2
3 3
NO
</p>