|
|
вернуться в форумIn case of WA#7 Notice that there are 18*3=54 participants, 64bit-type should be used for masks. Re: In case of WA#7 It's possible to solve that problem with only 32-bit masks. Encode team number k as 2^k (in c "1 << k", in pascal "1 shl k"). Create an array (I named it "check"): forall (i) { check[i] = 0; forall (j, not equal i) { if (there is a member in team j that exists also in team i) then check[i] = check[i] bitwise or (2 ^ j); } } You can encode every possible teams combination in one number from interval [0 .. (2^k) - 1]. Note that the number is less than 2 ^ 18 (or 262144). Then enumerate all numbers from that interval and for every number S for every bit p in position q in number S check inequality "S & check[q] > 0". If for some p in position q in number S this inequality is true, than state S is inacceptable. Edited by author 23.09.2011 01:18 |
|
|