当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5172:GTY's gay friends

题目描述
GTY has $ n $ gay friends. To manage them conveniently, every morning he ordered all his gay friends to stand in a line. Every gay friend has a characteristic value $ a_i $ , to express how manly or how girlish he is. You, as GTY's assistant, have to answer GTY's queries. In each of GTY's queries, GTY will give you a range $ [l, r] $ . Because of GTY's strange hobbies, he wants there is a permutation $ [1..r-l+1] $ in $ [l, r] $. You need to let him know if there is such a permutation or not.
输入解释
Multi test cases (about 3) . The first line contains two integers n and m ( $ 1 \leq n, m \leq 1000000 $ ), indicating the number of GTY's gay friends and the number of GTY's queries. the second line contains n numbers seperated by spaces. The $i^{th}$ number $a_i$ ( $ 1 \leq a_i \leq n $ ) indicates GTY's $i^{th}$ gay friend's characteristic value. The next m lines describe GTY's queries. In each line there are two numbers l and r seperated by spaces ( $ 1 \leq l \leq r \leq n $ ), indicating the query range.
输出解释
For each query, if there is a permutation $ [1..r-l+1] $ in $ [l, r] $, print 'YES', else print 'NO'.
输入样例
8 5
2 1 3 4 5 2 3 1
1 3
1 1
2 2
4 8
1 5
3 2
1 1 1
1 1
1 2
输出样例
YES
NO
YES
YES
YES
YES
NO
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #29

源链接: HDU-5172

最后修改于 2020-10-25T23:20:24+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)