图论 BFS HDU 1175
来源:互联网 发布:炒股软件接口 编辑:程序博客网 时间:2024/04/30 08:12
#include <iostream>#include <string>#include <vector>#include <map>#include <set>#include <algorithm>#include <iterator>#include <list>#include <stack>#include <math.h>#include <queue>using namespace std;/*T2 HDU 1175*/struct place{int x;int y;};int n,m;int b[1002][1002];int vis[1002][1002];int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};int turn;void bfs(int x1,int y1,int x2,int y2){place a,t;queue<place> que;a.x=x1;a.y=y1;que.push(a);turn =0;vis[x1][y1] = 1;while(!que.empty()){a=que.front();que.pop();if(a.x == x2 && a.y == y2){cout<<"YES"<<endl;return ;}}cout<<"NO"<<endl;}int main(){int i,j;int x1,x2,y1,y2;int q;while(cin>>n>>m){for(i=1;i<=n;i++)for(j=1;j<=m;j++)cin>>b[i][j];cin>>q;for(i=0;i<q;i++){cin>>x1>>y1>>x2>>y2;if(b[x1][y1] != b[x2][y2] || !b[x1][y2] ||(x1==x2 && y1==y2)){cout<<"NO\n"<<endl;}memset(vis,0,sizeof(vis));bfs(x1,y1,x2,y2);}}return 0;}
0 0
- 图论 BFS HDU 1175
- hdu 1175 bfs
- hdu 1175 BFS
- HDU 1175 BFS
- BFS HDU 1175
- hdu 1175 bfs+剪枝
- HDU 5040 图论bfs
- 图论 BFS HDU 1495
- 图论 BFS HDU 2717
- 图论 BFS HDU 1548
- hdu 1175 连连看 bfs
- hdu 1175 连连看 (BFS)
- hdu 1175 连连看 BFS
- Hdu 1175 连连看 [Bfs]
- HDU 1175 连连看(BFS)
- HDU 1175 连连看【BFS】
- HDU 1175 连连看(BFS)
- hdu 1175 bfs 转弯题
- MPAndroidChart(GitHub上优秀得图表功能库)
- 评价人工神经部分
- c#学习笔记之获取当前路径
- Xcode的Product Name、Bundle Name、Bundle Display Name区别
- ajax提交数据到后台php接收
- 图论 BFS HDU 1175
- android studio 线程安全Only the original thread that created a view hierarchy can touch its views
- 你说 后来
- 前端js+ajax+css/后端springMVC项目1总结
- mySQL数据库
- 【转载】XCode工程中 Project 和 Targets区别
- 机器学习中常用到的知识点总结
- php的pdo数据层mysql类
- HDU 1671 Phone List 字典树(Trie)