{"problem":{"name":"B. Count Palindromes","description":{"content":"Given two times when seen on a digital clock, count the number of moments between these two times (both start and end time included) when the time was a palindrome.  A digital clock shows time in the","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":524288},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10058B"},"statements":[{"statement_type":"Markdown","content":"Given two times when seen on a digital clock, count the number of moments between these two times (both start and end time included) when the time was a palindrome. \n\nA digital clock shows time in the format HH:MM:SS (hours:minutes:seconds). \n\nFor example, 2:40:38 pm is represented as 14:40:38. \n\nThe first line contains q ( ≤ 105) queries. This is followed by q lines each containing two time strings, t1 and t2, which are 6 digit integers that represent times shown by a digital clock. It is ensured that t1 and t2 are valid times(t1 occurs on or before t2).\n\nFor each query in one line print the number of palindromic times.\n\nQuery 1: Only 1 moment is considered in this case, i.e., 00:00:01. We can clearly see that 00:00:01 is not a palindromic string. \n\nQuery 4: Between 02:38:15 and 03:01:16, there are 3 moments that are palindromic strings. They are 02:44:20, 02:55:20 and 03:00:30. \n\nNote that the time as seen on a digital clock should appear as a palindrome. 1 is a palindrome, but 00:00:01 on a digital clock is not.\n\n## Input\n\nThe first line contains q ( ≤ 105) queries. This is followed by q lines each containing two time strings, t1 and t2, which are 6 digit integers that represent times shown by a digital clock. It is ensured that t1 and t2 are valid times(t1 occurs on or before t2).\n\n## Output\n\nFor each query in one line print the number of palindromic times.\n\n[samples]\n\n## Note\n\nQuery 1: Only 1 moment is considered in this case, i.e., 00:00:01. We can clearly see that 00:00:01 is not a palindromic string. Query 4: Between 02:38:15 and 03:01:16, there are 3 moments that are palindromic strings. They are 02:44:20, 02:55:20 and 03:00:30. Note that the time as seen on a digital clock should appear as a palindrome. 1 is a palindrome, but 00:00:01 on a digital clock is not.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ t \\in \\mathbb{Z} $ be the number of queries.  \nLet $ Q = \\{(T_1^{(k)}, T_2^{(k)}) \\mid k \\in \\{1, \\dots, t\\}\\} $ be the set of queries, where for each $ k $:  \n- $ T_1^{(k)}, T_2^{(k)} $ are 6-digit strings representing valid times in HH:MM:SS format (00:00:00 to 23:59:59).  \n- $ T_1^{(k)} \\leq T_2^{(k)} $ lexicographically (i.e., $ T_1^{(k)} $ occurs on or before $ T_2^{(k)} $).\n\n**Constraints**  \n1. $ 1 \\leq t \\leq 10^5 $  \n2. Each time string $ T = \\text{HHMMSS} $ satisfies:  \n   - $ 0 \\leq \\text{HH} \\leq 23 $  \n   - $ 0 \\leq \\text{MM} \\leq 59 $  \n   - $ 0 \\leq \\text{SS} \\leq 59 $  \n\n**Objective**  \nFor each query $ k $, count the number of times $ T $ in the inclusive range $ [T_1^{(k)}, T_2^{(k)}] $ such that the 6-digit string $ T = d_1d_2d_3d_4d_5d_6 $ satisfies:  \n$$\nd_1 = d_6, \\quad d_2 = d_5, \\quad d_3 = d_4\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10058B","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}