UVa 414 machined Surfaces (Water ver.)

Source: Internet
Author: User
Tags extend

414-machined surfacestime limit:3.000 seconds

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

A imaging device furnishes digital images of two machined surfaces that eventually would be assembled in contacts with each Other. The roughness of this final contacts is estimated.

A Digital Image is composed to the two characters, "X" and "" (space). There are always columns to a image, but the number of rows, N, is variable. Column One (1) would always have an "X" in it and would be part of the left surface. The left surface can extend to the right from column one (1) as contiguous X' s.

Similarly, column would always have an "X" in it and is the right surface. The right surface can extend to the left from column as contiguous X' s.

Digital-image View of Surfaces

In each row of the image, there can is zero or more spaces characters separating the left surface to the right surface. There would never be more than a single blank region into any row.

For each image given, your are to determine the total ' void ' that would exist after the left surface has been brought into Contacts with the right surface. The ' void ' is the total count of the spaces this remains between the left and right surfaces after theyhave been brought into the contact.

The two surfaces are brought into contacts by displacing them strictly horizontally all towards each other until a rightmost "X" of the left surface of some row are immediately to the left of the leftmost ' x ' of the right surface of That row. There is no rotation or twisting of this two surfaces as they are into contacts; They remain rigid, and only move horizontally.

Note: The original image may show the two surfaces already in contacts, which case no displacement to the contact enters Ghness estimation.

Input

The input consists of a series of digital images. Each image data set has the following format:

A-
A single unsigned integer, N, with value greater than zero (0) and less than 13. The digit of Nwould be is the the the the the the the the "a line.
Next N Lines-
Each line
has exactly characters one or more X' s, then zero or more spaces, then one or more x' s.

The end of the data are signaled by a null data set has a zero on the the "the" of "the" of "and" further data.

Output

For each image you receive as a data set, you are are to reply with the total void (count of spaces remaining after the SURFAC Es are brought into contacts). Use the default output for a in a line.

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.