Problem
Automatic Chemical Manufacturing is experimenting with a process called self-assembly. In this process, molecules with natural asonity for each other are mixed together in a solution and allowed to spon-taneously assemble themselves into larger structures. But there is one problem: sometimes molecules assemble themselves into a structure of unbounded size, which gums up the machinery.
You must write a program to decide whether a given collection of molecules can be assembled into a structure of unbounded size. You should make two simplifying assumptions: 1) the problem is restricted to two dimensions, and 2) each molecule in the collection is represented as a square. The four edges of the square represent the surfaces on which the molecule can connect to other compatible molecules.
In each test case, you will be given a set of molecule descriptions. Each type of molecule is described by four two-character connector labels that indicate how its edges can connect to the edges of other molecules. There are two types of connector labels:
- An uppercase letter ( A, …, Z ) followed by
+
or.
Two edges are compatible if their labels have the same letter but different signs. For example,A+
is compatible withA
but is not compatible withA+
orB
. - Two zero digits
00
. An edge with this label is not compatible with any edge (not even with
another edge labeled00
).
Assume there is an unlimited supply of molecules of each type, which may be rotated and reected.
As the molecules assemble themselves into larger structures, the edges of two molecules may be adjacent to each other only if they are compatible. It is permitted for an edge, regardless of its connector label, to be connected to nothing (no adjacent molecule on that edge). Figure A.1 shows an example of three molecule types and a structure of bounded size that can be assembled from them (other bounded structures are also possible with this set of molecules).
Input
The input consists of several test cases. A test case consists of two lines. The rst contains an integer n (1 < n < 40000) indicating the number of molecule types. The second line contains n eight-character strings, each describing a single type of molecule, separated by single spaces. Each string consists of four two-character connector labels representing the four edges of the molecule in clockwise order.
Output
For each test case, display the word unbounded
if the set of molecule types can generate a structure of unbounded size. Otherwise, display the word bounded
.
Sample Input
|
|
Sample Output
|
|
Solution
題目描述:
分定數種分子,每一種分子有無限多個,問會不會產生無邊界的化合物,也就是可以一直串一直串下去。
題目解法:
鏡射和旋轉不用去理會,對於建圖並沒有影響,而題目圖片中看起來是平面,但是事實上可以螺旋疊起。
如上圖片所示,使用這種建照方式去找環,只要有環的情況就會有無邊界的化合物。
不考慮找到每一個化合物間的關係,這關係過於龐大,只考慮接口連接的關係。
|
|