I am so sorry. I omitted the word BINARY
I tried a lot of solutions for this problem, and my last one was of linear time. Still I got TLE on 2 test cases. Hence the question.
ADAROOKS personally was easy for me, primarily because I used the concept of finite projective planes.
@alei basically I used the formula p^2 + p + 1 > N. Gave me all primes between 11 and 37, both inclusive, for given values of N. Then just chose my matrix based on the value of N. The approach worked solely because N started from 100 and thus the smallest matrix (100x100) has 9 rooks per row. And it only increases with N.
You didn’t answer my question though
What was the time complexity expected for BINARY?
Your solution looks very interesting. Could you explain it in a lot more detail? I looked through your code and I understand what it does but why does it work?
I would say its a coincidence because if N would have been smaller my approach would have failed. But any incidence matrix of this sort has this inherent property that the 1s do not form a rectangle and that is what we needed for this question. Since the whole matrix has this property, it wasn’t likely that its subset won’t have it as well. The only question was of satisfaction of 8N criteria, which I checked at N = 100.
How the stackers and some people here are able to solve it so fast…I have given a lot of time to this question still did not got anything on time…Is the finite projections solution so obvious?..i have not even heard of it…any good tutorials for it??..
No bro no… The obvious solution is this one… In the first column, place rooks at co-ordinates:-1,4,7…47 … Then for the second column, add 1 to previous co-ordinates and hence, the problem is over
Link to my solution:-CodeChef: Practical coding for everyone