Omi and the segment trees

How to do SEGTREES from lost in code.i couldn’t find a discussion thread for discussing this contest so created one :stuck_out_tongue:


Thanks for creating a thread :sweat_smile: even I was waiting for this…btw can someone tell me how to solve "Omi and matrix " question from Lost in code contest.

for every b[i] must contain all bits in a[i][k] && a[k][i] for all k atleast. so calculate all b[i] by taking or of all such values.

1 Like

Consider ith row, Consider all bits which are set in any number in this row, for every such bit, it is guaranteed that it would be set in the ith number as matrix is formed by AND operation. So ith number will have all those bits set which are set in any number (other than -1 ofcourse) in its row. After that just take the sum of all numbers.


elegant!!! thanks for explaining bro!

1 Like