meteora' solution for STRBIT in march cook-off

Hi,

prblem link:

link text

This is the solution of meteora of 2nd problem STRBIT :

link text

for(i = 0; i < N; ++i)

{

		ct += inc[i];

		if(ct&1) str[i] ^='R'^'G';//result of XORing ??

		if(str[i] == 'G') continue;

		++ct;++sol;

		if(i+K < N) inc[i+K] -= 1;

}

I am not able to understand :frowning:

Please anyone help…

1 Like
if(ct&1) str[i] ^='R'^'G';

is equivalent to

if (str[i] = 'R') {
    str[i] = 'G';
} else {
    str[i] = 'R';
}
1 Like