CHECHOC - Editorial

My code not working Pls someone help…
all corner and edge tc considered…
https://www.codechef.com/viewsolution/36039792

Hey Guys,
My Solution
This is My solution please go through it and tell me where I m wrong

@rajarshi_basu @cherry0697 @anon70990627

sed lyf :cry: :cry:

Can anyone please help me out with this code.
I tried to include all cases, still i am getting a WA. This code is working fine when I checked the possible test cases.

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

base case is wrong even if y<x, for 1 block ans should be x as there is no adjacent cell, its no need to satisfy the condition of sum <=y,

so for (n==m==1)
ans = x;

check this if you still dont get it
English Explanation
Hindi Explaination

what if when m is odd and in the last else part it can not be always y+x
think and try it

First try, if you cant solve it watch this
English Explanation
Hindi Explaination

Same for me. I have written the special ‘if case’ of n==m==1, but taken min(x,y) as solution.

If you feel difficulties on finding WA, try this. It will gives you WA as well as Correct answer
CHECHOC WA | TEST CASE GENERATOR

Can anyone please tell me why the following code gets “Wrong Answer (WA)” ?

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

for _ in range(int(input())):
n,m,x,y=list(map(int, input().split()))
if y>(2x):
y=2
x

ans=0
if n%2==0:
    a=n//2
    ans=y*a*m
elif m%2==0:
    a=m//2
    ans=y*a*n
else:
    a=n*y
    n1=n//2
    m1=m//2
    b=min(x,y)
    ans=(m1*a)+(n1*y)+b 
    
print(ans)
1 Like

it is accepted but it is not the correct code
let see for

1
19 19 101 189

answer should be 34121 , however this code gives 36461

whats wrong in this please help
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
long long int n,i,j,m,x,y,p,count=0;
cin>>n>>m>>x>>y;
long long int a[n][m];
if(y>=x2)
{
count=x
n*m;
cout<<count<<endl;
}
else
{
if(x>y)
{
for(i=0;i<n;i++)
{
if(i%2==0)
{
for(j=0;j<m;j++)
{
if(j%2==0)
{
count=count+y;
}
else
{
count=count+0;
}
}}
else
{
for(j=0;j<m;j++)
{
if(j%2==0)
{
count=count+0;
}
else
{
count=count+y;
}

			}
		}
    }	
			}
		else
	{
	for(i=0;i<n;i++)
	{
		if(i%2==0)
		{
		for(j=0;j<m;j++)
		{
			if(j%2==0)
			{
				count=count+x;
			}
			else
			{
				count=count+y-x;
			}
		}}
		else
		{
        	for(j=0;j<m;j++)
			{
			if(j%2==0)
			{
				count=count+y-x;
			}
			else
			{
				count=count+x;
			}
				
			}
		}
    }}
	cout<<count<<endl;
    }
}

}

Fails on

1
7 3 8 2

Correct ans- 22. Your output- 28

: ( missed 100 pts for 1*1 testcase

for mn=1 and y<x why should we fill x in the cell as it is obvious from second proposition that sum is less than y so it is obvious that each element should be either less than y or equal to.
Filling x in 1
1 matrix (x>y) is really out of context.
That costed 100 points and wasted a lot of time too. Even if one is able to find out that corner case is m==1 and n==1,the logic which prob setter used indeed beyond interpretation

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 !