UVa 457 Linear cellular automata (Water ver.)

Source: Internet
Author: User
Tags time limit

457-linear Cellular automata

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem &problem=398

A biologist is experimenting with DNA modification of bacterial colonies being grown in a linear array of culture. By changing the DNA, the It Able ' program ' the bacteria to respond to the population density of the neighboring. Population is measured on a four point scale (from 0 to 3). The DNA information is represented as a array of DNA, indexed from 0 to 9, of population density values and are inte Rpreted as follows:

In no given culture dish, let K is the sum of that culture dish ' s density and densities of the dish Ely to the left and the dish immediately. Then, by "next day", that dish would have a population density of dna[k].

The dish at the far left of the the ' line are considered to have a left neighbor with population density 0.

The dish at the ' far right ' is considered to have a right neighbor with population 0.

Now, clearly, some DNA programs cause all bacteria to die off (e.g., [0,0,0,0,0,0,0,0,0,0]). Others result in immediate population explosions (e.g., [3,3,3,3,3,3,3,3,3,3]). The biologist is interested in how some of the less obvious intermediate DNA programs might.

Write a program to simulate the culture growth in a line of dishes, assuming this dish starts with a population dens ity of 1 and all other dishes-start with a population density of 0.

Input

The input begins with a single positive integer in a line by itself indicating the number of cases following, each of them as described below. This are followed by a blank line, and there are also a blank line between two consecutive.

For each of the input set your program would read in the DNA program (integer values) on one line.

Output

For each test case, the output must follow the description below. The outputs of two consecutive cases is separated by a blank line.

For each input set it should print the densities of the "dishes for each of the" next days. Each day ' s printout should occupy one line of characters. Each dish was represented by the a single character on this line. Zero population densities are to be printed as the character '. Population density 1 would be printed as the character '. Population density 2 would be printed as the character 'x'. Population density 3 would be printed as the character 'W'.

Sample Input

1

0 1 2 0 1 3 3 2 3 0

Sample Output

BBBBBBBBBBBBBBBBBBB.BBBBBBBBBBBBBBBBBBBB
bbbbbbbbbbbbbbbbbb...bbbbbbbbbbbbbbbbbbb
BBBBBBBBBBBBBBBBB.XBX.BBBBBBBBBBBBBBBBBB
bbbbbbbbbbbbbbbb.bb.bb.bbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbb ... bbbbbbbbbbbbbbbb bbbbbbbbbbbbbb.xbbbbbbbx.bbbbbbbbbbbbbbb.
BBBBBBBBBBBBB.BBXBBBBBXBB.BBBBBBBBBBBBBB
bbbbbbbbbbbb...xxxbbbxxx...bbbbbbbbbbbbb
BBBBBBBBBBB.XB.WW.XBX.WW.BX.BBBBBBBBBBBB
BBBBBBBBBB.BBB.XXWB.BWXX.BBB.BBBBBBBBBBB

Note: Whe show only the ' ten lines of output (the total number of lines must is) and the spaces have been with The character "B" for ease of reading. The actual output file would use the Ascii-space character and not "B".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.