Feb Long Challenge TEAMNAME solution with help of bits ? how?

this long challenge was bad for me i stuck at Teamname , I was just checking solutions and found this

https://www.codechef.com/viewsolution/42443290

please can somebody explain this solution or tell me a suitable approach ?

after seeing this solution i feel like competitive coding is really really something :pensive:

mp[str] |= 1<<k;
This means that this suffix has starting letter as (β€˜a’ + k). It’s same as adding in its set.

int xorr = a ^ b;
a = a & xorr;
b = b & xorr;

xorr will contain only the bits (letters) that are not in both of them.
a & xorr will contain the bits (letters) which is only in a
b & xorr will contain the bits (letters) which is only in b

cnt += 2 * (__builtin_popcount(a) * __builtin_popcount(b));

Now, if some letter is only in a and another one is only in b, swapping them will result in an unfunny pair of strings, thus giving us the number of required pairs, with these two suffixes. A factor of two is just to take care the ordering of the strings.