hdu 2822 Dogs(优先队列)】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=2822 给定起点和终点,问从起点到终点需要挖几次只有从# 到 .或者从. 到  . 才需要挖一次. #include <cstdio> #include <queue> #include <cstring> using namespace std; ; int n,m; int sx,sy,ex,ey; char maze[maxn][maxn]; int vis[maxn][maxn…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2822 Dogs Description Prairie dog comes again! Someday one little prairie dog Tim wants to visit one of his friends on the farmland, but he is as lazy as his friend (who required Tim to come to his place…
题目链接:hdu2822 会优先队列话这题很容易AC.... #include<stdio.h> #include<string.h> #include<queue> #include<algorithm> #define N 1005 using namespace std; char map[N][N]; int v[N][N],d[4][2] = { {-1,0},{1,0},{0,-1},{0,1} }; int begin_x,begin_y,en…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2822 题目大意:X消耗0,.消耗1, 求起点到终点最短消耗 解题思路: 每层BFS的结点,优先级不同,应该先搜cost小的.直接退化为最短路问题. 优先队列优化. 卡输入姿势.如果O(n^2)逐个读的话会T掉.要用字符串读一行. #include "cstdio" #include "queue" #include "cstring" using…
http://acm.hdu.edu.cn/showproblem.php?pid=1509 裸的优先队列的应用,输入PUT的时候输入名字,值和优先值进队列,输入GRT的时候输出优先值小的名字和对应的值 注意的是优先级一样的时候输出顺序在前的 #include<cstdio> #include<cstring> #include<queue> using namespace std; struct point { int val,odr,num; ]; bool ope…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5875 Function Time Limit: 7000/3500 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others) 问题描述 The shorter, the simpler. With this problem, you should be convinced of this truth. You are given an…
Dogs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2208    Accepted Submission(s): 838 Problem Description Prairie dog comes again! Someday one little prairie dog Tim wants to visit one of his…
网赛的时候看了这道题,发现就是平常的那种基础搜索题. 由于加了一个特殊条件:可以一次消耗3秒或原地停留1秒. 那就不能使用简单的队列了,需要使用优先队列才行. 题意 告诉一副地图:一个起点,一个终点,若干墙,若干监视器,剩下的是空地. 起点,终点,监视器都算空地. 监视器初始值会指定一个方向,共有四个方向. 监视器每秒顺时针转动到下个方向. 监视器视野距离为2. 在监视器的位置或在监视器面向的格子是监视区域. 普通的移动一格需要消耗1秒时间. 在监视器下移动一格需要消耗3秒时间. 如果呆在原地不…
题目:http://acm.hdu.edu.cn/showproblem.php? pid=5360 题意:beta有n个朋友,beta要邀请他的朋友go hiking,已知每一个朋友的理想人数[L,R](现有L~R个人准备去,那么这个朋友就去). 求最多有多少人去. 及beta邀请朋友的顺序. 分析:每次邀请人的最优解就是:选会去的人里面R最小的那个人. 代码实现的话,cur代表已经准备go hiking的人数,每次将全部L<=cur的人放进优先队列,选出R最小的那个. 假设队列为空,那么剩下…
HDU 5289 - Assignment http://acm.hdu.edu.cn/showproblem.php?pid=5289 Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task t…