Omi and matrix

Hello guys, This question is from “LOST IN CODE” contest . Can some one provide its logic or how to approach this question. … https://www.codechef.com/LICO2020/problems/OMYGAME

1 Like

Consider the binary form of a number. If it has one at any position then it implies that both the numbers from which it is obtained(by AND) must have one at that position. Other positions may have one or zero. But since we want overall minimum so after traversing through whole 2D-array ,we first mark the set bits and after that we just have to sum the values (if we go on setting more bits then it will increase the answer unnecessarily) to obtain the answer :).

3 Likes

ok got it it was an easy one . Thanks anyways