# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 165 |
2 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 160 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Name |
---|
You can just ignore it now. (I assume you don't know MO's algorithm)
This problem can be easily solved by MO's algorithm. As always ECPC problems are standard problems, either you know or you don't know.
I already read about MO's algorithm and learned it... If i ignored it now how i will learn this!?
Please write the solution if you know. as i am really interesed to solve this problem.
spend your time learning binary search rather than more advanced algorithms that appear very infrequently.
Just use MO, maintain a data of each freq how many time it appeared.
Like say $$$freq[x]$$$ is how many time $$$x$$$ appeared, $$$freq2[x]$$$ how many time $$$x$$$ was a freq of a number, you can update that while adding/deleting one element in $$$O(1)$$$
Then to check that every freq from $$$X$$$ to $$$Y$$$ appeared, go for loop check that every $$$freq2[X...Y]$$$ are greater than $$$0$$$.
Sorting querys and maintainning data is $$$O(NsqrtN)$$$ as a standared MO is. For answering the query its extra $$$sqrtN$$$. (the for loop can't go more than $$$O(sqrtN)$$$ otherwise the sum of freq is greater than $$$N$$$ and that is impossible).
Complexity : $$$O((N+Q)*sqrtN)$$$