Universal Cup Judging System

Universal Cup

时间限制: 3.5 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

一個 rururutata 型序列定義為可以表示為 $r + r + r + t + t$(其中 $+$ 表示拼接)的序列,其中 $r$ 和 $t$ 是非空序列。

給你一個長度為 $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)$ 滿足條件。

對於第二個詢問,在 $(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, 2, 2, 2)$ 不是 rururutata 型序列,且顯然它也不包含任何更短的 rururutata 型序列。

對於第四個詢問,注意 $(3, 3, 3, 2, 2)$ 不是其連續子陣列。

對於第五個詢問,注意允許 $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.