Zzuli_team_practice (1) POJ 1099...__ Summer Camp Training

Source: Internet
Author: User
Square Ice P time limit:1000ms Memory limit:10000kb 64bit IO Format:%i64d &%i64u
[Submit]   [Go back] [Status]
Description
Square Ice is a two-dimensional arrangement of water molecules H2O, with oxygen in the vertices of a square lattice and on E hydrogen atom between each pair of adjacent oxygen atoms. The hydrogen atoms must stick out in the left and right sides but, not are, to allowed out of the top or stick. One 5 x 5 example is shown below.


Note this is the each hydrogen atom are attached to exactly one of their neighboring oxygen atoms and each oxygen atom is attached t O Two of its neighboring hydrogen atoms. (Recall that one water molecule are a unit of one O linked to two H ' s.)
It turns out we can encode a square, ice pattern, and what is known as a alternating sign matrix (ASM): Horizontal Molecul ES are encoded as 1 vertical molecules are encoded as-1 and all other molecules are as 0. So, the above pattern would is encoded as:


An ASM are a square matrix with entries 0, 1 and-1, where the sum of each row and column are 1 and the Non-zero entries in Each row and in each column must alternate in sign. (It turns out there is a one-to-one correspondence between ASM ' s and square ice patterns!)
Your job is to display the square ice pattern, in the same format as the example above, for a given ASM. Use dashes (-) to horizontal attachments and vertical bars (|) for vertical attachments. The pattern should is surrounded with a border of asterisks (*), is left justified and there should is exactly one charact Er between neighboring hydrogen atoms (H) and oxygen atoms (O): Either a space, a dash or a vertical bar.

Input
Input consists of multiple cases. Each case consists of a positive integer m (<= one) on a line followed by m lines giving the entries of a ASM. Each line gives a row of the "ASM with entries separated by a". The end of the input was indicated by a line containing M = 0. Output
For each case, print the case number (starting from 1), in the format shown in the Sample Output, followed by a blank line , followed by the corresponding square ice pattern in the format described above. Separate the output of different cases by a blank line. Sample Input
2 0 1 1 0 4 0 1 0 0 1-1 0 1 0 0 1 0 0 1 0 0Sample Output
Case 1:
*h-o h-o-h* * |  * * * H * * * | * *h-o-h o-h* ***********
Case 2:
*h-o h-o-h o-h o-h* * |   |  |          * * H H H * * * |   * *h-o-h O h-o h-o-h* * |      |           * * H H H * * * |  |          * *h-o h-o h-o-h o-h* * |       * * H H H * * * |   |  | * *h-o h-o-h o-h o-h* ******************* Well depressed simulation problem, finish submitting a look at the time 18:01:35 with an array to write down this position, first of 1 and 1 of the case to write down, this good to get, 0 of the situation at the end to see whether the surrounding H has been linked, not connected, attention order, from left to right, from top to bottom code: C Language: Temporary personal code #include <stdio.h>
Char str [100] [100];
int range (int i, int j)
{
if (str [i-1] [j] = = ' | ' | |-str [i + 1] [j] = = ' | ' | | str [i] [j-1] = '-' | | str [i] [j + 1] = '-')
return 0;
return 1;
}
int main ()
{
int map [[], A, b;
int I, j, N, flag = 0;
while (scanf ("%d", &n), N)
{
for (i = 0; i < i + +)
for (j = 0; J < J + +)
STR [i] [j] = ';
for (i = 1; I <=n; i + +)
for (j = 1; J <=n; J + +)
scanf ("%d", & map [i] [j]);
for (i = 0; I <=n; i + +)
map [i] [0] = map [i][n + 1] =-1;
for (j = 0; J <=n; J + +)
Map [0] [j] = map [n + 1] [j] = 1;
for (i = 0; I <n; i = i + 1)
for (j = 0; J <n; J + +)
{
A = i * 4 + 1;
B = J * 4 + 3;
STR [a][b] = ' O ';
i + +; j + +;

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.