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

晋江市住房和城乡建设网站制作视频剪辑

晋江市住房和城乡建设网站,制作视频剪辑,做石材的一般用什么网站,营销策划公司排行榜炸弹人问题 问题描述#xff1a;小人可以在迷宫中任意地方放置一个炸弹#xff0c;炸弹可以在以该点为中心的十字方向杀死怪物#xff0c;但是触碰到墙之后不再能传递攻击。求将一个炸弹放在哪个位置可以杀死更多的怪物#xff1f;#xff1f; Input#xff1a; 13 1…炸弹人问题 问题描述小人可以在迷宫中任意地方放置一个炸弹炸弹可以在以该点为中心的十字方向杀死怪物但是触碰到墙之后不再能传递攻击。求将一个炸弹放在哪个位置可以杀死更多的怪物 Input 13 13 ############# #GG.GGG#GGG.# ###.#G#G#G#G# #.......#..G# #G#.###.#G#G# #GG.GGG.#.GG# #G#.#G#.#.#.# ##G...G.....# #G#.#G###.#G# #...G#GGG.GG# #G#.#G#G#.#G# #GG.GGG#G.GG# ############# 3 3Output: 7 11 10 即7 11坐标处可以杀死10个怪物 思路一遍历图中的每个点若非墙壁怪物则计算该点可以杀死多少怪物循环遍历找出最大之注但是不幸的是这样的的方法对于一些特殊的点不适用例如图中的111点 思路二BFS/DFS先筛选出可以抵达的点再计算 DFS package Bomberman;import java.util.Scanner;public class DFS {static char[][] a new char[20][20];static int[][] book new int[20][20];static Scanner input new Scanner(System.in);static int max 0;static int mx, my;static int n, m;public static void main(String[] args) {n input.nextInt();m input.nextInt();for (int j 0; j n; j) {String str input.next();a[j] str.toCharArray();}int startX input.nextInt();int startY input.nextInt();book[startX][startY] 1;max getsum(startX, startY);mx startX;my startY;dfs(startX, startY);System.out.println(mx my max);}public static void dfs(int x, int y) {/*** 右、下、左、上* */int sum, tx, ty;int[][] next {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};sum getsum(x, y);if (sum max) {max sum;mx x;my y;}for (int i 0; i 4; i) {tx x next[i][0];ty y next[i][1];if (tx 0 || tx n - 1 || ty 0 || ty m - 1) {continue;}if (a[tx][ty] . book[tx][ty] 0) {book[tx][ty] 1;dfs(tx, ty);}}return;}public static int getsum(int i, int j) {int x, y;int sum 0;x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}x--;}x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}x;}x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}y--;}x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}y;}return sum;} }BFS import java.util.LinkedList; import java.util.Queue; import java.util.Scanner;class note {int x;int y;note(int x, int y) {this.x x;this.y y;} } public class BFS {static char[][] a new char[20][20];static int[][] book new int[20][20];static Queuenote queue new LinkedList();static Scanner input new Scanner(System.in);static int n, m;static int max0, mx, my;public static void main(String[] args) {/*** #代表墙G代表怪物.代表放置炸弹的位置* */n input.nextInt();m input.nextInt();for (int l 0; l n; l) {String str input.next();a[l] str.toCharArray();}int startX input.nextInt();int startY input.nextInt();queue.offer(new note(startX, startY));max getnum(startX, startY);mx startX;my startY;bfs();System.out.println(mx my max);}public static void bfs() {int tx, ty, sum;int[][] next {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};while (!queue.isEmpty()) {for (int l 0; l 4; l) {tx queue.peek().x next[l][0];ty queue.peek().y next[l][1];if (tx 0 || tx n - 1 || ty 0 || ty m - 1) {continue;}if (a[tx][ty] . book[tx][ty] 0) {book[tx][ty] 1;queue.offer(new note(tx, ty));sum getnum(tx, ty);if (sum max) {max sum;mx tx;my ty;}}}queue.remove();}}/*** 获取在某点放置炸弹可以杀死的怪物数* */public static int getnum(int i, int j) {int sum, x, y;sum 0;x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}x--;}x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}x;}x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}y--;}x i;y j;while (a[x][y] ! #) {if (a[x][y] G) {sum;}y;}return sum;} }
http://www.ihoyoo.com/news/28101.html

相关文章:

  • 百度提交网站已删内容做网站怎么插音频
  • 浙江省建设工程招投标网站品牌网站设计标准
  • 网站被采集海南网站建设推广公司
  • 在阿里怎样做单页销售网站流行网站开发工具
  • 网站设计公司网站设计公司免费优化网站
  • 在线网站域名whois查询工具网页制作三剑客包括
  • wordpress文章有模板优化落实新十条措施
  • 网站建设与维护流程网站开发与维护是什么
  • 网站信息推广的策略有哪些seo查询友情链接
  • 永康外贸网站建设qq手机网页版在线登录
  • 手机站制作的网站架构制作企业网站的新闻
  • 装修公司怎么做免费网站特产电商网站建设报价单
  • 郑州网站建设技术支持wordpress建站教程道一
  • 自己做网站处理图片用什么软件o2o网站咋建设
  • 免费可商用的素材网站推广营销方案
  • 成都程序员网站餐饮品牌设计哪个公司最好
  • 网站流量与广告费最新国际热点新闻
  • 主流网站设计软件wordpress 自带搜索
  • 黑户可做网站买东西网站
  • 郑州云拓网站建设公司一套网页ui设计多少钱
  • 做网站的有哪些公司好的flash网站
  • 个人网站成功案例wordpress制作页面模板下载
  • cms网站开发教程企业邮箱的格式长什么样子
  • 慕课网站建设开题报告专门建设网站的公司
  • 阿里云自己做网站网站源码下载教程
  • 兰州建设网站的公司视频分享网站建设难吗
  • 做网站签到挣钱吗小程序模板下载了怎么用
  • 网站广告轮播代码衡阳建设网站制作
  • 软件库合集资料网站推广渠道平台
  • flash网站轮播广告怎么做做视频解析网站是犯法的么