POJ 2227 FloodFill (priority_queue)】的更多相关文章

题意: 思路: 搞一个priority_queue 先把边界加进去 不断取最小的 向中间扩散 //By SiriusRen #include <queue> #include <cstdio> #include <cstring> using namespace std; #define int long long struct Node{int h,x,y;Node(int a,int b,int c){h=a,x=b,y=c;}}; priority_queue&l…
思路描述来自:http://hi.baidu.com/perfectcai_/item/701f2efa460cedcb0dd1c820也可以参考黑书P89的积水. 题意:Farmer John有一个碗,形状如下,给你一个w*h平面,每个1*1的位置有一个高度Hij,问用这个碗来装牛奶,最多可以装多少体积.例如:555515555这个可以装4体积,只有中间的1位置可以装:再如:555512555这个可以装1体积,只有中间的1位置可以装,而装到2时就会开始漏出,因为液体是可以流动的: 分析:由例子…
思路:正向建边,一遍Dijkstra,反向建边,再一遍Dijkstra.ans加在一起输出最大值. (SPFA也行--) // by SiriusRen #include <queue> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 1005 int n,m,X,tot=0,maxx=0,first[N],v[N*N],w[N*…
题意: 思路: 贪心 能不覆盖的就不盖 写得很乱 左闭右开的 temp //By SiriusRen #include <queue> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n,l,temp,ans; struct Node{int from,to;}node[10050]; priority_queue<Node>pq…
Expedition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18655   Accepted: 5405 Description A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed t…
POJ 3297 算法竞赛初级杂烩包 题意:学生选课,没个学生只能选一门课.大写字符是课的名字,小写是人名.如果课程后面有多个相同名字算一个,如果一个人选多门课,则他选不上课,输出课和每门课选课人数 思路: map<string,set<int> > stu:一个学生名对应他选了哪几门课 map<string,ser<int> > pro:课程名对应有几个学生选了他,set存对应的学生 vector<pair<int,string> >…
sort()函数的cmp为函数,priority_queue的cmp为类,具体写法是: struct Node { int i,j; } node[]; struct cmp { bool operator() (Node a,Node b) { if(a.i==b.i) return a.j<b.j;///j的升序 return a.i<b.i; ///i的升序 } }; priority_queue<Node,vector<Node>,cmp> re; #inclu…
Fence Repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 40465   Accepted: 13229 Description Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000)…
思路: 贪心?就算是吧 先把所有的开始时间排个序 如果当前的能匹配上已有的牛栏,就找开始时间最早的那个. 否则新加一个牛栏 整个过程用priority_queue实现就OK了.. //By SiriusRen #include <queue> #include <cstdio> #include <algorithm> using namespace std; int n,t=1,s[55555]; struct Node {int pos,begin,end;}nod…
Oil Deposits The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It…