F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

A Sequence Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1526    Accepted Submission(s): 300


Problem Description
One day, WNJXYK found a very hard problem on an Online Judge. This problem is so hard that he had been thinking about the solutions for a couple of days. And then he had a surprise that he misunderstood that problem and easily figured out a solution using segment tree. Now he still wonders that solution for the misread problem.
There is a sequence with $N$ positive integers $A1$,$A2$,...,$An$ and $M$ queries. Each query will give you an interval [L,R] and require an answer with YES/NO indicates that whether the numbers in this interval are continuous in its integer range.
Let us assume that the maximal number in an interval is $mx$ and the minimal number is $mi$. The numbers in this interval are continuous in its integer range means that each number from $mi$ to $mx$ appears at least once in this interval.
 

Input
The input starts with one line contains exactly one positive integer $T$ which is the number of test cases. And then there are T cases follow.
The first line contains two positive integers $n$,$m$ which has been explained above.The second line contains positive integers $A1$,$A2$,...,$An$.
Then there will be m lines followed. Each line contains to positive numbers $Li$,$Ri$ indicating that the ith query’s interval is [$Li$,$Ri$].
 

Output
For each test case, output m line.
Each of following m lines contains a single string “YES”/ “NO” which is the answer you have got.
 

Sample Input
2 3 3 3 1 2 2 3 1 3 1 2 5 3 1 2 2 4 5 1 5 1 3 3 3
 

Sample Output
YES YES NO NO YES YES
 

Hint

T=5
1<=n<=100000
1<=Ai<=10^9
1<=m<=100000
The input file is very large, so you are recommend to use scanf() and printf() for IO.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 15:24:46, Gzip enabled