CF1718D Permutation for Burenka

Description

We call an array $ a $ pure if all elements in it are pairwise distinct. For example, an array $ [1, 7, 9] $ is pure, $ [1, 3, 3, 7] $ isn't, because $ 3 $ occurs twice in it. A pure array $ b $ is similar to a pure array $ c $ if their lengths $ n $ are the same and for all pairs of indices $ l $ , $ r $ , such that $ 1 \le l \le r \le n $ , it's true that $ $$$\operatorname{argmax}([b_l, b_{l + 1}, \ldots, b_r]) = \operatorname{argmax}([c_l, c_{l + 1}, \ldots, c_r]), $ $ where $ \\operatorname{argmax}(x) $ is defined as the index of the largest element in $ x $ (which is unique for pure arrays). For example, $ \\operatorname{argmax}(\[3, 4, 2\]) = 2 $ , $ \\operatorname{argmax}(\[1337, 179, 57\]) = 1 $ .

Recently, Tonya found out that Burenka really likes a permutation $ p $ of length $ n $ . Tonya decided to please her and give her an array $ a $ similar to $ p $ . He already fixed some elements of $ a $ , but exactly $ k $ elements are missing (in these positions temporarily $ a\_i = 0 $ ). It is guaranteed that $ k \\ge 2 $ . Also, he has a set $ S $ of $ k - 1 $ numbers.

Tonya realized that he was missing one number to fill the empty places of $ a $ , so he decided to buy it. He has $ q $ options to buy. Tonya thinks that the number $ d $ suits him, if it is possible to replace all zeros in $ a $ with numbers from $ S $ and the number $ d $ , so that $ a $ becomes a pure array similar to $ p $ . For each option of $ d$$$, output whether this number is suitable for him or not.

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first test case for $ d = 9 $ , you can get $ a = [5, 9, 7, 6] $ , it can be proved that $ a $ is similar to $ p $ , for $ d=1 $ and $ d=4 $ it can be proved that there is no answer. In the second test case for $ d = 1 $ , you can get $ a = [1, 5, 10, 9, 3] $ , for $ d = 8 $ , you can get $ a = [3, 5, 10, 9, 8] $ , it can be proved that for $ d = 11 $ there is no answer.