← Back to topics
Topic

z-95 round #4

Dumbe93
When competition will be judge ?...
adminModerator
In the next 24 hrs.
Dumbe93
tanks..=)...
adminModerator
The results are up.

It took me some time to check if the tests for the 3rd problems were okay. And they ARE okay. Even though everyone got 0 :(
frost_nova
hm, very strange. Is it possible to see one test and right answer for it?
picsel
Can somebody give some test cases that don't work for those who got 20 points on z-rectangle?
AhmedKamel
if you have a rectangle 6X5. tell me what is your optimal answer. So, i can give you the right one.
picsel
Ok, thanks, I just found the problem :D
Ewok95
can someone tell me whats the problem with my code, I can't see the mistake


#include <stdio.h>

int x,y,br=0;

int main()
{
scanf("%d %d",&x,&y);
while(x>0 && y>0)
{
if(x>y)x-=y;
else if(x<y)y-=x;
else
{
br++;
break;
}
br++;
}
printf("%d",br);
getchar();
getchar();
return 0;
}


as soon as possible
Ravent
because you solution is wrong
for example 5 6
your answer - 6
right answer - 5
AhmedKamel
_ _ _ _ _
| | |
|_ _| |
| |_ _ _|
|_ _| |
| | |
|_ _|_ _ _|
AhmedKamel
lol, is it clear :D ?
AhmedKamel
May anyone who got 100 in rectangles tell me how can i optimize to to get 100 ?
i am getting 70 coz of 3 TLE.

that is my dp function:


int solve(int r,int c)
{
if(r==c)return best[r][c]=1;
int ret=1<<30,i;
if(best[r][c]!=-1)return best[r][c];
for(i=1;i<=r/2;i++)
ret=min(ret,solve(i,c)+solve(r-i,c));
for(i=1;i<=c/2;i++)
ret=min(ret,solve(r,i)+solve(r,c-i));
return best[r][c]=ret;
}
frost_nova
try change your recursion dp to tabular dp
AhmedKamel
does it differ in time ?
AhmedKamel
Oh, it really differs, Thank you :)
frost_nova
complexity of two solutions are equal, but in recursion you need to call function which more slowly then simple access to array
Ewok95
@Ravent
@AhmedKamel

Thanks
AhmedKamel
In spaghetti:

If the line segment (spaghetti) is on the cutting line(collinear). how will it be cut ?

adminModerator
There is no such a case. But if there was, you would cut it in half
AhmedKamel
Oh, i see. Thanks alot.
adminModerator
Damn, the tests WERE ALL okay, but the grader program was NOT.

I've fixed it and the competition is being regraded. Sorry for that guys, it took me a while to find the bug :)
picsel
Grader for that task in training section is OK now?
adminModerator
yes, it is okay now
mister
Are you sure grader is working properly for z-spaghetti in training section? I'm getting a 0/10 for it...