Universal Cup Judging System

Universal Cup

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

비어 있지 않은 수열 $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)$로 잡으면 조건을 만족합니다.

두 번째 쿼리에서 $(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.