#C87. Common Language Check
Common Language Check
Common Language Check
You are given a list of attendees, each with a set of programming languages that they are interested in. Your task is to determine whether there exists at least one programming language that is common for every attendee.
This can be mathematically viewed as finding the intersection $$\bigcap_{i=1}^{n} L_i$$ where each \(L_i\) is the set of languages provided by the i-th attendee. If the intersection is non-empty, print YES
; otherwise, print NO
.
inputFormat
The input is given via standard input. The first line contains a single integer n
which indicates the number of attendees. Each of the next n
lines contains one or more non-empty strings separated by spaces representing the programming languages that the corresponding attendee is interested in.
outputFormat
Output a single line to standard output. Print YES
if there exists at least one language common to all attendees. Otherwise, print NO
.
3
python java
java cpp
java python
YES