Video Tutorial: An Interesting Problem on Arrays


Its been a while that I’ve made some video on competitive programming.

The problem that I want to talk about today is:

You are given an array A of size N < 1000 with elements upto 10^{18}.
You have to print any subset S such that:

  1. The AND resultant of all elements in S is 0.
  2. The AND resultant of any 2 elements in S is not 0.

The problem looks easy but is quite twisted, and can be solved once you pick up the hidden observation here.
I read this problem sometime back in Petr’s blog and wanted to share the solution with you guys.

Check out the video here:

Its difficult to pick up such observations but this is what I like about Competitive Programming. It makes you smarter gradually and you start looking at things in a different manner.

Happy Coding!


how petr mitrichev knows soo much…
only rare questions exists that petr couldn’t solve in ONE go…
how does one reaches to that level …
Please answer

1 Like

since long i was waiting for ur video …

I know, but it does happen. I used to think how people solve such problems 2 years back. But now I am able to solve them. Its a gradual process, but it does happen :slight_smile:


sahi hai … hote hote aakhir me ho hi jata hai …

1 Like