文章列表
 
您正在查看 "Acm Stl" 分类下的文章

2010-06-28 2:28
解题思路为哈夫曼树,但并不一定必须要构造一颗哈夫曼树,只需按其思想进行运行即可,运用优先队列可以很容易解此题,因为一个小的错误,WA了几次,还是粗心啊...

#include <iostream>
#inc
 
2010-06-23 0:36
描述

已知线性表中的元素递增排列,要求删除线性表内的数大于等于MIN,小于等于

MAX的,并输出删除后的线性表

要求:请使用链表做,


 
2010-06-21 19:00
 
2010-06-20 1:01
又一水题
题目内存上限为五百K
题目大意:设想一个双堆栈总空间容量为
100万个数据,现在我进行M次操作,可能是出栈,可能是入栈,希望得到最后2个堆栈的信息,输出顺序均为从栈底到栈顶输出
算法描述:如果用静态存储肯定会超内存,所以肯定用动态存储,我用两个STL的stack,为了输出又声明了一个vect
 
2010-06-10 0:44

map水过

需要注意的是不一定连在一起的字符就当成一个词,应该以非字母符号为分隔符

#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, string>m;
string s0, s1, s;
int main()
{
freopen("in.txt","r",stdin);
cin>>s0>>s0;
while (s0!="END")
{
   cin>>s1;
   m[s1]=s0;
   cin>>s0;

 
2010-06-03 1:28
算法描述: 优先队列

注意: 使用优先队列的时候,我先用了一个比较函数
bool operator() ( const Info &a, const Info &b)
{
if (a.val==b.val)
return a.id<b.id;
return a.val<b.val;
}
但是后来向优先队列里面添加新成员的时间编辑器会报错,试了几个编辑器也不行,后来把比较函数换为
bool operator<(const Info &a)const
{
if (a.val==val)
return  a.id < id;
return  a.val < val;
}
就不报错了。想想这应该是C++的内
 
2010-05-28 17:20
算法描述:先对每个人用map哈希成所对应的党派, 然后再输入抽票支持的每个人。这时再把每个人哈希成一个数字,数字表示支持的人数,注意要处理平局的情况,一次AC的感觉真爽
#include <iostream>
#include <string>
#include <map>
using namespace std;
string name, party;
int    n, m;
map<string, string>ma;
map<string, int>ma2;
char  ch[100];
int main( )
{
freopen("in.txt","r",stdin);
cin
 
2010-05-28 16:49
用一个map哈希字符串即要可,输入的时候一个字符串的输入。
#include <iostream>
#include <string>
#include <map>
using namespace std;
const int maxn=1010;
char     ch[maxn];
int        w,  totprice;
int        m,  n;
map<string, int>ma;
int main()
{
freopen("in.txt", "r",stdin);
cin>>m>>n;
 
2010-05-28 13:36
算法描述:用map进行哈希。因为如果有相同的分数,“LI Ming“要排在分类一样的同学的最前面。这里为了避免处理麻烦。我直接哈希成double型,然后每次都对李明的分类加一个小数(当然这里的小数也不能乱加。必须得根据题目控制好精度. 最后直接统计,复杂度为O(n*m*log(n))
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string, double>m;
int   n,  num;
int       score;
string  na
 
2010-05-27 14:10
http://coder.buct.edu.cn/oj/Problem.aspx?pid=1067

此题我用set做的。虽然能过但是代码带有一点茫目性。
#include <iostream>
#include <set>
using namespace std;
set<__int64>st;
set<__int64>s;
__int64  ans[1510];
int  flag[3]={2, 3, 5}, n;
int main()
{
__int64  t;
bool f = false;
freopen("in.txt","r",stdin);
st.insert(1);    s.insert(1);
for (int i=1;; i++)
{
 
 
   
 
 
文章存档
 
     
 
最新文章评论
  

条理很清晰
 

什么是多重队列?跪求!!!
 

orz ...
 

请问这个代码,错在什么地方了?一直是 running time error 我是不是少考虑了什么条
 

#include<iostream> #include<algorithm> #include<string.h> using namespace std;
   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu