← Back to topics
Topic

z-95 round #4

D
Dumbe93
When competition will be judge ?...
a
adminModerator
In the next 24 hrs.
a
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 :(
f
frost_nova
hm, very strange. Is it possible to see one test and right answer for it?
p
picsel
Can somebody give some test cases that don't work for those who got 20 points on z-rectangle?
A
AhmedKamel
if you have a rectangle 6X5. tell me what is your optimal answer. So, i can give you the right one.
p
picsel
Ok, thanks, I just found the problem :D
E
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
R
Ravent
because you solution is wrong
for example 5 6
your answer - 6
right answer - 5
A
AhmedKamel
_ _ _ _ _
| | |
|_ _| |
| |_ _ _|
|_ _| |
| | |
|_ _|_ _ _|
A
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;
}
f
frost_nova
try change your recursion dp to tabular dp
A
AhmedKamel
Oh, it really differs, Thank you :)
f
frost_nova
complexity of two solutions are equal, but in recursion you need to call function which more slowly then simple access to array
E
Ewok95
@Ravent
@AhmedKamel

Thanks
A
AhmedKamel
In spaghetti:

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

a
adminModerator
There is no such a case. But if there was, you would cut it in half
a
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 :)
p
picsel
Grader for that task in training section is OK now?
a
adminModerator
yes, it is okay now
m
mister
Are you sure grader is working properly for z-spaghetti in training section? I'm getting a 0/10 for it...