10024 - Curling up the cube

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
henar2
New poster
Posts: 30
Joined: Mon Nov 26, 2001 2:00 am
Location: Valladolid (Spain)

10024 - Curling up the cube

Post by henar2 » Thu Aug 15, 2002 6:08 pm

Hi, I can't find why this code doesn't go on. :o
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]

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

Post by wyvmak » Sun Sep 01, 2002 10:01 am

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?)

henar2
New poster
Posts: 30
Joined: Mon Nov 26, 2001 2:00 am
Location: Valladolid (Spain)

Post by henar2 » Sun Sep 01, 2002 4:04 pm

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.
:o

wyvmak
Experienced poster
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

Post by wyvmak » Sun Sep 01, 2002 5:21 pm

it can, please trust me. :-?

OOXO
XXXX
XOOO

also can, do you think so?

henar2
New poster
Posts: 30
Joined: Mon Nov 26, 2001 2:00 am
Location: Valladolid (Spain)

Post by henar2 » Sun Sep 01, 2002 8:13 pm

Sorry, you are correct. :oops:
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. :lol:

yan4546
New poster
Posts: 7
Joined: Fri Nov 15, 2002 4:17 am
Contact:

10024

Post by yan4546 » Wed Nov 20, 2002 3:24 am

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

:roll: :roll: :roll: :roll: :roll: :roll: :roll: :roll: :roll:
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

:roll: :roll: :roll: :roll: :roll: :roll: :roll: :roll: :roll: :win

Can you send some of your datas to me?


Thank you!
8) 8) 8) 8) 8) 8)
aaaaaaaaaaaaaaaaaaaaa

Astrakan
New poster
Posts: 24
Joined: Sun Nov 03, 2002 12:18 pm
Location: Sweden

Post by Astrakan » Wed Dec 25, 2002 1:26 pm

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)

alex[LSD]
Learning poster
Posts: 53
Joined: Sat Jan 24, 2004 9:22 pm
Location: Tomsk, Siberia, RUSSIA
Contact:

One more question...

Post by alex[LSD] » Fri Apr 02, 2004 8:23 pm

Code: Select all

......
.***..
......
....*.
....*.
....*.

is SUCH a case possible in this problem?
The more contests are held, the happier I am.

MUBBASHER
New poster
Posts: 10
Joined: Mon Oct 04, 2004 5:23 am

10024 NEED TEST DATA

Post by MUBBASHER » Mon Oct 04, 2004 7:35 am

I a m getting wrong answer from acm-site.
:x
if some body know about getting sample inputs and ouputs from acm site for problem 10024. or from some othwer resourse please tell it to me.
:oops:
Or if somebody already solved the problem please post me the smples produced by his program. i have already posted my code in last Topic please test it also. :o
:evil: :evil:

:wink:
THANKS IN ADVANCE.
:wink:

MUBBASHER
New poster
Posts: 10
Joined: Mon Oct 04, 2004 5:23 am

10024

Post by MUBBASHER » Thu Oct 07, 2004 10:23 am

:o 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.

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

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

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

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

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

:evil: BUT ACM Judge Says Wrong answer :evil:
:x WHY

guayoyo
New poster
Posts: 11
Joined: Wed Aug 17, 2005 5:59 pm
Location: Caracas, Venezuela

Easier than you think...

Post by guayoyo » Wed Sep 07, 2005 8:42 pm

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)...
10024 - Guayoyo has Curled Up the Cube!

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Fri Apr 07, 2006 11:04 pm

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

adelar
New poster
Posts: 35
Joined: Wed May 02, 2007 11:48 pm
Location: Brasil

answer!!!

Post by adelar » Fri Jul 27, 2007 5:26 pm

Hi,
this input is possible?

Code: Select all

......
.***..
......
....*.
....*.
....*. 
thanks in advance.

tgoulart
New poster
Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Re: answer!!!

Post by tgoulart » Sat Jul 28, 2007 12:04 am

adelar wrote:Hi,
this input is possible?

Code: Select all

......
.***..
......
....*.
....*.
....*. 
thanks in advance.
No gaps allowed.
Thiago Sonego Goulart - UFMG/Brazil

Post Reply

Return to “Volume 100 (10000-10099)”