Page 1 of 1
10024 - Curling up the cube
Posted: Thu Aug 15, 2002 6:08 pm
by henar2
Hi, I can't find why this code doesn't go on.
Please check it.
[c]
#include<stdio.h>
int sum_col(int map[6][6],int col);
int sum_row(int map[6][6],int row);
void rotate(int map[6][6]);
main()
{
int map[6][6];
int i,j,row,col,cases,k,temp;
scanf("%d",&cases);
for(i=0;i<cases;i++)
{
for(j=0;j<6;j++)
{
for(k=0;k<6;k++)
scanf("%d",&map[j][k]);
}
row=-1;
for(k=0;k<3;k++)
{
for(j=0;j<6;j++)
{
temp=sum_row(map,j);
if(temp==4)
{
row=j;
break;
}
}
if(row==-1)
rotate(map);
else
break;
}
if(row==-1)
{
printf("incorrect\n");
goto finished;
}
col=-1;
for(j=0;j<6;j++)
{
temp=sum_col(map,j);
if(temp==3)
{
col=j;
break;
}
}
if(col==-1)
{
printf("incorrect\n");
goto finished;
}
if(row-1>=0 && row+1<6 && col-1>=0 && col+1<6 && col+2<6)
{
if(map[row][col]==1 && map[row][col-1]==1
&& map[row][col+1]==1 && map[row][col+2]==1
&& map[row-1][col]==1 && map[row+1][col]==1)
{
printf("correct\n");
goto finished;
}
}
if(row-1>=0 && row+1<6 && col-1>=0 && col-2>=0 && col+1<6)
{
if(map[row][col]==1 && map[row][col-1]==1
&& map[row][col+1]==1 && map[row][col-2]==1
&& map[row-1][col]==1 && map[row+1][col]==1)
{
printf("correct\n");
goto finished;
}
}
printf("incorrect\n");
finished:
if(i!=cases-1)
printf("\n");
}
}
int sum_row(int map[6][6],int row)
{
int i,sum;
sum=0;
for(i=0;i<6;i++)
sum+=map[row]
;
return(sum);
}
int sum_col(int map[6][6],int col)
{
int i,sum;
sum=0;
for(i=0;i<6;i++)
sum+=map[col];
return(sum);
}
void rotate(int map[6][6])
{
char map2[6][6];
int i,j;
for(i=0;i<6;i++)
for(j=0;j<6;j++)
map2[j]=map[j];
for(i=0;i<6;i++)
for(j=0;j<6;j++)
map[j][5-i]=map2[j];
return;
}
[/c]
Posted: Sun Sep 01, 2002 10:01 am
by wyvmak
mind to briefly explain your algorithm in words? i'm not used to understand other's code (neither my own code

)
but i guess what you miss maybe this case
XX
.XX
..XX
this can be curled up into a cube. (right?)
Posted: Sun Sep 01, 2002 4:04 pm
by henar2
What i do in my messy code is:
1--> Look for a row that sum 4. If not, then rotate and look for again. If after 3 rotations there isn't a row with sum=4 then: incorrect.
2--> Look for a column that sum 3 in the last rotate image. If it doesn't exist then: incorrect.
3--> In this point I have the row and the column where the figure intersect, then I check if the figure:
00X0
XXXX
00X0
or
0X00
XXXX
0X00
(where X=1)
is in the image because i have the intersect point.
and that's all, i think it must go on but i am getting wrong answer.
And, about your comment, I think that your case can't be curled up into a cube, at least, as i have understood the problem statement.

Posted: Sun Sep 01, 2002 5:21 pm
by wyvmak
it can, please trust me.
OOXO
XXXX
XOOO
also can, do you think so?
Posted: Sun Sep 01, 2002 8:13 pm
by henar2
Sorry, you are correct.
I understood that I should find a shape like:
00X0
XXXX
00X0
And that is not true. So, I'll rewrite my code.
Thanks a lot.

10024
Posted: Wed Nov 20, 2002 3:24 am
by yan4546
I have tried lots of inputs and I found no mistakes.
but I always get the WA;
I don't know why.
Can you help me?
Following are some of my inputs and outputs:
--------------------------------------------------------
Group 1:
intput:
0 0 0 0 0 0
0 0 1 1 0 1
0 0 0 1 1 1
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
output:
incorrect
Group 2:
input:
0 0 0 0 0 0
0 0 0 1 1 0
0 0 1 1 0 0
0 1 1 0 0 0
0 0 0 0 0 0
output:
correct

:win
Can you send some of your datas to me?
Thank you!

Posted: Wed Dec 25, 2002 1:26 pm
by Astrakan
The output for your test cases is correct. However, did you notice that this is a multiple input-problem (blue check mark)? Your program should accept input like this:
Code: Select all
2
0 0 0 0 0 0
0 0 1 1 0 1
0 0 0 1 1 1
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 1 1 0
0 0 1 1 0 0
0 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
and produce output like this:
incorrect
correct
(see
http://acm.uva.es/problemset/minput.html)
One more question...
Posted: Fri Apr 02, 2004 8:23 pm
by alex[LSD]
Code: Select all
......
.***..
......
....*.
....*.
....*.
is SUCH a case possible in this problem?
10024 NEED TEST DATA
Posted: Mon Oct 04, 2004 7:35 am
by MUBBASHER
10024
Posted: Thu Oct 07, 2004 10:23 am
by MUBBASHER

I m getting problem in solving 10024 "Curling up he cube"
perhaps i m not getting the correct way to solve th problem.
Here are steps througjh which i tried to solve my problem.

First i have made a class of 'FACE' with four
pointers "left,Right,Top ,Bottom".

Than i have linked these faces a made a Standered Cube.

Then i have linked face of inputed 'ones'. in another face link list.

then recursivly checked it's validation with the standrad cube.

I have checked my code for almost all problems. It gives answer
correct.

BUT ACM Judge Says Wrong answer

WHY
Easier than you think...
Posted: Wed Sep 07, 2005 8:42 pm
by guayoyo
Hi MUBBASHER. I'm new to this board, and I can see your post have no replies, so I would explain you all my failed solutions...
First, I tried the way you have posted (in 3 different ways) and all were WAs... that it because when you curl the cube to one side, maybe the top of a face changes, and that is difficult to catch...
The other way i tried, was to create the 12 answers in the program and search the pattern (moved, rotated, etc...), and WA...
Until I solved problem 10409 - Die Game, which consist of rotate a six-faced dice and answer the face that was on the top... the solution for this problem was not to use pointers to mark adjacent faces, was to write four routines, moveNorth(), moveSouth(), moveWest() and moveEast() to rotate the dice in that direction (i.e.: moveNorth() makes the top face now is the north face, the north face is the bottom face, the bottom face is the south face and the south face is the top face).
What makes the solution easier is the fact that when you move the dice, you rotate the contents of the faces of the dice, so the top is always the top, and so on.
Once you solve this problem, you can use the code to rotate the dice to rotate the cube over the paper, and if after rotating the cube the six faces have been on the bottom with a 1 on the paper, then is "correct", else if "incorrect",...
Maybe this can help you and everyone who read this post...
(I came to this solution 8 months after my first WA solution)...
Posted: Fri Apr 07, 2006 11:04 pm
by Darko
I liked your idea, guayoyo, so I implemented my solution that way.
Here's some I/O (weird, will comment bellow):
Code: Select all
7
0 0 0 0 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 1 1 1 0
0 0 0 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 1 1 0
0 0 1 1 0 0
0 0 0 1 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 0 1 0 0
0 0 1 1 0 0
0 0 0 1 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 0 1 0 0 0
0 0 1 0 1 0
0 0 0 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 0 1 0 0 0
0 0 1 1 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 1 0 0
0 0 1 1 0 0
0 0 1 1 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Code: Select all
correct
incorrect
incorrect
correct
incorrect
incorrect
correct
Note that the last case is not a cube, but my AC program reports it as such. I submitted it to check it for time (thought I did some silly stuff) and it got accepted. Unless I misunderstood the problem, which makes it even worse, heh.
Darko
answer!!!
Posted: Fri Jul 27, 2007 5:26 pm
by adelar
Hi,
this input is possible?
Code: Select all
......
.***..
......
....*.
....*.
....*.
thanks in advance.
Re: answer!!!
Posted: Sat Jul 28, 2007 12:04 am
by tgoulart
adelar wrote:Hi,
this input is possible?
Code: Select all
......
.***..
......
....*.
....*.
....*.
thanks in advance.
No gaps allowed.