Hi guys! Can someone explain me please, how to use BIT in this problem? http://mirror.codeforces.com/problemset/problem/12/D I've seen that some contestants has solved it using BIT but I didn't understand how they do. Thanks in advance! :)
# | 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 |
Hi guys! Can someone explain me please, how to use BIT in this problem? http://mirror.codeforces.com/problemset/problem/12/D I've seen that some contestants has solved it using BIT but I didn't understand how they do. Thanks in advance! :)
Name |
---|
Auto comment: topic has been updated by lllAlonsolll (previous revision, new revision, compare).
Well, the first think that came into my mind was like sort all ladys by say their Bs, then for each lady u have to make a sum query in 2d(Is, Rs) sparce segment tree. Idk there might be something smoother
You can do it with 1D BIT too. Sort ladies by their increasing values of beauty. A lady is a self-murderer iff there is some lady who has a higher beauty, intellect and richness. Maintain a BIT which stores the maximum possible value of intellect for each value of richness. When you traverse the above sorted list in reverse order, if you're at position i, you know that the ladies inserted into the BIT already have higher beauty. Now find the maximum possible intellect for any value of richness greater than the richness of the current lady. If this found value > intellect value of current lady, then there is definitely some lady j (j > i in sorted list) who has higher values of all three parameters. Complexity: O(logn) per query, O(nlogn) overall. :)
Excellent explanation! Thanks a lot, now I finally understand :)
Yea, u r right, i missunderstood the problem a little(i thought u have to count pairs, in which selfmurdering occurs).
But we can't make a BIT of size 109
std::map is enough