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");
# | 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 | nor | 150 |
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");
Name |
---|
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.