# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Name |
---|
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