Canadian Computing Competition: 2003 Stage 2, Day 1, Problem 3
Imagine a cube formed from solid interlocking pieces of various shapes.
If the pieces are sufficiently entwined, the only way to separate them
would be to cut some of them. We can ask the question: "is the cube
stable?" That is, is it physically impossible to separate the cube into
Your program must answer this question for a variety of such cubes.
The pieces that make up a cube will be specified as follows: divide the
cube into a grid of
Input Specification
Your program will be given the specification of up to 10 different
cubes. The first two lines of each specification will consist of the
size of that cube,
Output Specification
For each cube given, in the order specified, print Yes
if that cube is
stable, and No
if it is not.
Sample Input
2
AB
AB
BB
BA
3
AAA
BBB
AAA
AAA
ABA
AAA
ABA
ABA
ABA
0
Sample Output
No
Yes
Comments