The Game

题意:

Description

One morning, you wake up and think: “I am such a good programmer. Why not make some money?” So you decide to write a computer game.

一天清晨,你起床后想到:“我是一个这么牛的程序员,为什么不赚点钱呢?”所以,你决定写一个电脑游戏。

The game takes place on a rectangular board consisting of w * h squares. Each square might or might not contain a game piece, as shown in the picture.

这个游戏是在一个长方形板上的,这个板由w*h个小正方形组成。每一个小正方形可能会包括一个游戏的块,如下图所示。

One important aspect of the game is whether two game pieces can be connected by a path which satisfies the two following properties:

这个游戏的一个最重要的方面是判断两个块会不会由符合下列要求的路径连接。

It consists of straight segments, each one being either horizontal or vertical.

1.路径是由直的部分组成,每个部分或水平或垂直。

It does not cross any other game pieces.

2.路径不能跨过其它的游戏方块。

(It is allowed that the path leaves the board temporarily.)

(路径可以暂时离开板)

Here is an example:

下面 举个例子。

The game pieces at (1,3) and at (4, 4) can be connected. The game pieces at (2, 3) and (3, 4) cannot be connected; each path would cross at least one other game piece.

(1,3)和(2,4)可以被连接。(2,3)和(3,4)不能被连接。

The part of the game you have to write now is the one testing whether two game pieces can be connected according to the rules above.

游戏的一部分 是你必须写一个程序证明两个木块是否能够被连接起来。

这里写图片描述

Input

输入

The input contains descriptions of several different game situations. The first line of each description contains two integers w and h (1 <= w,h <= 75), the width and the height of the board. The next h lines describe the contents of the board; each of these lines contains exactly w characters: a “X” if there is a game piece at this location, and a space if there is no game piece.

输入是多种情况的,第一行包括两个整数w和h(q<=w,h<=75),即板的宽度和长度,下h行表示板上都有什么。每行包括w个字符,’X’表示有一个游戏方块,空格表示没有游戏方块。

Each description is followed by several lines containing four integers x1, y1, x2, y2 each satisfying 1 <= x1,x2 <= w, 1 <= y1,y2 <= h. These are the coordinates of two game pieces. (The upper left corner has the coordinates (1, 1).) These two game pieces will always be different. The list of pairs of game pieces for a board will be terminated by a line containing “0 0 0 0”.

每种情况后包括几行询问,每行包括4个整数X1,Y1,X2,Y2(1<=X1,X2<=w;I<=Y1,Y2<=h)。这是2个游戏片段的坐标。(左上角为坐标(1,1)。) 这两个坐标将永远是不同的。“0 0 0 0”表示输入结束。

The entire input is terminated by a test case starting with w=h=0. This test case should not be procesed.

整个输入结束 是输入了(0,0) 这个case不用考虑。

Output

输出

For each board, output the line “Board #n:”, where n is the number of the board. Then, output one line for each pair of game pieces associated with the board description. Each of these lines has to start with “Pair m: “, where m is the number of the pair (starting the count with 1 for each board). Follow this by “ksegments.”, where k is the minimum number of segments for a path connecting the two game pieces, or “impossible.”, if it is not possible to connect the two game pieces as described above.

每个板,输出一行“Board #n:”,n是第n块板。然后输出一行为每对坐标是否相关联。如果关联,输出“Pair m: k segments.”m为这块板的第m次询问,k为路径包括几个部分。否则输出“Pair m: impossible.”

Output a blank line after each board.

每个板询问完后输出个空行。

Sample Input样例输入

5 4

XXXXX

X X

XXX X

XXX

2 3 5 3

1 3 4 4

2 3 3 4

0 0 0 0

0 0

Sample Output样例输出

Board #1:

Pair 1: 4 segments.

Pair 2: 3 segments.

Pair 3: impossible.

POJ 1101 译文的更多相关文章

  1. OpenJudge 2802 小游戏 / Poj 1101 The Game

    1.链接地址: http://bailian.openjudge.cn/practice/2802 http://poj.org/problem?id=1101 2.题目: 总时间限制: 1000ms ...

  2. 搜索 + 剪枝 --- POJ 1101 : Sticks

    Sticks Problem's Link:   http://poj.org/problem?id=1011 Mean: http://poj.org/problem?id=1011&lan ...

  3. POJ 1101 简单BFS+题意

    The Game 题意: Description One morning, you wake up and think: "I am such a good programmer. Why ...

  4. POJ - 1101 The Game dfs

    题意:给你一个地图,上面有一些‘X',给你起点终点,让你输出从起点到终点的路径中转向(改变方向)次数最少的路径,注意,不能穿过别的’X'并且可以超过边界 题解:关于超过边界,只要在外围多加一圈‘ ’. ...

  5. POJ 1101

    #include <iostream> #include <string> #define MAXN 78 #define min _min #define inf 12345 ...

  6. POJ 1101 The Game(BFS+判方向)

        The Game Description One morning, you wake up and think: "I am such a good programmer. Why ...

  7. POJ 2570(floyd)

    http://poj.org/problem?id=2570 题意:在海底有一些网络节点.每个节点之间都是通过光缆相连接的.不过这些光缆可能是不同公司的. 现在某个公司想从a点发送消息到b点,问哪个公 ...

  8. POJ 1426 Find The Multiple --- BFS || DFS

    POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...

  9. POJ 1006 Biorhythms (中国剩余定理)

    在POJ上有译文(原文右上角),选择语言:简体中文 求解同余方程组:x=ai(mod mi) i=1~r, m1,m2,...,mr互质利用中国剩余定理令M=m1*m2*...*mr,Mi=M/mi因 ...

随机推荐

  1. CAD通过扩展记录实体向数据库读写用户自定义的全局数据(com接口VB语言)

    VB代码实现如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...

  2. 前端自动化构建工具gulp使用

    1. 全局安装 gulp: $ npm install --global gulp 2. 作为项目的开发依赖(devDependencies)安装: $ npm install --save-dev ...

  3. MATLAB学习笔记之界面基本操作

    一.命令窗口 1.对于较长的命令,可以用...连接符将断开的命令连接 s=/+/+/4 ... +/+/ 注意: 连接符...与表达式之间要留一个空格: 对于单引号内的字符串必须在一行完全引起来. a ...

  4. Linux - nginx基础及常用操作

    目录 Linux - nginx基础及常用操作 Tengine淘宝nginx安装流程 nginx的主配置文件nginx.conf 基于域名的多虚拟主机实战 nginx的访问日志功能 网站的404页面优 ...

  5. Huawei-R&S-网络工程师实验笔记20190608-VLAN划分基础(基于端口、MAC地址、子网地址、协议)

    >Huawei-R&S-网络工程师实验笔记20190608-VLAN划分基础(基于端口.MAC地址.子网地址.协议) >>实验开始,先上拓扑图参考: 一.基于端口划分VLAN ...

  6. Django——8 关系表的数据操作 表关联对象的访问 多表查询

    Django 关系表中的数据操作 表关联对象的访问 关联对象的add方法 create方法 remove方法 clear方法 多表查询 查询补充 聚合查询 分组查询 F查询 Q查询 关系表的数据操作 ...

  7. 【codeforces 755E】PolandBall and White-Red graph

    [题目链接]:http://codeforces.com/contest/755/problem/E [题意] 给你n个节点; 让你在这些点之间接若干条边;构成原图(要求n个节点都联通) 然后分别求出 ...

  8. CF586D. Phillip and Trains

    /* CF586D. Phillip and Trains http://codeforces.com/problemset/problem/586/D 搜索 */ #include<cstdi ...

  9. nyoj_17_单调递增最长子序列_201403121516

    单调递增最长子序列 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4   输入 ...

  10. ZPush--基于netty4实现的苹果通知推送服务(APNs)Javaclient

    简单说下实现苹果通知推送服务(APNs)client的一些要注意的地方: 使用长连接: sanboxserver是无用的,调试时直接用"gateway.push.apple.com" ...