#C9298. Clock Segment Display
Clock Segment Display
Clock Segment Display
You are given the current state of a digital clock’s segments and a desired time in the format (HH:MM). The clock displays four digits (two for hours and two for minutes), with each digit represented by 7 segments. The current state is provided as a string of 28 characters (each group of 7 characters represents one digit) where each character is either '1' (the segment is working) or '0' (the segment is broken). For each digit in the desired time, determine if every segment required to display that digit is available (i.e. marked as '1') in the corresponding section of the current state. If all required segments for every digit are working, print "YES"; otherwise, print "NO".
For example, for a mapping of digits to segments where digit 0 is represented by segments ({0,1,2,4,5,6}) (assuming segments are numbered from 0 to 6), if one of these segments for a desired digit is off in the current state, then that digit cannot be displayed properly.
The mapping for each digit is given below in LaTeX format:
(\text{0}: {0,1,2,4,5,6}) (\text{1}: {2,5}) (\text{2}: {0,2,3,4,6}) (\text{3}: {0,2,3,5,6}) (\text{4}: {1,2,3,5}) (\text{5}: {0,1,3,5,6}) (\text{6}: {0,1,3,4,5,6}) (\text{7}: {0,2,5}) (\text{8}: {0,1,2,3,4,5,6}) (\text{9}: {0,1,2,3,5,6})
The desired time string is of the form (HH:MM) and you should consider only the four digits (ignoring the colon).
inputFormat
The first line contains an integer (T) representing the number of test cases. Each test case consists of two lines:
- The first line is a 28-character string representing the state of the clock's segments (4 digits (\times) 7 segments each).
- The second line is a string in the format (HH:MM) representing the desired time.
Input is read from standard input (stdin).
outputFormat
For each test case, output a single line: "YES" if the desired time can be displayed given the current segment state, or "NO" otherwise. Output is printed to standard output (stdout).## sample
1
1111111111111111111111111111
12:34
YES