Can anybody please explain me the following part of this Solution:- int t = H[h][l].second ^ H[h][r].second; bool ok = t — (t & -t); if(!ok) printf("Yes\n"); else printf("No\n");
№ | Пользователь | Рейтинг |
---|---|---|
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 | 165 |
2 | maomao90 | 163 |
2 | 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 |
Can anybody please explain me the following part of this Solution:- int t = H[h][l].second ^ H[h][r].second; bool ok = t — (t & -t); if(!ok) printf("Yes\n"); else printf("No\n");
Название |
---|
int t = H[h][l].second ^ H[h][r].second; Each bit say that letter is odd counts or even. What's this means? (t & -t) Let's see on bit form. Put t = 1001100. So -t = 0110100 t & -t =0000100 And you can see, that smallest nonzero bit always stay nonzero. So, we should know, how much nonzero bits are there in t? If there is 1 or 0 nonzero bit, t = (t — &t) and t — (t & -t) = 0 and answer is "we can build polyndrom", else there are 2 or more bits and we can't built polyndrom. Sorry for my poor English :)
I am not able to understand what does 't' mean here?
For each query we have some letters. We can build from this letters polyndrom. If there are 2 or more letters, that appear odd counts, we can't build polyndrom. So, let's define for each letter a bit. For 'a' — first bit, for 'b' — second bit. And if 'a' appears odd counts — first bit equal 1, else equal 0. So, we have 26 bits and this bits build number. This is 't'. After this we should find number of nonzero bits.
Thanx.I got it now.