Universal Cup Judging System

Universal Cup

実行時間制限: 3.5 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

Sebuah barisan bertipe rururutata didefinisikan sebagai sebuah barisan yang dapat ditulis sebagai $r + r + r + t + t$ ($+$ berarti penggabungan/konkatenasi) menggunakan barisan tak kosong $r$ dan $t$.

Anda diberikan sebuah barisan bilangan bulat $S = (S_1, S_2, \dots, S_N)$ dengan panjang $N$. Terdapat $Q$ kueri yang harus Anda proses secara berurutan.

Pada setiap kueri, diberikan bilangan bulat $L$ dan $R$. Tentukan apakah terdapat barisan bertipe rururutata sebagai subarray bersebelahan dari $(S_L, S_{L+1}, \dots, S_R)$.

Masukan

Masukan diberikan dalam format berikut:

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

Setiap kueri diberikan dalam format berikut:

L R

Batasan

  • $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$
  • Semua nilai masukan adalah bilangan bulat.

Keluaran

Cetak $Q$ baris.

Pada baris ke-$i$, cetak Yes jika barisan bertipe rururutata ada untuk kueri ke-$i$, dan No jika sebaliknya.

Contoh

Masukan 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

Keluaran 1

Yes
Yes
No
No
Yes

Catatan

Untuk kueri pertama, $(S_1, S_2, S_3, S_4, S_5) = (3, 3, 3, 2, 2)$ adalah barisan bertipe rururutata. Kondisi terpenuhi dengan mengambil $r = (3)$ dan $t = (2)$.

Untuk kueri kedua, di antara $(S_4, S_5, \dots, S_{12})$, subarray bersebelahan $(S_4, S_5, \dots, S_{10}) = (2, 2, 2, 4, 3, 4, 3)$ adalah barisan bertipe rururutata. Kondisi terpenuhi dengan mengambil $r = (2)$ dan $t = (4, 3)$.

Untuk kueri ketiga, $(3, 3, 2, 2, 2)$ bukanlah barisan bertipe rururutata, dan jelas tidak memuat barisan bertipe rururutata yang lebih pendek pula.

Untuk kueri keempat, perhatikan bahwa $(3, 3, 3, 2, 2)$ bukanlah subarray bersebelahan.

Untuk kueri kelima, perhatikan bahwa $r$ dan $t$ diperbolehkan sama.

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.