Training #2 cell battle (BFS)】的更多相关文章

Constraints: 1 <= R, C <= 500 1 <= T <= 5 Sample Input: 5 3 5 ##### a...b ##### 3 4 #### a..b #### 3 3 #c# a.b #d# 3 3 #c# ... a.b 3 5 ..... .#.#. a...b Sample Output: ##### aa*bb ##### #### aabb #### #c# a*b #d# #c# acb a*b aa*bb a#.#b aa*bb…
  Battle City Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7579   Accepted: 2544 Description Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are…
来源poj2312 Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty spaces, rivers, st…
Battle City Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9885   Accepted: 3285 Description Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are d…
Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty spaces, rivers, steel walls…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6324 Problem F. Grab The Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1234    Accepted Submission(s): 779 Problem Description Little Q and…
Battle City Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty spaces, rivers,…
1013 Battle Over Cities (25 分)   It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any o…
Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty spaces, rivers, steel walls…
原题: ZOJ 3675 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3675 由m<=20可知,可用一个二进制数表示指甲的状态,最多2^20,初始状态为0,表示指甲都没剪,然后BFS找解,每次枚举剪刀的两个方向,枚举移动的位数进行扩展状态即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include &…
原题: ZOJ 3781 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3781 题意: 给一个n*m的X,O构成的格子,对一个点操作可以使与它相连通的所有一样颜色的格子翻转颜色(X->O或O->X),问给定的矩阵最少操作多少次可以全部变成一样的颜色. 网上思路: 每次操作都将本身所在的连通块与和自己相邻的不同颜色的连通块变成同一种颜色,也就是变成一个连通块了,那么要使n次操作后全部变成一样的颜色,也就是从某点出发到达…
题意—— 一个n*m的地图,从左上角走到右下角. 这个地图是一个01串,要求我们行走的路径形成的01串最小. 注意,串中最左端的0全部可以忽略,除非是一个0串,此时输出0. 例: 3 3 001 110 001 此图的最短路径为101. 输入—— 第一行输入一个整数t,表示共有t组数据. 接下来每组第一行输入两个整数n, m.表示地图的长和宽. 接下来n行,每行m个字符.字符只有0或1. 输出—— 输出一个字符串,表示最短路径. 这道题刚开始用了优先队列+大数写的bfs,然后无限爆tle,后来想…
题意:给你n个点,点带权,任意两点之间的边权是它们的点权的异或值中“1”的个数,问你该图的最小生成树. 看似是个完全图,实际上有很多边是废的.类似……卡诺图的思想?从读入的点出发BFS,每次只到改变它的任意一位所能到达的点(不论是否读入). 记录每个点是从哪个读入点BFS过来的,当第二次访问某个点的时候,就将它的两个源头(一次是第一次的时候标记的,一次是第二次过来的)连一条边. 这样最多连m(位数)*n条边,实际上比这个值更小. 这种做法可以将很多显然不会出现在最小生成树里的边排除掉. open…
题意:M行N列的矩阵.Y:起点,T:终点.S.R不能走,走B花费2,走E花费1.求Y到T的最短时间. 三种解法.♪(^∇^*) //解法一:暴力 //157MS #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<cmath> #include<queue> #include&…
题目链接:http://poj.org/problem?id=2312 题目大意:给出一个n*m的矩阵,其中Y是起点,T是终点,B和E可以走,S和R不可以走,要注意的是走B需要2分钟,走E需要一分钟.最后求解Y--->T的最短时间!! 看到这题首先想到广搜来找最短时间,但是这里可以对B和E进行处理,方便计算~ #include <iostream> #include <cstdio> #include <queue> #include <cstring>…
G.coloring tree BFS计数 题目:给你n(<=5000)个节点的一颗树 你有K(<=5000)种颜色 你可以给每一个节点染一种颜色 总共有Kn种染色方法 在一种染色方法中 定义colorness为每一对相同颜色节点距离中的最短距离 问colorness为D时 有多少种染色方案 结果%mod 解:我们先求出>=D的方案数再减去>=D+1的方案数就是==D的方案数 现在问题变为>=X的方案数 可以看成对于任意一个节点,所有和它距离小于d的节点,不能和它有相同的颜色…
题目 It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other highways to keep the rest…
acm.hdu.edu.cn/showproblem.php?pid=5542 [Accepted] #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; ; ; char str[maxn]…
B. Biridian Forest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/B Description You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through t…
Escape Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 541    Accepted Submission(s): 141 Problem Description The students of the HEU are maneuvering for their military training. The red army…
Escape Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 598    Accepted Submission(s): 153 Problem Description The students of the HEU are maneuvering for their military training.The red army a…
J - Goblin Wars Time Limit:432MS    Memory Limit:1572864KB    64bit IO Format:%lld & %llu SubmitStatusPracticeSPOJ AMR11J Description The wizards and witches of Hogwarts School of Witchcraft found Prof. Binn's History of Magic lesson to be no less bo…
The wizards and witches of Hogwarts School of Witchcraft found Prof. Binn's History of Magic lesson to be no less boring than you found your own history classes.  Recently Binns has been droning on about Goblin wars, and which goblin civilization fou…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3533 Escape Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1792    Accepted Submission(s): 529 Problem Description The students of the HEU are…
XYZ and Drops Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 505    Accepted Submission(s): 122 Problem Description XYZ is playing an interesting game called "drops". It is played on a r∗c…
Problem Description The students of the HEU are maneuvering for their military training. The red army and the blue army are at war today. The blue army finds that Little A is the spy of the red army, so Little A has to escape from the headquarters of…
Problem Description Suppose that you are an admiral of a famous naval troop. Our naval forces have got 21 battleships. There are 6 types of battleships. First, we have got one flagship in which the admiral must be and it is denoted by number 0. Other…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
传送门 Dungeon Master Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28416   Accepted: 11109 Description You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be f…
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 337    Accepted Submission(s): 273 Problem Description Erik Demaine is a Professor in Computer Science at the Massachusetts Insti…