当前位置: 首页 > news >正文

重型机械网站开发模版wordpress文章中标签

重型机械网站开发模版,wordpress文章中标签,山西省两学一做网站,如何打造平台题意#xff1a; 一个 nmn\times mnm 的图#xff0c;现在有一束激光从左上角往右边射出#xff0c;每遇到 ‘#’#xff0c;你可以选择光线往四个方向射出#xff0c;或者什么都不做#xff0c;问最少需要多少个 ‘#’ 往四个方向射出才能使光线在第 n 行往右边射出。 …题意 一个 n×mn\times mn×m 的图现在有一束激光从左上角往右边射出每遇到 ‘#’你可以选择光线往四个方向射出或者什么都不做问最少需要多少个 ‘#’ 往四个方向射出才能使光线在第 n 行往右边射出。 题目 “The Chamber of Secrets has been opened again” — this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter the Chamber of Secrets. These aren’t good news for Lord Voldemort. The problem is, he doesn’t want anybody to be able to enter the chamber. The Dark Lord is going to be busy sucking life out of Ginny. The Chamber of Secrets is an n × m rectangular grid in which some of the cells are columns. A light ray (and a basilisk’s gaze) passes through the columns without changing its direction. But with some spell we can make a column magic to reflect the light ray (or the gaze) in all four directions when it receives the ray. This is shown in the figure below. The left light ray passes through a regular column, and the right ray — through the magic column. The basilisk is located at the right side of the lower right cell of the grid and is looking to the left (in the direction of the lower left cell). According to the legend, anyone who meets a basilisk’s gaze directly dies immediately. But if someone meets a basilisk’s gaze through a column, this person will get petrified. We know that the door to the Chamber is located on the left side of the upper left corner of the grid and anyone who wants to enter will look in the direction of its movement (in the direction of the upper right cell) from that position. This figure illustrates the first sample test. Given the dimensions of the chamber and the location of regular columns, Lord Voldemort has asked you to find the minimum number of columns that we need to make magic so that anyone who wants to enter the chamber would be petrified or just declare that it’s impossible to secure the chamber. Input The first line of the input contains two integer numbers n and m (2 ≤ n, m ≤ 1000). Each of the next n lines contains m characters. Each character is either “.” or “#” and represents one cell of the Chamber grid. It’s “.” if the corresponding cell is empty and “#” if it’s a regular column. Output Print the minimum number of columns to make magic or -1 if it’s impossible to do. Examples Input 3 3 .#. … .#. Output 2 Input 4 3 ##. … .#. .#. Output 2 Note The figure above shows the first sample test. In the first sample we should make both columns magic. The dragon figure represents the basilisk and the binoculars represent the person who will enter the Chamber of secrets. The black star shows the place where the person will be petrified. Yellow lines represent basilisk gaze moving through columns. 分析 1.此题目正解不是 0-1 BFS 但是适用 0-1 BFS 可以不需要思考过程赛时许多大佬都是这么做的。 2.做法很简单一个方向射出不需要花费0而往四个方向射出需要花费1然后直接来就可以了。 3.复习双端队列deque std::deque 是 STL 提供的 双端队列 数据结构。能够提供线性复杂度的插入和删除以及常数复杂度的随机访问。 构造函数 参见如下代码假设你已经 using 了 std 命名空间相关类型 // 1. 定义一个int类型的空双端队列 v0 dequeint v0; // 2. 定义一个int类型的双端队列 v1并设置初始大小为10; 线性复杂度 dequeint v1(10); // 3. 定义一个int类型的双端队列 v2并初始化为10个1; 线性复杂度 dequeint v2(10, 1); // 4. 复制已有的双端队列 v1; 线性复杂度 dequeint v3(v1); // 5. 创建一个v2的拷贝deque v4其内容是v4[0]至v4[2]; 线性复杂度 dequeint v4(v2.begin(), v2.begin() 3); // 6. 移动v2到新创建的deque v5不发生拷贝; 常数复杂度; 需要 C11 dequeint v5(std::move(v2));元素访问 与 vector 一致但无法访问底层内存。其高效的元素访问速度可参考实现细节部分。 函数作用at()返回容器中指定位置元素的引用执行越界检查常数复杂度。operator[]返回容器中指定位置元素的引用。不执行越界检查常数复杂度。front()返回首元素的引用。back()返回末尾元素的引用。 元素增删及修改 与 vector 一致并额外有向队列头部增加元素的函数。 函数作用clear()清除所有元素insert()支持在某个迭代器位置插入元素、可以插入多个。复杂度与 pos 与两端距离较小者成线性。erase()删除某个迭代器或者区间的元素返回最后被删除的迭代器。复杂度与 insert 一致。push_front()在头部插入一个元素常数复杂度。pop_front()删除头部元素常数复杂度。push_back()在末尾插入一个元素常数复杂度。pop_back()删除末尾元素常数复杂度。swap()与另一个容器进行交换此操作是 常数复杂度 而非线性的。 deque 的实现细节 deque 通常的底层实现是多个不连续的缓冲区而缓冲区中的内存是连续的。而每个缓冲区还会记录首指针和尾指针用来标记有效数据的区间。当一个缓冲区填满之后便会在之前或者之后分配新的缓冲区来存储更多的数据。 AC代码 #includestdio.h #includestring.h #includedeque #includeiostream using namespace std; const int M1e310; const int inf0x3f3f3f3f; int n,m; char mp[M][M]; int f[M][M][10]; int c[4][2] {1,0,-1,0,0,1,0,-1}; dequeintq; void Add_front(int x,int y,int dir,int step) {if(stepf[x][y][dir]){q.push_front(dir);//放在首位的需要倒着放入q.push_front(y);q.push_front(x);f[x][y][dir]step;} } void Add_back(int x,int y,int dir,int step) {if(stepf[x][y][dir]){q.push_back(x);q.push_back(y);q.push_back(dir);f[x][y][dir]step;} } int main() {cinnm;for(int i0; in; i)cinmp[i];for(int i0; in; i)for(int j0; jm; j)for(int k0; k4; k)f[i][j][k]inf;Add_front(n-1,m-1,3,0);while(!q.empty()){int xq[0];int yq[1];int dirq[2];q.pop_front();q.pop_front();q.pop_front();int xxxc[dir][0];int yyyc[dir][1];if(xx0yy0xxnyym)Add_front(xx,yy,dir,f[x][y][dir]);if(mp[x][y]#){for(int i0; i4; i){if(i!dir)Add_back(x,y,i,f[x][y][dir]1);}}}if(f[0][0][3]inf)cout-1endl;elsecoutf[0][0][3]endl;return 0; }
http://www.zqtcl.cn/news/15652/

相关文章:

  • 高校网站建设需求分析wordpress分页调用代码
  • 知名网站建设平台淘宝客做网站卖什么好
  • 网站google搜索优化网站建设高端定制
  • 哪个浏览器能打开那种网站辛集建设局官方网站
  • 苏州建设厅网站首页沈阳制作网站建站
  • 网站建设分金手指排名十三北京东道设计公司官网
  • wordpress 自定义结构廊坊关键词优化服务
  • 网站集约化建设方案桂林wordpress招聘
  • 手工做衣服的网站wordpress nginx 404
  • 服务器搭建网站数据库衡水营销网站建设
  • 官网网站怎么创建常德网站制作建设
  • 一个网站后台怎么做网站接入网方式
  • dede资讯类网站模板网站代码需要注意什么
  • 苏州网站开发电话自己做的网站怎么弄成app
  • 如何拿高权重网站外链进行互换?网站单页做301
  • 建立网站平台需要多少钱wordpress训网 插件
  • 新手容易上手的cms做企业网站个人网站备案涉及支付宝
  • 如何鉴别网站有没有做301重定向广州海珠网站开发价格
  • 谁能分享个小网站啊电子宣传册如何制作
  • 网站多级栏目怎么快速做网站文章
  • 企业网站建设的必要性和重要性大城县企业网站建设
  • 前端做项目的网站资源个人网站论坛展示
  • 网站空间是啥互联网博客网站
  • 青岛外贸网站运营哪家好在线设计logo字体
  • 领域网站建设做网站公司深
  • 做网站的数据从哪里来一家只做外卖的网站
  • 网页后端开发seo推广服务
  • 北京网站建设报价表网上怎么注册网址
  • 汶上县住房和建设局网站系统优化有什么用
  • 注册消防工程师长沙网站seo源头厂家