#include<stdio.h> #include<string.h> #include<queue>//水杯盛水问题,用优先队列不断从最小的边缘开始 using namespace std; int n,m; #define N 400 int p[N][N]; struct node { int x,y,w; friend bool operator<(node a,node b) {//优先队列 return a.w>b.w;//从小到…
坦克大战 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描写叙述 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…
Nightmare 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial…
/** http://acm.nyist.net/JudgeOnline/problem.php?pid=547 题意: 有一个正方形的区域 区域上面有高度不同的1*1的立方体自然有凸有凹 凹的地方可以储水 问一共可以储存多少水 分析: 每次都从最低的边界向内部注水(仅与边界相邻的内部) 如果能够注水 就把注水后的柱子当作新的边界 也就是把边界放到一个优先队列中 每次都让高度最小的边界出队(优先队列) */ include include include using namespace std;…
山治的婚约 Description 我们知道,山治原来是地下有名的杀人家族文斯莫克家族的三子,目前山治的弟弟已经出现,叫做四治,大哥二哥就叫汪(One)治跟突(Two)治好了(跟本剧情无关) .山治知道自己跟夏洛特家族有婚约之时,决定参加大妈的茶会,跟父亲做个了断.然而夏洛特公主早已看穿了一切,她给山治出了个难题,如果山治能够解决难题,夏洛特公主就帮助山治解除婚约.公主安排了 N 只拿着蛋糕的猴子,排成一列,每只猴子都有自己的初始位置 Pi 和行动量 Di,山治从前往后夺取猴子的蛋糕,因为光谱踢…
按照Java api的说法: java.util.PriorityQueue.PriorityQueue() Creates a PriorityQueue with the default initial capacity (11) that orders its elements according to their natural ordering. 优先队列PriorityQueue的默认排序方式为其中元素的自然顺序.下面利用这一特点,把它当成个小顶堆来求出数组中的前k大元素 packa…
这里之所以扩充一个 有限队列 是因为,生活使用中队列通常会附加优先级,比如排队买票,一般老人和军人等会有优先权限. 实现:继承上篇的 普通队列实现.这里用一种方法,入队的时候,进行排序插入到指定位置,输出不变. 优先队列类 //继承自 Queue function PriorityQueue(){ Queue.call(this); } 继承原型方法 function base(p, c){ var h = {}, P = p.prototype, C = c.prototype; for(va…
Waiting ten thousand years for Love Time Limit: 10000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1057 Accepted Submission(s): 335 Problem Description It was ten thousand years, after Demon Lemon caught Y…
Rescue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 27406 Accepted Submission(s): 9711 Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is d…