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

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

The Game

2019-11-14 09:51:14
字體:
來源:轉載
供稿:網友

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
热门国产精品亚洲第一区在线| 日本精品一区二区三区在线| 懂色av影视一区二区三区| 国精产品一区一区三区有限在线| 91精品国产综合久久香蕉| www日韩中文字幕在线看| 成人黄色免费看| 欧美中文字幕在线播放| 亚洲伊人第一页| 国产精品大片wwwwww| 欧美噜噜久久久xxx| 疯狂做受xxxx高潮欧美日本| 亚洲天堂免费在线| 日韩电影免费观看中文字幕| 成人免费自拍视频| 欧美专区日韩视频| 亚洲xxxx18| 欧美性猛交丰臀xxxxx网站| 91欧美视频网站| 91中文字幕在线| 精品久久中文字幕| 国产亚洲成精品久久| 国内免费久久久久久久久久久| 亚洲国产精品电影在线观看| 国产精品国产三级国产aⅴ浪潮| 亚洲欧美国产另类| 欧美做受高潮电影o| 欧美在线一区二区三区四| 亚洲精品国产精品久久清纯直播| 中文字幕成人精品久久不卡| 国产一区二区日韩| 欧美一区二区三区精品电影| 国产一区二区在线免费视频| 亚洲人成自拍网站| 欧美午夜精品在线| 精品国内自产拍在线观看| www.亚洲男人天堂| 77777少妇光屁股久久一区| www高清在线视频日韩欧美| 久久精品青青大伊人av| 亚洲美女在线视频| 国产精品88a∨| 777午夜精品福利在线观看| 亚洲精品720p| 久久99青青精品免费观看| 亚洲精品免费一区二区三区| 欧美在线免费看| 国产女同一区二区| 日韩色av导航| 亚洲美女av电影| 国产香蕉97碰碰久久人人| 日韩一区二区三区xxxx| 国产成人综合精品在线| 亚洲成人av在线| 久久成人精品一区二区三区| 粗暴蹂躏中文一区二区三区| 亚洲色图av在线| 亚洲欧洲日产国产网站| 国产在线观看一区二区三区| 日韩精品视频在线免费观看| 精品久久久久国产| 日韩免费观看在线观看| 日韩美女视频免费看| 欧美在线视频一二三| 欧美午夜精品久久久久久久| 日韩av中文字幕在线免费观看| 日韩美女主播视频| 国产精品美女呻吟| 欧美一区在线直播| 欧美午夜宅男影院在线观看| 日韩av黄色在线观看| …久久精品99久久香蕉国产| 亚洲2020天天堂在线观看| 亚洲成人精品在线| 在线国产精品播放| 亚洲国产精品久久久久秋霞不卡| 国产欧美日韩免费| 欧美性生交xxxxxdddd| 中文字幕日韩精品有码视频| 国产精品福利网站| 欧美日本在线视频中文字字幕| 91久久综合亚洲鲁鲁五月天| 国产在线视频一区| 这里只有精品视频在线| 欧美亚洲午夜视频在线观看| 欧美色欧美亚洲高清在线视频| 亚洲第一区第二区| 久久精品国产亚洲一区二区| 久久综合色影院| 亚洲激情在线视频| 国产欧美精品一区二区| 最新的欧美黄色| 久久精品青青大伊人av| 国产福利视频一区| 色偷偷888欧美精品久久久| 性色av香蕉一区二区| 2019最新中文字幕| 亚洲最大av网站| 日韩欧美在线看| 国产91在线播放精品91| 欧美国产欧美亚洲国产日韩mv天天看完整| 国产精品亚洲一区二区三区| 人体精品一二三区| 国产日韩换脸av一区在线观看| 欧美午夜美女看片| 亚洲天堂网在线观看| 91精品国产91久久久久久久久| 日韩中文在线中文网在线观看| 久久影视免费观看| 91国产精品电影| 日韩欧美成人精品| 日本一区二区在线播放| 不卡av在线播放| 亚洲国产私拍精品国模在线观看| 日韩精品中文字幕在线| 日韩av网站大全| 国产精品美女久久久久久免费| 欧美综合一区第一页| 高清视频欧美一级| 亚洲女同精品视频| 日韩视频精品在线| 亚洲丝袜在线视频| 欧美大荫蒂xxx| 欧美激情中文字幕乱码免费| 国产成人免费av| 91在线播放国产| 久久成年人视频| 91精品国产亚洲| 亚洲第一精品夜夜躁人人爽| 日韩精品在线免费观看视频| 国产色婷婷国产综合在线理论片a| 精品国产精品自拍| 欧洲永久精品大片ww免费漫画| 国产91对白在线播放| 在线激情影院一区| 久久91亚洲人成电影网站| 亚洲欧美激情四射在线日| 日韩av在线免播放器| 亚洲精品美女久久久| 国语自产在线不卡| 午夜精品久久久99热福利| 亚洲另类激情图| 国产日韩欧美夫妻视频在线观看| 国产啪精品视频| 中文字幕久久亚洲| 97在线观看免费高清| 亚洲人成在线观看| 亚洲v日韩v综合v精品v| 国产日韩欧美日韩大片| 亚洲国产另类 国产精品国产免费| 18久久久久久| 欧美性在线观看| 色99之美女主播在线视频| 久久精品视频播放| 亚洲精品成人网| 伊人男人综合视频网| 久久99久久99精品免观看粉嫩| 国内精品一区二区三区四区| 91亚洲国产成人久久精品网站| 国产精品1234| 国产精自产拍久久久久久蜜| 亚洲精品少妇网址| 亚洲视频国产视频| 亚洲人午夜精品免费|