CHEFTIC - Editorial

“We can just do bruteforce by putting ‘X’ in each of the empty place of grid and check whether the grid has KK consecutive ‘X’'s or not.”

I think, this will not work for a test case like-

1

3 2

. . .

. . .

. . .

Here the actual answer is ‘NO’ but using this algorithm it will give ‘YES’.

My code is here-
https://www.codechef.com/viewsolution/9499155

@debjitdj, I think the editorialist meant, putting X at given position and checking if a solution exists, then removing the X placed for next iteration. Putting it simply, as the chef can play only one move, putting X at all possible locations is not what the editorialist meant to say.

1 Like

The links to the Problem in the Contest section and Practice section are incorrect. Please fix them.

Could someone point out what’s wrong in my solution here or give a set of n=k=3 tests?
https://www.codechef.com/viewsolution/9503691

Thanks

@likecs I have a doubt. Is this a valid test case?-

1

4 3

. X O .

X O O X

O X X O

X O X O

Because in this case that logic will also no work.

Done exactly like this !!!

https://www.codechef.com/viewsolution/9500258

and got AC :slight_smile:

1 Like

Can anyone help me find out test cases for 3rd subtask for which my solln. does not work?
https://www.codechef.com/viewsolution/9502837

1 Like

how can we access the minor diagonal elements?

Can anyone, give some hints or algorithm to be used to solve it in O(n^2)?

the question was poorly expressed. I thought that we had to check all possible diagonals for win

You can add only one X.

And what about this test case?

1

4 3

. X O .

X O O X

O X X O

X O X O

In that case also, it will work. You can put X in two places and check for those cases. Answer will be NO.

But the answer should be ‘YES’…because there are already 3 consecutive ‘X’.

That input is invalid according to problem. The board cannot already have some winner.

1 Like

Invalid, read the last line of the problem saying that it will be always chef’s chance and the board will not have any winner already.

Oh! I missed the last line. Thankz :slight_smile:

Sorry. I missed the last line.

@likecs: I have expanded the editorial, hope that will answer the question properly.

Oh, I didn’t see that. Yes it’s invalid input.