Q.Find the number of pairs in the array whose bitwise AND is greater then K?
Size of Array: N=5*(10^5)
Elements in Array: (10^9)>=a[i]>=1
Range for K: (10^9)>=K>=0
Expected Time Complexity: O(N) or O(NlogN)
№ | Пользователь | Рейтинг |
---|---|---|
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 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Q.Find the number of pairs in the array whose bitwise AND is greater then K?
Size of Array: N=5*(10^5)
Elements in Array: (10^9)>=a[i]>=1
Range for K: (10^9)>=K>=0
Expected Time Complexity: O(N) or O(NlogN)
Название |
---|
It's better to add your approach to the blog than just posting a question. A possible approach could be using some tree structure to store the numbers you have seen so far and somehow traverse the tree to find the count of numbers whose AND with the current element will be > K.
You can solve this using SOS dp. Iterate over i, now we want to find j such that a[i] & a[j] >= K. It's easy to see that there are log masks such that a[i] & a[j] >= K is equivalent to a[j] includes one if the masks(a[j] & mask == mask). This can be solved using sum over subset dp