Ruffians
Time limit1sMemory limit2048 MB
Given a two-by-five grid of digits, the task is to decide whether two cards with equal numbers sit in different rows and different columns.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Problem
Ashley and Brandon are playing the new hit card game, Ruffians! In Ruffians, ten cards are dealt out in a grid of two rows and five columns. Each card has a number on it from 1 to 9. Ashley and Brandon are both looking for a pair of cards that have the same number.
After playing this game for a while, they realize that there is always a pair of cards that have the same number. To make the game harder, they require that they find a pair of cards with the same number, and that the two cards are in different rows and different columns.
Given an arrangement of cards, determine if such a pair exists or not.
Input
The first line of input contains a single integer (). This is the number of test cases.
Each test case is represented on two lines. The first line of each test case contains five integers, each between and . The second line of the test case also contains five integers, each between and . These two lines combined form the grid of two rows and five columns of cards.
Output
Output lines, one for each test case.
For each test case, if there exists a pair of cards with the same number in different rows and different columns, output YES. Otherwise, output NO.