CF1702C Train and Queries

Description

Along the railroad there are stations indexed from $ 1 $ to $ 10^9 $ . An express train always travels along a route consisting of $ n $ stations with indices $ u_1, u_2, \dots, u_n $ , where ( $ 1 \le u_i \le 10^9 $ ). The train travels along the route from left to right. It starts at station $ u_1 $ , then stops at station $ u_2 $ , then at $ u_3 $ , and so on. Station $ u_n $ — the terminus. It is possible that the train will visit the same station more than once. That is, there may be duplicates among the values $ u_1, u_2, \dots, u_n $ . You are given $ k $ queries, each containing two different integers $ a_j $ and $ b_j $ ( $ 1 \le a_j, b_j \le 10^9 $ ). For each query, determine whether it is possible to travel by train from the station with index $ a_j $ to the station with index $ b_j $ . For example, let the train route consist of $ 6 $ of stations with indices \[ $ 3, 7, 1, 5, 1, 4 $ \] and give $ 3 $ of the following queries: - $ a_1 = 3 $ , $ b_1 = 5 $ It is possible to travel from station $ 3 $ to station $ 5 $ by taking a section of the route consisting of stations \[ $ 3, 7, 1, 5 $ \]. Answer: YES. - $ a_2 = 1 $ , $ b_2 = 7 $ You cannot travel from station $ 1 $ to station $ 7 $ because the train cannot travel in the opposite direction. Answer: NO. - $ a_3 = 3 $ , $ b_3 = 10 $ It is not possible to travel from station $ 3 $ to station $ 10 $ because station $ 10 $ is not part of the train's route. Answer: NO.

Input Format

N/A

Output Format

N/A

Explanation/Hint

The first test case is explained in the problem statement.