Comments
+3

Yeah, thanks. I don't know why I was forgetting this condition for this test case.

For the problem — Monopole Magnets, it is written:- "every row and every column has exactly one segment of black cells or is all-white"

From what I'm understanding, there should be continuous black cells within a row or a column. No white between them.

So, if I have a 3x3 square with the middle cell (1,1) white and all other cells black. Then I can have a solution with four south magnets at the four corners ((0,0), (0,2), (2,0), and (2,2)).

Can anyone tell me if it's correct or I'm making some mistake?

You can think it like this :

Suppose k=3 and the sequence is 4 3 4 2 So, you need to make a new sequence with period 3 basically.

You can make a set with distinct elements from the original sequence and of length 3, like (2,3,4). Now, you just replace every element with this small sequence. You'll get -

2 3 4* 2 3* 4 2 3 4* 2* 3 4

(* represents the elements in the original sequence)