№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3856 |
2 | jiangly | 3747 |
3 | orzdevinwang | 3706 |
4 | jqdai0815 | 3682 |
5 | ksun48 | 3591 |
6 | gamegame | 3477 |
7 | Benq | 3468 |
8 | Radewoosh | 3462 |
9 | ecnerwala | 3451 |
10 | heuristica | 3431 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 168 |
2 | -is-this-fft- | 162 |
3 | Dominater069 | 160 |
4 | Um_nik | 159 |
5 | atcoder_official | 156 |
6 | djm03178 | 153 |
6 | adamant | 153 |
8 | luogu_official | 149 |
9 | awoo | 148 |
10 | TheScrasse | 146 |
Название |
---|
I can`t understend why answer is "1 2 3".
1 because {1}={2}, 2 because {3,1}={10,1}, and what is 3?
UPD. understood
3 because {1,2} = {4,5}
Maybe in KMP:
a[0]...a[i]...a[j]...a[k]
a[0]...a[i]==a[j]...a[k]
ifa[0]...a[i-1]==a[j]...a[k-1]
anda[i]==a[k]
.a[i]==a[k]
if and only if count of numbers which greather thena[i]
ina[0]..a[i-1]
is equal to count of numbers which greather thena[k]
ina[j]..a[k-1]
.We can use the struct like segment tree, which help us get this count in
O(log(400000))
(just +1 toa[i]
when we add numbera[i]
ans -1 else). If we getsuffix(a[j]..a[k-1])
we don't forget to decrease all values which don't include to this suffix (it'sa[j]..a[h]
, ifa[j]..a[k-1]=a[j]..a[h]a[h+1]..a[k-1]
). And first we should decrease all numbers as it possibly in any sequence because numbers are in the range1..2^32
(then we can use a segment tree).I don't know is it correct solution, but maybe.
Yes, I did something like that for POJ 3167, using a BIT. But in that problem we only need to match one pattern. In SPOJ UNTITLED you need to match many patterns.
read the solution to ceoi 2011 Matching