CHECHOC - Editorial

can someone please tell me why my code is giving WA.
https://www.codechef.com/viewsolution/36042692

@abiding_haze7
My code is giving ans as 2 only

Fails on
1
7 3 8 2
Correct ans-22

Can someone please tell me what is wrong in my code?
Getting WA.
https://www.codechef.com/viewsolution/35964790

thank you now i got it

@yash_chandnani , sir i tested your code on inputs 1 1 6 5 and your code gives answer 6 , which is impossible against the given statement that sum should not be greater than y. please clarify sir, or if someone else can !

if there’s only one cell there are no pairs of cells so the limit of y does not apply to anything

1 Like

Damn , missed only the base case

Please check my code, I don’t get where I did wrong solution

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.

Can anyone tell me what’s wrong with my solution?
https://www.codechef.com/viewsolution/36047769

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) :slight_smile:

1 Like

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!

Please check this code
https://www.codechef.com/viewsolution/36048722

@sksama
@anon70990627

@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 :smile:

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

English Explanation
Hindi Explaination