博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 5652 India and China Origins
阅读量:6393 次
发布时间:2019-06-23

本文共 2872 字,大约阅读时间需要 9 分钟。

India and China Origins

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 901    Accepted Submission(s): 309


Problem Description
A long time ago there are no himalayas between India and China, the both cultures are frequently exchanged and are kept in sync at that time, but eventually himalayas rise up. With that at first the communation started to reduce and eventually died.
Let's assume from my crude drawing that the only way to reaching from India to China or viceversa is through that grid, blue portion is the ocean and people haven't yet invented the ship. and the yellow portion is desert and has ghosts roaming around so people can't travel that way. and the black portions are the location which have mountains and white portions are plateau which are suitable for travelling. moutains are very big to get to the top, height of these mountains is infinite. So if there is mountain between two white portions you can't travel by climbing the mountain.
And at each step people can go to 4 adjacent positions.
Our archeologists have taken sample of each mountain and estimated at which point they rise up at that place. So given the times at which each mountains rised up you have to tell at which time the communication between India and China got completely cut off.
 

Input
There are multi test cases. the first line is a sinle integer 
T which represents the number of test cases.
For each test case, the first line contains two space seperated integers 
N,M. next 
N lines consists of strings composed of 
0,1 characters. 
1 denoting that there's already a mountain at that place, 
0 denoting the plateau. on 
N+2 line there will be an integer 
Q denoting the number of mountains that rised up in the order of times. Next 
Q lines contain 
2 space seperated integers 
X,Y denoting that at ith year a mountain rised up at location 
X,Y.
T10
1N500
1M500
1QNM
0X<N
0Y<M
 

Output
Single line at which year the communication got cut off.
print -1 if these two countries still connected in the end.
Hint:
From the picture above, we can see that China and India have no communication since 4th year.
 

Sample Input
 
1 4 6 011010 000010 100001 001000 7 0 3 1 5 1 3 0 0 1 2 2 4 2 1
 

Sample Output
 
4
 

题意    一開始有一个地图  白格能走  黑格不能走  仅仅能走到相邻格子  起点是最上面一层任意的白格  终点是底层的白格

   之后的Q年中  每年都会在Xq,Yq的格子中出现一座山  该格子将不能通行  问第几年时  没有路径从上走到下

一道简单的搜索题。先记录一天从上到下的路径。若生成的山在记录的路径上,就又一次搜索路径,知道没有路径或者没有山生成。

不必要每次生成山就去搜索一次路径

#include
#include
#include
#include
#include
using namespace std;int n,m;char Map[505][505];bool vis[505][505]; //记录一条从上走到下的路径 经过的点是true int dir[4][2]= {0,1,1,0,0,-1,-1,0};int rr;struct node{ int x,y; bool cheak() { if(x>=0&&x
=0&&y
q; int mat[505][505]; memset(mat,-1,sizeof(mat)); memset(vis,false ,sizeof(vis)); node st,ed; for(int i=0; i
  

转载地址:http://egsha.baihongyu.com/

你可能感兴趣的文章
Jedis与Redisson选型对比
查看>>
MongoDB学习笔记(查询)
查看>>
freemarker自定义标签的写法和使用
查看>>
使用Gitlab CI进行持续集成
查看>>
Win32编程基本概念
查看>>
×××灯式样的站点链接说明,链接提示
查看>>
Linux下动态IP和静态IP的设置方法
查看>>
mysql 行长度
查看>>
SUSE配置网关
查看>>
java中获取字母和数字的组合
查看>>
8-3 泛型
查看>>
你是“职业”软件开发吗?——书评《浮现式设计-专业软件开发的演进本质》...
查看>>
iOS 多线程 之 GCD(大中枢派发)(二)
查看>>
开源项目 log4android 使用方式详解
查看>>
ssh命令详解
查看>>
C# 中字符串转换成日期
查看>>
垃圾短信相关用户细分方案
查看>>
免费的Windows系统工具
查看>>
脚本:将git项目下载到本地并启动
查看>>
Linked List Cycle && Linked List Cycle II
查看>>