Help In CHECHOC

Can someone explain why I am getting WA for this CodeChef: Practical coding for everyone

idk, but it gives wrong answer to this

1 1 40 1

what is the answer?

40

1 Like

and also to this
3 3 8 10

CodeChef: Practical coding for everyone This is also giving WA. Any corner cases?

https://www.codechef.com/viewsolution/36015518
Please help me in this. I spent a total of 90 minutes but still can’t figure out what’s wrong.

1 Like

You missed the case of 1x1 matrix in which case your answer should be x even if y<x.

How is it 40 if the max limit is 1 ?

for 1 1 100 10… why the answer will be 100 and not 10???

The else part is where the mistake lies bro.
y-x can be greater than x which is not allowed by the statements of the problem

Since there are no adjacent cells

not really corner but this
3 3 8 10

That’s for adjacent cells. Notice for n = 1 m = 1, there are no adjacent cells.

Here try this edge-case n=m=1.
eg. for test-case
1
1 1 1000 1
It is outputting 1, while answer should be 1000 as we do not have to worry about y in this case.
(Think why?!)

i tried explaing here the tricky test cases

(but went really fast)

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

try this 3 3 8 10

1 Like

some base conditions are required , like when x is greater than y then substitute y at every alternate places

see [CodeChef: Practical coding for everyone](http://My Soln) , covers all cases

Consider test case : 1 1 11 7
For this case, there are no adjacent cells in the 1x1 matrix. So, the cell can hold the value of x even if it exceeds ‘y’. This is the only corner case due to which many must have got WA.

1 Like

for 1X1 matrix output will be max value of X as there is no adjacent cell