#C7755. Coordinated Decorations
Coordinated Decorations
Coordinated Decorations
You are given two arrays representing decoration themes used in two different venues. Your task is to determine whether the two arrays share at least one common decoration. If there is at least one common element between the two arrays, print YES
; otherwise, print NO
.
The input consists of multiple test cases. For each test case, there are two lines:
- The first line contains a space-separated list of integers representing the decoration values of the first venue.
- The second line contains a space-separated list of integers representing the decoration values of the second venue.
The output for each test case should be on a separate line.
Note: Even though the problem statement mentions "subarray", the intended check is whether there is at least one common element in the two arrays.
inputFormat
The input is read from standard input (stdin) and has the following format:
T arr1_line_1 arr2_line_1 arr1_line_2 arr2_line_2 ... arr1_line_T arr2_line_T
Here, T
is the number of test cases. Each test case consists of two lines: the first line contains the decorations in the first array and the second line contains the decorations in the second array. Each line contains space-separated integers.
outputFormat
For each test case, output a single line with either YES
if there is at least one common decoration in both arrays, or NO
if there is none. The output is printed to standard output (stdout).
2
1 2 3 4 5
5 4 3 2 1 0
1 2 3
4 5 6 7
YES
NO
</p>