if there’s only one cell there are no pairs of cells so the limit of y does not apply to anything
Damn , missed only the base case
It is not clear whether your remarks is about my question(209) or not. If so, the test case given by you returns answer as 34121 and not 36461 as told by you. Please check again and if possible please tell me where I have done the mistake?
https://www.codechef.com/viewsolution/35987993
Please anyone help me.
Since you have written your code in py , I can’t help ( I know cpp only)
If you know cpp then use it
CHECHOC WA FINDER
It will gives you all posssible Test Cases where you failed.
Try Once, you will Love it!!
The beauty about this question was the base case (1x1)
i literally submitted this code 7 time got WA and time penalty for 70 mins
void test_case(){ int n,m,x,y; cin>>n>>m>>x>>y; int arr[n][m]; lld sum=0; if(n<2){ cout<<x<<endl; return; } x=min(x,y); for(int i=0;i<n;++i){ for(int j=0;j<m;++j){ if((i+j)%2==0){ sum+=x; } else{ sum+=max(0,min(x,y-x)); } } } cout<<sum<<endl; }
ps did you figure out mistake in my code.
what was my mistake is only edge case condition didn’t satisfy.
Here is the correct code to it:
void test_case(){ int n,m,x,y; cin>>n>>m>>x>>y; int arr[n][m]; lld sum=0; if(n*m<2){ cout<<x<<endl; return; } x=min(x,y); for(int i=0;i<n;++i){ for(int j=0;j<m;++j){ if((i+j)%2==0){ sum+=x; } else{ sum+=max(0,min(x,y-x)); } } } cout<<sum<<endl; }
total wasted my rank should have been under 200-300 but ended up getting 2000+ xoxo.
Well, Thankyou for the reply. I corrected the base case but then also, it’s showing WA after submission!
@anon70990627 Sir, please provide me testcases, here is my code CodeChef: Practical coding for everyone
I am getting 95. Is it correct??
Hello, I don’t know what’s wrong with this ; I tried all the base cases
Can anyone please help me look into it:
[CodeChef: Practical coding for everyone](http://My Submission is here)
Thanks in advance
yours code goes wrong where n or m is odd, try drawing a matrix on a paper and fill it , for odd number of n and m, u will see whats wrong, and x==y is not needed.
Try making a matrix and visualize it, if still dont understand see the videos, the question is explained with diagrams
A hint- You did +x, which only adds for 1 block
Draw on paper fill all the block and take out sum for each row and what happens when its odd and what when even
Fails on-
1
9 1 2 8
Ans- 18. Your output 34
Can someone tell me the intuition behind the formula for calculating the black and white squares? I just can’t figure it out at the moment. Thanks
@anon70990627 Thank a lot sir. I really did a silly mistake. I forgot about first condition that value in cell can’t exceeded x.
Suppose there is a matrix, we assume the matrix as a chess board black and white… the first row starts from black,
so in first row we fill it with max possible i.e, x and in 2nd we can only will y-x (as sum of 2 adjacent black +white is always less than y)
@rajarshi_basu @cherry0697 @yash_chandnani
Why my solution is giving WA on submission. Please suggest. Thanks in advance
https://www.codechef.com/viewsolution/36056485
try this testcase:
1
3 3 2 5
your code outputs 23 where as it should be 9*2 = 18
here is my code check it out: solution