日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

0714M

發布時間:2023/12/9 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 0714M 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*************************************************************************> File Name: code/2015summer/0714/M.cpp> Author: 111qqz> Email: rkz2013@126.com > Created tim: 2015年07月14日 星期二 11時37分51秒************************************************************************/ #include<iostream> #include<iomanip> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<string> #include<map> #include<set> #include<queue> #include<vector> #include<stack> using namespace std; #define REP(i, n) for (int i=0;i<int(n);++i) typedef long long LL; typedef unsigned long long ULL; const int N=1E3+5; int m,n; char mymap[N][N]; int tx,ty,sx,sy; int dirx[4]={0,1,0,-1}; int diry[4]={1,0,-1,0}; int tim[N][N]; bool ok(int xxx,int yyy) {if (mymap[xxx][yyy]=='*')return false;if (xxx<0||xxx>=m) return false;if (yyy<0||yyy>=n) return false;return true; } void bfs() {cout<<"wwwwwwwwwwwwwwwffffffkkkkkkk?!"<<endl;memset(tim,0,sizeof(tim));queue<int>x;queue<int>y;x.push(sx);y.push(sy); while (!x.empty()&&!y.empty()){int xx=x.front();int yy=y.front();cout<<"nowx:"<<xx<<" nowy:"<<yy<<endl;x.pop();y.pop();if (xx==tx&&yy==ty) break;for ( int i = 0 ; i < 4 ; i++ ){int tmpx = xx+dirx[i];int tmpy = yy=diry[i];if (ok(tmpx,tmpy)){ if (mymap[tmpx][tmpy]=='|'){if (tim[xx][yy]%2==0){if (i==1){tim[tmpx+1][tmpy]=tim[xx][yy]+1;x.push(tmpx+1);y.push(tmpy);}if (i==3){tim[tmpx-1][tmpy]=tim[xx][yy]+1;x.push(tmpx-1);y.push(tmpy);}}else{if (i==0){tim[tmpx][tmpy+1]=tim[xx][yy]+1;x.push(tmpx);y.push(tmpy+1);}....{tim[tmpx][tmpy-1]=tim[xx][yy]+1;x.push(tmpx);y.push(tmpy-1);}}}if (mymap[tmpx][tmpy]=='-'){if (tim[xx][yy]%2==0){if (i==0){tim[tmpx][tmpy+1]=tim[xx][yy]+1;x.push(tmpx);y.push(tmpy+1);}if (i==2){tim[tmpx][tmpy-1]=tim[xx][yy]+1;x.push(tmpx);y.push(tmpy-1);}}else{if (i==1){tim[tmpx+1][tmpy]=tim[xx][yy]+1;x.push(tmpx+1);y.push(tmpy);}if (i==3){tim[tmpx-1][tmpy]=tim[xx][yy]+1;x.push(tmpx-1);y.push(tmpy);}}}if (mymap[tmpx][tmpy]=='.'){tim[tmpx][tmpy]=tim[xx][yy]+1;x.push(tmpx);y.push(tmpy);}}}} } void init() {scanf("%d %d",&m,&n)getchar();for ( int i = 0 ; i < m ; i++ )for ( int j = 0 ; j < n ; j++){scanf("%c",&mymap[i][j]);if (mymap[i][j]=='T'){tx = i;ty = j;}if (mymap[i][j]=='S'){sx = i;sy = j;}} } int main() {init();cout<<"why!!!!"<<endl;bfs();cout<<tim[tx][ty]<<endl;return 0; }

?

轉載于:https://www.cnblogs.com/111qqz/p/4645211.html

總結

以上是生活随笔為你收集整理的0714M的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。