亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

The Game

2019-11-14 10:18:10
字體:
來源:轉載
供稿:網友

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. 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. It does not cross any other game pieces. (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.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.InputThe 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. 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". The entire input is terminated by a test case starting with w=h=0. This test case should not be procesed.OutputFor 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. Output a blank line after each board.Sample Input
5 4XXXXXX   XXXX X XXX 2 3 5 31 3 4 42 3 3 40 0 0 00 0Sample Output
Board #1:Pair 1: 4 segments.Pair 2: 3 segments.Pair 3: impossible.

解題報告

直接廣搜就行了,由隊列的每個點向四個方向標記直到遇到'X',小心每組結束還有個/n,

#include<stdio.h>#include<string.h>#include<queue>#define MAX_N 80#define INF 0x3f3f3f3fusing namespace std;char map[MAX_N][MAX_N];int dp[MAX_N][MAX_N];const int ox[]={0,0,1,-1};const int oy[]={1,-1,0,0};int w,h;int s_x,s_y,e_x,e_y;int bfs(){    memset(dp,0x3f,sizeof(dp));    queue<pair<int,int> > que;    que.push(make_pair(s_x,s_y));    dp[s_y][s_x]=0;    map[e_y][e_x]=' ';    int H=h+1,W=w+1;        while(!que.empty()){        int X=que.front().first,Y=que.front().second;que.pop();        int S=dp[Y][X]+1;        for(int i=0;i<4;i++){            int x=X,y=Y;            while(true){                x+=ox[i],y+=oy[i];                if(x<0||x>W||y<0||y>H||map[y][x]=='X') break;                if(dp[y][x]<=S) continue;                que.push(make_pair(x,y));                dp[y][x]=S;            }        }    }    map[e_y][e_x]='X';    return dp[e_y][e_x];}int main(){    int Board=1,Pair;    while(~scanf("%d%d",&w,&h)&&w&&h){        memset(map,0,sizeof(map));        getchar();        for(int i=1;i<=h;i++)            gets(map[i]+1);        printf("Board #%d:/n",Board++);Pair=1;        while(scanf("%d%d%d%d",&s_x,&s_y,&e_x,&e_y)&&s_x&&s_y&&e_x&&e_y){            printf("Pair %d: ",Pair++);            int ans=bfs();            if(ans==INF) puts("impossible.");            else printf("%d segments./n",ans);        }        putchar('/n');    }    return 0;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
91视频国产一区| 欧美一级黄色网| 欧美精品一区二区免费| 欧美色图在线视频| 亚洲综合精品一区二区| 欧美国产日韩视频| 欧美成人一二三| 国产精品伦子伦免费视频| 亚洲影视九九影院在线观看| 久久免费少妇高潮久久精品99| 中文字幕精品—区二区| 欧美日韩在线第一页| 日日噜噜噜夜夜爽亚洲精品| 草民午夜欧美限制a级福利片| 成人激情免费在线| 日韩在线中文视频| 欧美激情2020午夜免费观看| 57pao国产成人免费| 亚洲免费电影在线观看| 日韩欧美成人免费视频| 91免费看国产| 亚洲女人天堂成人av在线| 揄拍成人国产精品视频| 成人午夜小视频| 91午夜理伦私人影院| 亚洲欧洲在线免费| 国产精品网红福利| 亚州av一区二区| 夜夜狂射影院欧美极品| 亚洲视频网站在线观看| 欧美色图在线视频| 成人福利在线观看| 国产亚洲人成网站在线观看| 亚洲第一级黄色片| 亚洲欧美日韩精品久久| 亚洲九九九在线观看| 亚洲欧美综合区自拍另类| 成人免费看黄网站| 久久久久久久久久久亚洲| 欧美理论电影在线播放| 欧美激情xxxx性bbbb| 在线国产精品视频| 欧美成人sm免费视频| 久久69精品久久久久久久电影好| 中日韩午夜理伦电影免费| 欧美疯狂做受xxxx高潮| 中文字幕视频一区二区在线有码| 色系列之999| 日韩成人在线播放| 精品福利一区二区| 欧美老女人bb| 97在线观看视频国产| 中文字幕亚洲无线码a| 国产亚洲欧美另类中文| 欧美插天视频在线播放| 992tv成人免费视频| 一本一本久久a久久精品综合小说| 午夜精品久久久久久久男人的天堂| 国产精品久久一区主播| 精品自拍视频在线观看| 欧美有码在线观看| 日韩一区二区久久久| 2018中文字幕一区二区三区| 国产精品自拍小视频| 国产成人精品久久久| 欧美理论电影网| 久久影视电视剧免费网站| 久久久国产精品一区| 欧美日韩不卡合集视频| 精品国产自在精品国产浪潮| 久久中文久久字幕| 欧美丰满少妇xxxxx| 久久精品国产清自在天天线| 亚洲夜晚福利在线观看| 亚洲美女精品成人在线视频| 精品精品国产国产自在线| 日韩成人在线观看| 日韩精品在线免费| 国产精品自拍网| 91精品久久久久久久久| 色偷偷噜噜噜亚洲男人的天堂| 亚洲国产欧美一区二区三区同亚洲| 国产欧美日韩精品丝袜高跟鞋| 国产精品欧美在线| 国产成人精品最新| 欧美色图在线视频| 欧美国产欧美亚洲国产日韩mv天天看完整| 日韩h在线观看| 日韩视频在线一区| 疯狂做受xxxx欧美肥白少妇| 91po在线观看91精品国产性色| 欧美日韩爱爱视频| 国产欧美日韩精品专区| 亚洲国产一区自拍| 狠狠色狠色综合曰曰| 国产亚洲人成网站在线观看| 91超碰caoporn97人人| 国产成人精品av在线| 亚洲欧美日韩国产中文| 欧洲成人免费视频| 亚洲国产精品久久| 高清一区二区三区日本久| 久久精品色欧美aⅴ一区二区| 中文字幕亚洲一区| 国产成人精品电影| 中文字幕九色91在线| 成人欧美一区二区三区黑人孕妇| 尤物99国产成人精品视频| 4388成人网| 97人人做人人爱| 精品自拍视频在线观看| 久久久人成影片一区二区三区| 国产精品444| 亚洲成人av片在线观看| 欧美大片在线免费观看| 青草青草久热精品视频在线网站| 日韩欧美中文字幕在线观看| 欧美日韩中文在线观看| 在线观看日韩www视频免费| 国产精品福利观看| 亚洲va电影大全| 成人免费激情视频| 国产欧美最新羞羞视频在线观看| 国产精品白嫩初高中害羞小美女| 亚洲免费人成在线视频观看| 日本老师69xxx| 亚洲免费福利视频| 欧美日韩综合视频网址| 在线观看精品国产视频| 不卡av日日日| 国产欧美久久久久久| 国产亚洲福利一区| 欧美激情精品久久久久久大尺度| 成人免费网站在线看| 久久99久久亚洲国产| 国产精品亚发布| 亚洲曰本av电影| 一本大道亚洲视频| 久久久久成人网| 久久99精品久久久久久噜噜| 欧美一区二区三区精品电影| 色综合伊人色综合网站| 国产成人精品午夜| 欧美激情一级欧美精品| 欧美在线观看日本一区| 欧美性精品220| 久久99热这里只有精品国产| 欧美色videos| 欧美人与物videos| 亚洲精品视频久久| 另类美女黄大片| 精品女厕一区二区三区| 欧美在线免费视频| 精品视频—区二区三区免费| 国产精品精品国产| 国产精品久久中文| 日韩在线免费av| 91精品国产自产在线| 欧美精品电影免费在线观看| 激情av一区二区| 亚洲剧情一区二区| 日本免费久久高清视频| 91色视频在线观看| 国产精品91在线观看|