应该是比较冷门的一道题,只搜到了英文题解hhhh,难度不大,所以这次来写一个认真的题解报告。


You are Ash, the famous Pokemon trainer. To become the greatest Pokemon master, you travel through regions battling against gym leaders and entering Pokemon League competitions. With your well-trained Pikachu, Squirtle and Bulbasaur, you have already captured six badges! What a marvellous performance!

你是神奇宝贝训练大师Ash(推测可能是智爷?)。为了成为更伟大的神奇宝贝训练大师,你在各地旅行并挑战道馆,最终还进入了神奇宝贝联盟赛。与你超强的皮卡丘、杰尼龟和妙蛙种子一起,你已经获得了六个徽章。你表现得真棒!

Now, you are walking through the Enchanted Forest, where the most powerful Pokemons live... No, not those giant dragons; we are actually talking about Jigglypuffs. A Jigglypuff is a normal-type Balloon Pokemon, with a round, balloon-like body, a tuft of fur on its forehead, and stubby arms and legs. What’s so powerful of them? Well, do you notice that microphone in the picture? That’s right, Jigglypuff has a well-regarded singing voice, and its most popular attack is to sing its opponent to sleep! Therefore, it is always a good idea to find a route avoiding places wherever you might hear the Jigglypuffs’ lullaby.

现在你正要穿越 魔幻森林 ,那里住着最强的神奇宝贝。不,不是那些巨龙,事实上我说的是胖丁。胖丁是普通系气球小精灵,它们的身体圆圆的,像气球一样,前额有一撮小刘海,还有短短的四肢。嗯?你问它们强在哪里?好吧,你注意到图片中的麦克风了吗?胖丁的歌声十分有名,它最强大的攻击就是通过唱歌来让它的对手睡觉!因此,穿过这个森林最好的办法是找一条不会听到它们歌声的路。

Let us model the situation as follows: we shall treat the forest as a rectangular grid formed by paths which are 1 unit apart. Your starting position is at the top left corner of the grid (1, 1), and you will leave the forest at the lower right corner (R, C). There might be blocked areas which you are not allowed to trespass through. Jigglypuffs might be present at some intersections. The loudness L of each Jigglypuff is given, which means that places no more than L units away from the Jigglypuff are considered “dangerous” and should be avoided.

让我们把这种情况建模如下:我们将森林视为一个单位长度为1的矩形网格格点。您的起始位置位于网格的左上角(1, 1),出口在在右下角(R,C)。有些点是被岩石阻挡而不能通过。胖丁们站在一些格点上。给出了每个胖丁的响度L,这意味着远离这个胖丁的L个单元的位置被认为是“危险的”并且不能走。


Input

Input consists of several test cases. Each test begins with two integers R and C (1 ≤ R, C ≤ 200), the number of rows and columns in the grid map. Then comes an integer m, followed by m lines each giving the coordinates of a blocked position. Next there is an integer n (0 ≤ n ≤ 100), the number of Jigglypuffs in the forest. The following n lines each gives the position of a Jigglypuff and its loudness L (1 ≤ L ≤ 100). Input ends with a test case where R = 0 and C = 0. You must not process this test case.

Output

For each case, if some “dangerous” places are unavoidable, print ‘Impossible.’ Otherwise, give the length of the shortest path to get out of the forest safely. The figure on the right shows the sample test case. The area enclosed by the blue circle is “dangerous”. The solution shown is unique.

Sample Input

5 5

5

1 2

1 3

1 4

1 5

2 5

1

4 3 1

0 0

Sample Output

8

多组输入

每组输入第一行是迷宫大小R,C(当R=C=0时结束输入)

后跟一行单一个数字表示被岩石阻挡的区域个数

后跟好多行岩石坐标

然后一行单一个数字表示胖丁的个数

后跟好多行 胖丁位置,胖丁声音传播距离



一个简单的迷宫。

因为胖丁而不能走的格子标记不能走就行

我的方法是先划分出一个以胖丁站位为中心的正方形,去遍历其中的每一点与胖丁站位的距离平方,如果小于L平方就标记不能走。

然后就是一个普通的找路bfs。

#include<iostream>
#include<string>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
/*
* I just want to eat
* How tasty it is
*/
int forest[205][205];//好像从(1,1)开始,也就是说边界是[1,n]
int R,C;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
struct step{int x,y,len;
};
void bfs(){queue<step> q2;step s={1,1,0};q2.push(s);while(!q2.empty()){int x= q2.front().x,y= q2.front().y,l= q2.front().len;q2.pop();if(x==R&&y==C){cout<<l<<endl;return;}for(int i=0;i<4;i++){int xx=x+dx[i],yy=y+dy[i];if(xx<=0||xx>R||yy<=0||yy>C)continue;if(forest[xx][yy]==1)continue;forest[xx][yy]=1;step s={xx,yy,l+1};q2.push(s);}}cout<<"Impossible."<<endl;return ;
}int main(){while(cin>>R>>C){if(R==0)break;memset(forest,0,sizeof forest);int n,a,b,L;cin>>n;for(int i = 0;i<n;i++){cin>>a>>b;forest[a][b]=1;}cin>>n;for(int i=0;i<n;i++){cin>>a>>b>>L;for(int j = max(a-L,0);j<=min(a+L,R);j++){for(int k = max(b-L,0); k<=min(b+L,C);k++){int d1=abs(j-a),d2=abs(k-b);if(d1*d1+d2*d2<=L*L)forest[j][k]=1;}}}bfs();}}

uva 10977 Enchanted Forest 魔幻森林相关推荐

  1. Isolation Forest 孤立森林

    Isolation Forest 孤立森林 Isolation Forest 孤立森林 从今天开始打算在CSDN博客上做笔记.希望有兴趣的可以一起讨论.现在主要做的和弱监督和无监督有关.今天读的是Is ...

  2. D. The Enchanted Forest

    传送门: D. The Enchanted Forest 题意:有一条长为n的线段,每个点上起始有a[i]个蘑菇.你可以选择起始点x.你有k分钟,每分钟以下事件将会发生: 1.从点x走到点y(abs( ...

  3. Codeforces-1687 A: The Enchanted Forest 【贪心、简单数学】

    Codeforces-1687 A: The Enchanted Forest 题目 题目截图 样例描述 题目大意   给定一个长度为 n n n 的数组 { a i } \{a_i\} {ai​}. ...

  4. The Enchanted Forest(思维/前缀和)

    The Enchanted Forest 传送门 Problem - 1687A - Codeforces 1600 思路 分类,如果k<=n,那很好想,就挑最大的连续子段和就行:当k>n ...

  5. Forbidden Forest 错落森林

    乔治温斯顿10首经典钢琴曲交响乐版-Forbidden Forest 一贯以来,许多古典音乐改编为新世纪音乐的专辑,除了保留原有的色彩和高贵内 涵,更拥有了灵气和动感.而现在让我们去感受一种用交响音乐 ...

  6. [Machine Learning] Random Forest 随机森林

    阅读目录 1 什么是随机森林? 2 随机森林的特点 3 随机森林的相关基础知识 4 随机森林的生成 5 袋外错误率(oob error) 6 随机森林工作原理解释的一个简单例子 7 随机森林的Pyth ...

  7. 【R文档】1 isolation.forest/孤立森林算法

    [未完待续--] 目录 1.辅助信息 2.孤立森林原理 3.基本描述 4.句法 5.案例 案例1:检测一个明显的离群值 1.辅助信息 包名称:isotree​ 包的版本:0.5.14 网址:英文R文档 ...

  8. 新概念二册 Lesson 44 Through the forest穿过森林(复习动名词doing)

    文章目录 1 课文 2 单词 2.1 forest [ˈfɒrɪst] n. 森林 2.2 risk [rɪsk] n. 危险,冒险 2.3 picnic [ˈpɪknɪk] n. 野餐 2.4 ed ...

  9. Isolation Forest孤立森林(一)

    孤立森林论文地址 http://cs.nju.edu.cn/zhouzh/zhouzh.files/publication/icdm08b.pdf 概要    现有的基于模型的异常检测方法大多是构造一 ...

最新文章

  1. Ubuntu下安装realtek的rtl8188eu网卡芯片驱动
  2. python同步锁和互斥锁的区别_Python实现的多线程同步与互斥锁功能示例
  3. c python通信protobuf_python 处理protobuf协议
  4. Shiro+springboot+mybatis(md5+salt+散列)认证与授权-02
  5. HarmonyOS之在工程中导入Sample工程和添加Module
  6. SAP UI5框架绘制footer区域的入口调试
  7. UML 中extend和include的区别
  8. docker安装部署_有关docker安装yearning和部署inception(闭源)
  9. Xcode7 无账号真机测试!!
  10. druid 连接池监控报错 Sorry, you are not permitted to view this page.
  11. Xilinx Altera FPGA中的逻辑资源(Slices VS LE)比较
  12. OCR图文识别工具Mac版:iText
  13. Dash_API与必应翻译的综合使用
  14. maven常用命令大全(附详细解释)
  15. WebSphere如何重启服务
  16. 数据的存储------计算机中常见数据类型的存储方式(C语言解析)
  17. vue报错 | Duplicate keys detected: ‘0’. This may cause an update error.
  18. 网络安全篇 防火墙的静态路由-04
  19. 如何做好一个中小型企业计算机网络管理员
  20. Mac 下 移动硬盘只读解决方案

热门文章

  1. Java逐行读取fasta文件
  2. python画立体爱心_Python画爱心
  3. 高通MSM8998 ABL的调试
  4. 虚拟服务器设置虚拟内存,vmware虚拟机关于内存的一项设置,可以提高你的虚拟机运行效能-虚拟内存怎么设置最好...
  5. 技嘉Gigabyte主板Z370HD3安装1080ti+ubuntu17.10+Cuda9.1+cudnn7+tensorflow
  6. mapbox-gl加载带环境贴图白模(视频)
  7. C语言编程学习制作最好玩的报数游戏
  8. mac系统上运行c语言文件
  9. error: #79: expected a type specifier
  10. 安装黑群晖找不到局域网电脑_组建家庭存储群晖NAS(一)——详细安装篇