「BZOJ3524 / 2223」[POI2014] Couriers

2014年4月19日7,1123

Description

给一个长度为n的序列a。1≤a[i]≤n。
m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2。如果存在,输出这个数,否则输出0。

Input

第一行两个数n,m。
第二行n个数,a[i]。
接下来m行,每行两个数l,r,表示询问[l,r]这个区间。

Output

m行,每行对应一个答案。

Sample Input

7 5
1 1 3 2 3 4 3
1 3
1 4
3 7
1 7
6 6

Sample Output

1
0
3
0
4

HINT

「数据范围」

n,m≤500000

Source

By Dzy

题解

coolinging:可持久化线段树就是记录左右儿子连来连去的线段树

如果这样用似乎应该称为主席树?

 

 

avatar
2 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
GayLeo Recent comment authors
  Subscribe  
提醒
Leo
Leo

学长你的代码交2223好像是WA啊 /01

Gay
Gay

2223输出的是yes和no,当然会wa呀

De℃,.: )
De℃,.: )

BZOJ上权限题………………
提交地址
http://main.edu.pl/en/archive/oi/21/kur