题目链接: Hdu 5336 XYZ and Drops 题目描述: 有一个n*m的格子矩阵,在一些小格子里面可能会有一些水珠,每个小水珠都有一个size.现在呢,游戏开始咯,在一个指定的空的小格子里面有一个将要向四周爆裂的水珠,在下一面分别向上,下,左,右四个方向发射一个小水滴,(小水滴与水珠同,小水滴没有size),当小水滴走向一个格子,这个格子如果是空或者有其他的小水滴同时走到这个格子的情况下,对小水滴的运动轨迹是不影响的.但是遇到水珠的话,小水滴就会被吸收,水珠每次吸收一个小水滴size…
XYZ and Drops Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1250    Accepted Submission(s): 407 Problem Description XYZ is playing an interesting game called "drops". It is played on a r∗…
题目链接:http://i.cnblogs.com/EditPosts.aspx?opt=1 Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7909    Accepted Submission(s): 2498 Problem Description Farmer John has been inform…
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 XYZ is playing an interesting game called "drops". It is played on a r∗c grid. Each grid cell is either empty, or occupied by a waterdrop. Each waterdrop has a property "size". The waterdrop cracks when its size is…
这题的题意是给你一幅图,图里面有水滴.每一个水滴都有质量,然后再给你一个起点,他会在一開始的时候向四周发射4个小水滴,假设小水滴撞上水滴,那么他们会融合,假设质量大于4了,那么就会爆炸,向四周射出质量为一的水滴,问你在T时刻的时候,各个水滴的状态. #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <math.h> #i…
胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23779    Accepted Submission(s): 9125 Problem Description Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩…
题目: The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to change such things every now and then,…
题目链接 Problem Description Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个ABC的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-1)的位置,现在知道魔王将在T分钟后回到城堡,Ignatius每分钟能从一个坐标走到相邻的六个坐标中的其中一个.现在给你城堡的地图,请你计算出Ignatius能否在魔王回来前离开城堡(只要走到出口就算…
图的深搜与广搜 复习下二叉树.图的深搜与广搜. 从图的遍历说起.图的遍历方法有两种:深度优先遍历(Depth First Search), 广度优先遍历(Breadth First Search),其经典应用走迷宫.N皇后.二叉树遍历等.遍历即按某种顺序訪问"图"中全部的节点,顺序分为: 深度优先(优先往深处走),用的数据结构是栈, 主要是递归实现. 广度优先(优先走近期的).用的数据结构是队列.主要是迭代实现. 对于深搜.因为递归往往能够方便的利用系统栈,不须要自己维护栈.所以通常实…
luoguP4112 [HEOI2015]最短不公共子串 链接 luogu loj 思路 子串可以用后缀自动机,子序列可以用序列自动机. 序列自动机是啥,就是能访问到所有子序列的自动机. 每个点记录下一个字母最近出现的位置.不过我这里构造是\(O(n^2)\). 然后进行bfs进行广搜就行了. 注意vis[][]剪枝,要不TLE. 代码 #include <bits/stdc++.h> #define ll long long using namespace std; const int N=…
题意:一个四位数的质数,每次只能变换一个数字,而且变换后的数也要为质数.给出两个四位数的质数,输出第一个数变换为第二个数的最少步骤. 利用广搜就能很快解决问题了.还有一个要注意的地方,千位要大于0.例如0373这个数不符合要求. #include <iostream> #include <cstdio> #include <queue> #include <cmath> #include <map> using namespace std; st…
非常可乐 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 42   Accepted Submission(s) : 21 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548 There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if yo…
题目链接 Problem Description 给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去.令人头痛的是,gloria是个没什么方向感的人,因此,她在行走过程中,不能转太多弯了,否则她会晕倒的.我们假定给定的两个位置都是空地,初始时,gloria所面向的方向…
就是在输入的时候把 ‘o’ 的放在队里,然后,直接BFS就可以了.感觉是水题. #include<iostream> #include<queue> using namespace std; #define pa pair<int, int> ; char cc[maxn][maxn]; , , -, , }; , , , , - }; char kk[] = " udlr"; int n, m, ans; queue<pa>q; int…
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:id=3414">http://poj.org/problem? id=3414 此题和poj1606一样 :http://blog.csdn.net/u012860063/article/details/37772275 Description You are given two pots, having the volume of A and B liters…
Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the mo…
题目链接 Problem Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He think…
极其简陋的BFS模板 void BFS(???){ queue<node>q; node start, next; start = ???; q.push(start); while(!q.empty()){ start = q.front(); q.pop(); //一系列迷幻操作 next = ???; if(???) q.push(next); } }…
题意:从S出发,去抓每一个A,求总路径最短长度.在S点和A点人可以分身成2人,不过一次只能让一个人走. 思路是先利用BFS求出各点之间的距离,建成图,再套用最小生成树模板. 一次性A了.不过觉得在判断第几个编号的点时稍显麻烦了. #include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; const int inf=1000000…
Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10541    Accepted Submission(s): 3205Special Judge Problem Description The Princess has been abducted by the BEelzebub…
Rescue Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 14   Accepted Submission(s) : 7 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Angel was caught by the MOLIGPY…
Open the Lock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3847    Accepted Submission(s): 1661 Problem Description Now an emergent task for you is to open a password lock. The password is co…
Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6383    Accepted Submission(s): 2034 Problem Description Farmer John has been informed of the location of a fugitive cow and wants…
诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 7642    Accepted Submission(s): 1830 Problem Description Hogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在竖直…
Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3226    Accepted Submission(s): 1045 Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally.…
BFS广搜题目有时间一个个做下来 2009-12-29 15:09 1574人阅读 评论(1) 收藏 举报 图形graphc优化存储游戏 有时间要去做做这些题目,所以从他人空间copy过来了,谢谢那位大虾啦. pku 1175 Starry Night 题目地址:http://acm.pku.edu.cn/JudgeOnline/problem?id=1175 解法:BFS,要注意的是如何判断图形是一样的,我的做法就是计算每两个点的距离之和. 看:http://hi.baidu.com/doxi…
Combine String HDU - 5707 题目大意:给你三个串a,b,c,问a和b是不是恰好能组成c,也就是a,b是不是c的两个互补的子序列. 根据题意就可以知道对于c的第一个就应该是a第一个或者b的第一个,如果第一个是a的第一个,那么c的第二个就应该是a的第二个或者是b的第一个,反之也是一样的.那么我们定义dp[i][j]就是a串匹配到i位置,b串匹配到j位置的合理性,那么dp[i][j]就由dp[i-1][j]和dp[i][j-1]推过来,a串匹配到i位置,b串匹配到j位置,那么c…
题目链接:http://acm.hust.edu.cn/vjudge/contest/128683#problem/E 题目大意:给定一只含有0和1的地图,0代表可以走的格子,1代表不能走的格 子.之后过了M年,每年把一个格子变成1, 即每年会有一个格子不能走.问地 图上界和下界连通共多少年.如果到M年之后依然连通,则输出-1. 给定的年份数据范围是10^5, 图的大小是500*500,由于图是一直在改变的, 因此每次都需要进行变更操作.然而如果变更一次广搜一次明显会TLE.仔细思 考会发现,当…