POJ 1101 譯文

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.路徑是由直的部分組成,每一個部分或水平或垂直。markdown

It does not cross any other game pieces.
2.路徑不能跨過其它的遊戲方塊。
(It is allowed that the path leaves the board temporarily.)
(路徑能夠暫時離開板)
Here is an example:
下面 舉個例子。ide

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樣例輸入this

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樣例輸出spa

Board #1:
Pair 1: 4 segments.
Pair 2: 3 segments.
Pair 3: impossible.遊戲

相關文章
相關標籤/搜索