Universal Cup Judging System

Universal Cup

Süre Sınırı: 3.5 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

空でない列 $r$ と $t$ を用いて $r + r + r + t + t$($+$ は連結を表す)と書ける列を rururutata 型列と定義します。

長さ $N$ の整数列 $S = (S_1, S_2, \dots, S_N)$ が与えられます。$Q$ 個のクエリが与えられるので、順番に処理してください。

各クエリでは、整数 $L$ と $R$ が与えられます。$(S_L, S_{L+1}, \dots, S_R)$ の連続部分列として rururutata 型列が存在するかどうかを判定してください。

入力

入力は以下の形式で与えられます:

N
S1 S2 ... SN
Q
query1
query2
:
queryQ

各クエリは以下の形式で与えられます:

L R

制約

  • $1 \le N \le 5 \times 10^5$
  • $1 \le S_i \le N$ ($1 \le i \le N$)
  • $1 \le Q \le 5 \times 10^5$
  • $1 \le L \le R \le N$
  • 入力される値はすべて整数である。

出力

$Q$ 行出力してください。

$i$ 行目には、$i$ 番目のクエリに対して rururutata 型列が存在するならば Yes を、そうでないならば No を出力してください。

入出力例

入力例 1

17
3 3 3 2 2 2 4 3 4 3 4 3 2 2 2 2 2
5
1 5
4 12
2 6
8 15
13 17

出力例 1

Yes
Yes
No
No
Yes

注記

最初のクエリでは、$(S_1, S_2, S_3, S_4, S_5) = (3, 3, 3, 2, 2)$ は rururutata 型列です。$r = (3)$、$t = (2)$ とすることで条件を満たします。

2 番目のクエリでは、$(S_4, S_5, \dots, S_{12})$ のうち、連続部分列 $(S_4, S_5, \dots, S_{10}) = (2, 2, 2, 4, 3, 4, 3)$ が rururutata 型列です。$r = (2)$、$t = (4, 3)$ とすることで条件を満たします。

3 番目のクエリでは、$(3, 3, 2, 2, 2)$ は rururutata 型列ではなく、明らかにより短い rururutata 型列も含みません。

4 番目のクエリでは、$(3, 3, 3, 2, 2)$ が連続部分列ではないことに注意してください。

5 番目のクエリでは、$r$ と $t$ が同じであってもよいことに注意してください。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1487EditorialOpen题解jianglyView
#1345EditorialOpen题解MilmonView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.