UVA oj 414 Machined Surfaces(水题)

原创 2016年06月01日 21:35:13
Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu

 Status

Description

Download as PDF

An imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is to be estimated.

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

Similarly, column 25 will always have an "X" in it and will be part of the right surface. The right surface can extend to the left from column 25 as contiguous X's.

Digital-Image View of Surfaces

 Left     		                           Right 

XXXX XXXXXtex2html_wrap_inline50

XXX XXXXXXX

XXXXX XXXX

XX XXXXXX

. .

. .

. .

XXXX XXXX

XXX XXXXXXtex2html_wrap_inline52

tex2html_wrap_inline54tex2html_wrap_inline56

1 25

In each row of the image, there can be zero or more space characters separating the left surface from the right surface. There will never be more than a single blank region in any row.

For each image given, you are to determine the total ``void" that will exist after the left surface has been brought into contact with the right surface. The ``void" is the total count of the spaces that remains between the left and right surfaces after theyhave been brought into contact.

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

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

Input

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

First line -
A single unsigned integer, N, with value greater than zero (0) and less than 13. The first digit of N will be the first character on a line.

Next N lines -
Each line has exactly 25 characters; one or more X's, then zero or more spaces, then one or more X's.

The end of data is signaled by a null data set having a zero on the first line of an image data set and no further data.

Output

For each image you receive as a data set, you are to reply with the total void (count of spaces remaining after the surfaces are brought into contact). Use the default output for a single integer on a line.

Sample Input (character "B" for ease of reading. The actual input file will use the ASCII-space character, not "B").

4
XXXXBBBBBBBBBBBBBBBBXXXXX
XXXBBBBBBBBBBBBBBBXXXXXXX
XXXXXBBBBBBBBBBBBBBBBXXXX
XXBBBBBBBBBBBBBBBBBXXXXXX
2
XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXBBBBBBBBBBBBBBXX
0

Sample Output

4
0
0
问两边X咬合之后留下多少个空格,也就是多少个B,样例中为了看得清楚用B代替了空格
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;
const int maxn = 1005;
char a[maxn];
int b[maxn];
int n;

int main()
{
    while(~scanf("%d",&n) && n)
    {
        getchar();
        int ans = 0;
        int cnt = 0;
        int i,j;
        int max = -1;
        memset(b,0,sizeof(b));
        for(int i=0;i<n;i++)
        {
            gets(a);
            cnt++;
            for(j=0;j<25;j++)
            {
                if(a[j] == 'X')
                    b[i]++;
            }
        }
        for(int i=0;i<n;i++)
        {
            if(max < b[i])
                max = b[i];
        }
        for(int i=0;i<n;i++)
        {
            ans += (max - b[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

UVa 414 Machined Surfaces(机器加工的表面)

Machined Surfaces  An imaging device furnishes digital images of two machined surfaces that ev...
  • mullerwch
  • mullerwch
  • 2013年08月01日 21:19
  • 729

UVA oj 练习水题 算法入门经典(大数系列)

最近做了很多白皮书(算法入门经典)上面的很多水题,但是考验编程的细心还是很考验的,把一些题记录在这儿 424 - Integer Inquiry  代码改的很烂,很不容易的过了: #include ...
  • y990041769
  • y990041769
  • 2013年07月07日 13:18
  • 3574

UVa253骰子涂色

一开始太蠢,犯迷糊了,以为先确定一个轴再考虑其他的旋转,后来想想,其实只要骰子的3个对面都相同,绕一个轴转肯定可以转回来。 在实现自己的想法的时候,wa了两次,就觉得自己的想法是错的,搜了一下其他人...
  • Nick_le
  • Nick_le
  • 2016年09月13日 23:59
  • 536

UVa OJ全部题目列表(按难度分级,仅标题)

# ID Title Solved by Difficulty 1 100 The 3n + 1 problem 26485 1 ...
  • gwq5210
  • gwq5210
  • 2014年10月10日 13:08
  • 5552

题目推荐—BZOJ 水题推荐

[bzoj1756]Vijos1083小白逛公园 裸题- -。。线段树维护lmax,rmax,max,sum然后搞之。。 [Ahoi2008]Meet 紧急集合 求两两点的lca然后会发现必然有两个l...
  • u011400953
  • u011400953
  • 2013年07月16日 15:26
  • 3146

uva10986(最短路径)

题目的意思就是
  • yeyeyeguoguo
  • yeyeyeguoguo
  • 2014年11月07日 20:22
  • 408

UVA Ants(水题)

Description Problem B: Ants An army of ants walk on a horizontal pole of length l cm, each...
  • yeguxin
  • yeguxin
  • 2015年02月02日 16:30
  • 441

一个简单的单线程OJ判题端(java实现)

前言最近准备用java做一个OJ的判题端,现在的想法还是不太成熟,实现的也十分简单,贴出来希望能和大家一同交流~ 实现的大体思路首先,前台的用户将代码提交后,假设将代码保存在服务器中。 那么,判题端应...
  • leeezm
  • leeezm
  • 2017年07月18日 20:00
  • 358

扩展欧几里得算法(不爽的裁判,uva 12169)

http://blog.csdn.net/a197p/article/details/45418367 一般这种数论的题,要注意中间变量或不会爆int。最好就全部都用long lon...
  • xl2015190026
  • xl2015190026
  • 2016年09月27日 01:11
  • 177

杭电ACM——自我强化步骤

实验室的师兄编程都很牛逼,我这个小菜鸟私下跟他们讨教了怎样变成牛逼的绝招,“练练练,写写写”这是他们给我的回答。尽管平时他们做项目很忙,但总是会抽出时间刷刷ACM。现在也感觉自己反应速度和算法能力有些...
  • Always2015
  • Always2015
  • 2015年04月09日 21:35
  • 6116
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:UVA oj 414 Machined Surfaces(水题)
举报原因:
原因补充:

(最多只允许输入30个字)