Friday, June 16, 2017

Solution task 23 region 61 EGE 2017 via bitmasks


***************************************
Original system looks like 
***************************************
(x1 V ┐x2) ^ (y1 V ┐y2) ^ (┐x1 V y1) = 1
(x2 V ┐x3) ^ (y2 V ┐y3) ^ (┐x2 V y2) = 1
(x3 V ┐x4) ^ (y3 V ┐y4) ^ (┐x3 V y3) = 1
(x4 V ┐x5) ^ (y4 V ┐y5) ^ (┐x4 V y4) = 1
(x5 V ┐x6) ^ (y5 V ┐y6) ^ (┐x5 V y5) = 1
(┐x6 V y6) = 1

Split original system into 3 equvalent first one :-
 
******************
System 1
******************
 
x2 => x1 = 1
x3 => x2 = 1
x4 => x3 = 1
x5 => x4 = 1
x6 => x5 = 1

*****************
System 2
*****************
 

y2 => y1 = 1
y3 => y2 = 1
y4 => y3 = 1
y5 => y4 = 1
y6 => y5 = 1
 
***********************************************************************
System 3 ( toi be taken in account when concantenating X and Y)
***********************************************************************
x1 => y1 = 1
x2 => y2 = 1
x3 => y3 = 1
x4 => y4 = 1
x5 => y5 = 1
x6 => y6 = 1

Build bitmasks for {x} and {y}

x6 x5 x4 x3 x2 x1
------------------
1  1  1  1  1  1 
0  1  1  1  1  1 
0  0  1  1  1  1
0  0  0  1  1  1 ==>
0  0  0  0  1  1 
0  0  0  0  0  1 
0  0  0  0  0  0

y6 y5 y4 y3 y2 y1
------------------
1  1  1  1  1  1 <==
0  1  1  1  1  1 <==
0  0  1  1  1  1 <==
0  0  0  1  1  1 <==
0  0  0  0  1  1  => 5-th row is not allowed for concateneting with 4-th row fom X
0  0  0  0  0  1        due to x3=1 and y3=0 . Hence x3 => y3 =0 ( 1 => 0)
0  0  0  0  0  0 

We would name them further matrix X and matrix Y 
 
************************
Now start concatenate
************************
First row from X with first row from Y
due to x6 => y6 =0
 
Second row from X with first and second rows from Y
Analyze attempt to pick up third row from Y
Then we'll get x5 => y5 = 0
 
Third row from X with rows 1,2,3 from Y
Analyze attempt to pick up fourth  row from Y
Then we'll get x4 => y4 =0
. . . . . . . . . . . . . . . . . . . 

Row number k from X may be concatenated with first k rows from Y
Analyze row (k+1) from Y  it has 0 on place number (k),
and x(k) = 1 in row number k from X
Then we'll get (x(k) => y(k)) = 0 where y(k)=0  belongs row (k+1) from Y

Thus final count = 1 +2 +3 + 4 + 5 + 6 +7 =(7*8)/2 = 28


No comments:

Post a Comment