Tri-Hexagonal PuzzleProblem code: N4 |
All submissions for this problem are available.
Little Johnny wants to play with his friends today. But his babysitter won't let him go! After a lot of begging, the heartless nanny gives him her brand new electronic puzzle and says: "If you solve the puzzle then you are free to go". Not being aware of Little Johnny's IT skills, the nanny leaves the kid alone.
Rapidly, Little Johnny sends you an e-mail asking for your help.
The puzzle consists of three hexagons as shown in the figure. Each vertex is painted black or white. Some of them belong to just one hexagon and some of them belong to more than one. Exactly four of them are painted black, and the other nine are white. The goal is to make the shared vertexes black by means of allowed moves: rotating a hexagon 60 degrees clockwise or counter-clockwise.
Can you help Little Johnny?
Input
Input starts with an integer T, the number of puzzles to solve (1<=T<=100). T lines follow, each one having 13 binary digits, corresponding to the top-down, left to right labeling of the vertexes in the puzzle. A '0' means the i-th vertex is painted white, while a '1' means it is painted black.
Output
For each test case output M on a single line, the minimum number of moves required to solve the puzzle. Then print M lines, each one describing a move in the following manner: two space separated integers H and C, the rotated hexagon (upper left is 0, upper right is 1, lower one is 2) and the direction (0 for counter-clockwise, 1 for clockwise).
If there is more than one solution, any will suffice.
Example 1

Input:
1
0000000101011
Output:
3
2 0
2 0
1 1
| Date: | 2010-02-05 |
| Time limit: | 1s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK TEXT JS |
Comments

Fetching successful submissions

can anyone please tell me
@Anurag The vertex labelling
@Anurag The vertex labelling is "top-down, left to right". If you list the vertices in order, then all the vertices that are at the same height appear together. Vertices that are higher appear earlier. Among vertices at the same height, vertices that are more to the left appear earlier.
The figure, input and output given in the problem statement all refer to the same test case.
is it possibl that at some
is it possibl that at some intermediate stage, some of the points r overlapping so that < 4 pts r visibl?
Your question makes no sense.
Your question makes no sense. Read the problem statement again.
I havent been able to
I havent been able to understand the qn (apologies if this is very silly)...
suppose we take the case given in input
In the first step, suppose we perform the operation 1 0 i.e. rotate hex 1 counter clockwise. Then do we get 0000100101011? Or can we get both 0000100001011 and 0000100100011?
Thank you
@Vivek imagine the
@Vivek
imagine the "tri-hexagon" as a framework of 13 cups. and there are 4 balls placed in these cups.
when a particular hexagon needs to be "rotated" then the balls on the perimeter of the hexagon are shifted.
hope this helps.
is the test i/o alrite?
is the test i/o alrite?
Yes, the test I/O is alright.
Yes, the test I/O is alright.
I think the input should
I think the input should be 0000000101101.Does anyone else think so?
if moves should be minimum or
if moves should be minimum or any number of moves?
@ shreyas - the input is
@ shreyas - the input is correct.
@ Pankaj - read the problem statement.
@shreyas, @Stephen If the
@shreyas, @Stephen If the given labelling is “top-down, left to right”, then shreyas is using a labelling scheme that could be described as “left-right, top to bottom”. shreyas is looking at all the vertices in each column, then moving on to the next column; you should be looking at all the vertices in each row, then moving on to the next row.
What is memory usage limit??
What is memory usage limit??
@piyush Like I said at
@piyush Like I said at Traffic jam, “There is no fixed upper memory limit, but 64K is the lower limit for available memory.”
Little Johny may like to
Little Johny may like to solve this himself
#venkat.....hehe
#venkat.....hehe
can anybody explain the
can anybody explain the numbering of tst case with diagram ....
it is dificult to understand
it is dificult to understand because there are 15 vertex and 13 digit code..
1 2 3 4
1 2
3 4 5
6 7 8
9 10
11 12
13
The formatting got
Hi My code works perfectly on
Hi
My code works perfectly on my system, but here it is showing runtime error SIGSEV. What could be the reason? I used C++
i m new to coding can someone
i m new to coding can someone help me how to approach this problem!!
i hav understood the ques.
thanx
I need another test case that
I need another test case that doesn't involve 3 black vertices on the same hexagon,just the input and the output is enough
It is your job to come up
It is your job to come up with your own test cases.
finally ... i was almost
finally ... i was almost going to give up when i realized i was printing the result in wrong order :/
Check if my output format was
Check if my output format was right for each test case
line-1:Number of rotations
next lines:single space seperated H and C in each line in order giving the corresponding rotation
my code is working fine with
my code is working fine with some warnings in g++ 4.3 (fedora),but here its shows those warnings as error
any idea ?
You could try fixing them?
You could try fixing them?
What is the Judge computers
What is the Judge computers configuration?
I'm getting a TLE. On my comp, I can execute >100 test cases in under .5s.
#include<iostream> #inclu