← Back to topics
Topic

boxes 19/20

bour1992
I have tried many times to submit the boxes problem but always i take a wrong result in test case 3. Can you see my code to help me find any mistake?
My code is here: http://www.z-trening.com/new/www/html/submit.php?submit=7100012313&subm_code=1
nikola
hmm..... everything seems ok to me, but i'm not very good in C++ maybe i missed sthing... Lets see what others have to say..
boris4
max1=v1;
if (max1<s1)
max1=s1;
if (max1<v1)
max1=d1;

i isto

max2=v2;
if (max2<s2)
max2=s2;
if (max2<v2)
max2=d2;

bour1992
If you can describe my mistake in English, it may help me.
turgond
well the only thing in serbian he said was i isto = and the same
Al3kSaNdaR
You should write like this ->


max1 = v1;
if ( max1 < s1 )
max1 = s1;
if ( max1 < v1 )
max1 = d1;
max2 = v2;
if ( max2 < s2 )
max2 = s2;
if ( max2 < v2 )
max2 = d2;

bour1992
but i already have this piece in my code.
boris4
well, that is mistake...

Al3kSaNdaR told that to me, that i should use that method of writing codes.
( I think )

so your code should look like

max1 = d1;
if ( max1 < s1 )
max1 = s1;
if ( max1 < v1 )
max1 = v1;
Al3kSaNdaR
Use space in every segment of code! Not just in that I wrote. You shouldn't write like
blah=tmp-temp;
if (blah==0) { return 0 };
while (blah) { cnt+=25, blah -- };
, but you should write like this
blah = tmp - temp;
if ( blah == 0 ) { return 0 };
while ( blah ) { cnt += 25, blah-- };


Maybe your idea isn't good, and you get WA on 1 case, or it's because of the spaces. If you put spaces and you get WA again try some alternative method to solve this task.

@boris4:

What did I tell you ? We met on SIO and republic competition but I can't remember what I told you. I remember that we were at lobby and I was programming light show , and you were testing some robot. :)
tgudlek
LOL :D

Spaces don't affect the output :D
boris4
what ?

@Al3kSaNdaR: spaces aren't going to do anything ( like newlines )...


int tmp=a;
a=b;
b=tmp;


will do same thing as


int tmp = a;
a = b;
b = tmp;
Al3kSaNdaR
=S I don't know very good C++, but when I code in C++ I use spaces. :-D

@bour1992:

Try different idea. ;)
boris4
@bour1992:

I think your idea is good, and you should't change it...

Just change you code, there is a little mistake.
( i showed you mistake in some of previous posts )
bour1992
LOL. Too many opinions.
Finally I heared boris and i change it to

max1 = d1;
if ( max1 < s1 )
max1 = s1;
if ( max1 < v1 )
max1 = v1;

and i pass all the tests.
Thank you boris!
Al3kSaNdaR
One hint, You don't need to check if input numbers are in given interval, they will always be.

So you don't have to write:



if ((d1<1000) && (d2<1000) && (s1<1000) && (s2<1000) && (v1<1000) && (v2<1000))
{
.
.
.
}

bour1992
Thank you Al3kSaNdar for your hint
boris4
you are welcome :)

is this good phrase ?