#P9222. 「PEOI Rd1」Morning or Afternoon

「PEOI Rd1」Morning or Afternoon

Problem Description

There is a pointer alarm clock that can show the date using a rotating dial. I observed it from one moment to another moment (a closed interval). Now I want to know whether I can be sure to infer whether it is currently in the morning or in the afternoon by checking whether the date changes during this interval.

The alarm clock updates the date exactly at 12:0012:00 in the morning.

After 11:5911:59 in the morning/afternoon, the time becomes 12:0012:00 in the afternoon/morning. After 12:5912:59 in the morning/afternoon, the time becomes 1:001:00 in the morning/afternoon.

Input Format

The first line contains a positive integer TT, the number of test cases.

The next TT lines each contain two times separated by a space, representing the start observation time and the end observation time. Note that the observation time interval is a closed interval.

A time is given in the form (a)b:cd\texttt{(a)b:cd}, where ab\texttt{ab} is the hour and cd\texttt{cd} is the minute. If the a\tt a digit is not omitted, then a0{\tt a}\not=0. It is guaranteed that textttab[1,12]\\texttt{ab}\in[1,12] and cd[0,59]\texttt{cd}\in[0,59].

Output Format

For each test case, output one line: if you can determine it for sure, output Yes; otherwise output No.

7
11:30 12:20
12:20 5:00
11:45 1:04
12:10 12:59
1:09 8:01
12:00 1:00
12:00 12:00
Yes
No
Yes
No
No
No
No

Hint

Sample Explanation #1

Because I observed from 11:3011:30 to 12:2012:20 (assume this 12:2012:20 is the first time it is observed; the a.m./p.m. of later occurrences of 12:2012:20 can be inferred from the current situation, because I know which occurrence the right endpoint 12:2012:20 is), I can determine whether the time is in the morning or afternoon by checking whether the date was updated during this period. For example, if I see that the clock updated the date during this period, then 12:2012:20 must be in the morning; otherwise 12:2012:20 must be in the afternoon.

Sample #3 is similar.

Sample Explanation #2

It could be from 12:2012:20 a.m. to 5:005:00 a.m., or it could be from 12:2012:20 p.m. to 5:005:00 p.m. In both cases, the date cannot change, so I cannot determine it.

Constraints

For 18%18\% of the points, all times are guaranteed not to have hour =12=12 (that is, times like 12:25 will not appear).

For another 9%9\% of the points, T=1T=1. \color{#fff}\sout\text{No, Commander-in-Chief!}

For 100%100\% of the testdata, T100T\leqslant 100, \overline\texttt{ab}\in[1,12], and \overline\texttt{cd}\in[0,59].

Translated by ChatGPT 5