Entropy (huffman) 优先队列)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1053Huffman问题利用STL中的priority_queue解决; 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 struct cmp10 {11 bool operator()(const int a, const int b)12 {13 return a > b;14 }15 };16 int solve(string...
阅读全文
posted @
2013-09-20 18:43
straw_berry
阅读(262)
推荐(0)
Sequence
摘要:DescriptionGiven m sequences, each contains n non-negative integer. Now we may select one number from each sequence to form a sequence with m integers. It's clear that we may get n ^ m this kind of sequences. Then we can calculate the sum of numbers in each sequence, and get n ^ m values. What w
阅读全文
posted @
2013-07-30 15:02
straw_berry
阅读(217)
推荐(0)
refresh的停车场
摘要:题目描述refresh最近发了一笔横财,开了一家停车场。由于土地有限,停车场内停车数量有限,但是要求进停车场的车辆过多。当停车场满时,要进入的车辆会进入便道等待,最先进入便道的车辆会优先进入停车场,而且停车场的结构要求只出去的车辆必须是停车场中最后进去的车辆。现告诉你停车场容量N以及命令数M,以及一些命令(Add num 表示车牌号为num的车辆要进入停车场或便道,Del 表示停车场中出去了一辆车,Out 表示便道最前面的车辆不再等待,放弃进入停车场)。假设便道内的车辆不超过1000000.输入首先输入N和M(0< n,m <200000),接下来输入M条命令。输出输入结束后,如果出现停车场内
阅读全文
posted @
2013-06-22 21:34
straw_berry
阅读(309)
推荐(0)
双向队列 STL
摘要:题目描述 想想双向链表……双向队列的定义差不多,也就是说一个队列的队尾同时也是队首;两头都可以做出队,入队的操作。现在给你一系列的操作,请输出最后队列的状态;命令格式:LINXX表示一个整数,命令代表左边进队操作;RINX表示右边进队操作;ROUTLOUT表示出队操作;输入第一行包含一个整数M(M 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 int n,wrong[101],c,x;10 char s[10];11 dequedque;12 c =...
阅读全文
posted @
2013-06-22 20:55
straw_berry
阅读(295)
推荐(0)
栈与队列的pop和push
摘要:E -ACboy needs your help again!Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionACboy was kidnapped!!he miss his mother very much and is very scare now.You can't image how dark the room he was put into is, so poor :(.As a smart ACMer, you want to get A
阅读全文
posted @
2013-03-22 21:18
straw_berry
阅读(439)
推荐(0)
hdoj-1022 Train Problem I
摘要:#include#include#includeusing namespace std;int main (){ int n,i,j,c; int d[100]; string a,b; while(cin>>n>>a>>b) { i=j=c=0; stack st; int tag=1; while(j<n) { if(a[i]==b[j]) { i++; j++; ...
阅读全文
posted @
2013-03-22 20:13
straw_berry
阅读(179)
推荐(0)