HDU2216:Game III(BFS)】的更多相关文章

Game III Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 31   Accepted Submission(s) : 11 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Zjt and Sara will take part…
Game III Problem Description Zjt and Sara will take part in a game, named Game III. Zjt and Sara will be in a maze, and Zjt must find Sara. There are some strang rules in this maze. If Zjt move a step, Sara will move a step in opposite direction.Now…
题意 输入两个正规表达式,判断两者是否相交(即存在一个串同时满足两个正规表达式).本题的正规表达式包含如下几种情况: 单个小写字符 $c$ 或:($P | Q$). 如果字符串 $s$ 满足 $P$ 或者满足 $Q$,则 $s$ 满足 $(P| Q)$ 连接:($PQ$). 如果字符串 $s_1$ 满足 $P$,$s_2$ 满足 $Q$,则 $s_1s_2$ 满足 $(PQ)$ 克莱因闭包:$(P^*)$. 如果字符串 $s$ 可以写成0个或多个字符串 $s_i$ 的连接 $s_1s_2...$…
http://acm.hdu.edu.cn/showproblem.php?pid=2216 zjt和sara在同一个地图里,zjt要去寻找sara,zjt每移动一步sara就要往相反方向移动,如果他们相邻或者在同一个格子里就算相遇. 输出最少步数.注意zjt每次必须要有能移动的点才移动,否则不能移动,但是sara没有能移动的点的话可以呆着不动. 用结构体保存两个点和相应的步数作为一个状态,然后用哈希函数映射出每一个状态的的哈希值,放入set中,判重. 注意哈希函数的选取要确保不能重复. #in…
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all hou…
//点和线段树都从1开始 //边使用vector vector<int> G[maxn]; ],num[maxn],iii[maxn],b[maxn],a[maxn],top[maxn],deep[maxn],fa[maxn],idx[maxn]; //采用静态链表 //a[i] 是初始时树上每个点的权值 //b[i] 是经过bfs后每个点的权值 //idx[i] 是每个点在全局线段树中的下标 void build_List() { , rear = ; que[rear++] = ; fa[…
又是类似骑士拯救公主,不过这个是朋友拯救天使的故事... 不同的是,天使有多个朋友,而骑士一般单枪匹马比较帅~ 求到达天使的最短时间,杀死一个护卫1 units time , 走一个格子 1 unit time .SO,杀死一个护卫到达那个格子 2units time. 第一反应是广搜,就搜咧 = =.. WA了,交hdu上 AC了,hdu数据真弱啊... 想了想,想通了,因为一般广搜的话必须都是1个时间才能搜,才能保证这个BFS树是等距离向外伸展的,而这个不是等距离的,所以需要一些处理. 1.…
Strobogrammatic Number A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as a string. For example, the nu…
HDU 3277 Marriage Match III 题目链接 题意:n个女孩n个男孩,每一个女孩能够和一些男孩配对,此外还能够和k个随意的男孩配对.然后有些女孩是朋友,满足这个朋友圈里面的人.假设有一个能和某个男孩配对,其它就都能够.然后每轮要求每一个女孩匹配到一个男孩,且每轮匹配到的都不同.问最多能匹配几轮 思路,比HDU3081多了一个条件,此外能够和k个随意的男孩配对.转化为模型,就是多了一个结点,有两种两边的方式.一种连向能够配对的,一种连向不能配对的.此外还要保证流量算在一起,这要…
1119 AlvinZH's Fight with DDLs III 思路 难题,最小点覆盖. 分析题意,某一个任务,既可以在笔记本A的 \(a\) 模式下完成,也可以在笔记本B的 \(b\) 模式下完成.如果笔记本A处于x模式,那么所有可以在笔记本x模式的任务可以一起完成,B同理.这两句话作为题目核心,该如何转化呢? 对于每个任务对应的(a,b),我们把它映射到平面坐标当中,明显发现,此题和二营长,你他娘的意大利炮呢简直一模一样.其实就是一个最小点覆盖问题,也就是最大二分图匹配问题. 关于最小…