I wanna cry so bad rn
Because the question was intended for brute force to pass here.
void solve()
{
//Code here;
int n, m, x, y;
cin >> n >> m >> x >> y;
int a[n + 1][m + 1];
for (int i = 1; i <= n; i++)
{
if (y >= x)
{
if (i & 1)
{
for (int j = 1; j <= m; j++)
{
a[i][j] = x;
int d = (y - x);
if (d > x)
{
a[i][j + 1] = x;
} else
{
a[i][j + 1] = d;
}
j++;
}
} else
{
for (int j = 1; j <= m; j++)
{
int f = (y - x);
if (f < x)
{
a[i][j] = f;
} else
{
a[i][j] = x;
}
a[i][j + 1] = x;
j++;
}
}
} else
{
if (i & 1)
{
for (int j = 1; j <= m; j++)
{
a[i][j] = y;
a[i][j + 1] = 0;
j++;
}
} else
{
for (int j = 1; j <= m; j++)
{
a[i][j] = 0;
a[i][j + 1] = y;
j++;
}
}
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cout << a[i][j] << " ";
}
cout << endl;
}
int tot = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
tot += a[i][j];
}
}
cout << tot << endl;
}
can anyone say where is my wrong? Here the 1x 1 ans also coming write but know why wa is coming?
your concept is not right if take the pattern as
5 0 5
0 5 0
5 0 5
then obviously it will give 25
so always take ma(y,x) and if (y>x) then only take x and (y-x)
@nandansharma1 The error is that in not accepted code for n*m==1 you have written cout<<min(x,y) which will return y when x is greater
but since it has no adjacent element so the second requirement is worthless in this test case i.e when n=m=1
This will go out of the bounds of the matrix .
eg - suppose at some iteration, j=4 and m=4 so it will enter the while loop but the line a[i][j+1] will be a[i][5+1] which exceeds the size of array.
can anyone please tell me what is wrong with this please…?
https://www.codechef.com/viewsolution/35999059
@aditya04848 one of the most obvious case that failed n=1,m=1 and x<y answer should be x and not y
base case cost me o god this time i might have reached 4 star.
Hi.
Can someone plz tell me the test case where my code is giving the wrong ouput
heres my submission
https://www.codechef.com/viewsolution/35965722
I am assigning max values matrix can have and then I am summing all the elements of matrix
Hey can you please point the error in this code I literally have no clue PLZ help.
https://www.codechef.com/viewsolution/36025013
This gay solution will give wrong answer when matrix is a square matrix like 33 or 44 but he got AC. Can any one explain how?
https://www.codechef.com/viewsolution/35981280
i had everything cool while i was going for a dry run, but ended up getting a WA. Pls can someone help me with this code
Jako Rakhe Sayian maar sake na koi… cannot be justified better than this.
Thank you so much bro…
@iiy_yt_28 that is why people say that debugging your own code is some time a hell lot of task