Universal Cup Judging System

Universal Cup

Límite de tiempo: 3.5 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓
Estadísticas

Una sequenza di tipo rururutata è definita come una sequenza che può essere scritta come $r + r + r + t + t$ ($+$ indica la concatenazione) utilizzando sequenze non vuote $r$ e $t$.

Ti viene data una sequenza di interi $S = (S_1, S_2, \dots, S_N)$ di lunghezza $N$. Ci sono $Q$ query, che devi elaborare in ordine.

In ogni query vengono dati gli interi $L$ e $R$. Determina se esiste una sequenza di tipo rururutata come sottoarray contiguo di $(S_L, S_{L+1}, \dots, S_R)$.

Input

L'input è fornito nel seguente formato:

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

Ogni query è fornita nel seguente formato:

L R

Vincoli

  • $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$
  • Tutti i valori in input sono interi.

Output

Stampa $Q$ righe.

Sulla $i$-esima riga, stampa Yes se esiste una sequenza di tipo rururutata per la $i$-esima query, e No altrimenti.

Esempio

Input 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

Output 1

Yes
Yes
No
No
Yes

Note

Per la prima query, $(S_1, S_2, S_3, S_4, S_5) = (3, 3, 3, 2, 2)$ è una sequenza di tipo rururutata. La condizione è soddisfatta prendendo $r = (3)$ e $t = (2)$.

Per la seconda query, tra $(S_4, S_5, \dots, S_{12})$, il sottoarray contiguo $(S_4, S_5, \dots, S_{10}) = (2, 2, 2, 4, 3, 4, 3)$ è una sequenza di tipo rururutata. La condizione è soddisfatta prendendo $r = (2)$ e $t = (4, 3)$.

Per la terza query, $(3, 3, 2, 2, 2)$ non è una sequenza di tipo rururutata e chiaramente non contiene nemmeno alcuna sequenza di tipo rururutata più corta.

Per la quarta query, nota che $(3, 3, 3, 2, 2)$ non è il sottoarray contiguo.

Per la quinta query, nota che è consentito che $r$ e $t$ siano uguali.

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.