摘要: #include<iostream>#include<cstring>#include<string>#include<map>#include<stdio.h>using namespace std;int main(){ map<string,string> d; char str1[12],str2[12],str[30]; while(gets(str)) { if(strlen(str)==0) break; sscanf(str,"%s %s",str1,str2); d[str2]=str 阅读全文
posted @ 2011-07-10 19:55 Crazy_yiner 阅读(1071) 评论(0) 推荐(0) 编辑
摘要: 一大早我们就打车到了吉大,感觉吉大本校比东师要大,至少比净月校区要大一些。一行人在吉大里走错一会之后总算找到了体育馆,来的有点早,带队老师这时候还没到,我们在体育馆门外等候老师驾到~_~做在体育馆稳外的台阶上,还安队伍排好了队形(各种风景呀)。。。上午热身赛三道题,一共有三道题,第一题给了个0 1矩阵 求最大的全1子矩阵,zs和xzy在那想,我在看别的题,最后zs想出把0赋值为个很小的数的最大子矩阵算法,套模版过之~还有一道字符串,安一定的顺序输出,秒。。。剩下一道题记不清了中午吉大请吃自助(学院交过钱的。。。),饭菜相当不错。下午正式比赛,一开始zs和xzy看A 觉得有思路,zs在那敲,看到 阅读全文
posted @ 2011-06-03 22:16 Crazy_yiner 阅读(727) 评论(4) 推荐(0) 编辑
摘要: 0-1 背包有N件物品和一个容量为m的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。特点:每种物品仅有一件,可以选择放或不放。void ZeroOnePack(int cost, int weight){ for (int i = m; i >= cost; i--) dp[i] = max(dp[i], dp[i-cost] + weight);}完全背包有N种物品和一个容量为V的背包,每种物品都有无限件可用。第i种物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。特点:每种物品 阅读全文
posted @ 2011-05-26 16:25 Crazy_yiner 阅读(340) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<set>#include<algorithm>#include<stdio.h>#include<cstring>using namespace std;int d[301];int c[50001];int e[50001];bool cmp(const int x,const int y){ return x<y;}set<int> s;int main(){int t;scanf("%d",&t);for(int l=1;l< 阅读全文
posted @ 2011-05-25 17:41 Crazy_yiner 阅读(225) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>#include<vector>#include<algorithm>using namespace std;int main(){ vector<int> v(3,5);//创建长度为3 初值为5的向量 //v[0]=0;数组下标给向量元素赋值 无法动态增加向量长度 v[0]=1;//有下标方式改变向量内元素值 v.push_back(2);//用push_back方法向向量尾部添加元素 动态增加向量长度 v.push_back(3); v.push_back(4 阅读全文
posted @ 2011-05-24 20:45 Crazy_yiner 阅读(168) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include<cstdio>#include<map>#include<algorithm>#include<string>using namespace std;int par[5000],n,m;struct In{ int from,to,len;}s[100000];bool cmp(In a,In b){ return a.len<b.len;}void init(){ int i; for(i=1;i<=n;i++)par[i]=i;}int getr(int x){ 阅读全文
posted @ 2011-05-24 11:26 Crazy_yiner 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Dijkstra 算法单源最短路径define INF=正无穷w[x][y]表示边不存在(x,y)memset(v,0,sizeof(v));//将所有点标记为没有进入集合for(int i=1;i<=n;i++) d[i]=(i==0?0:INF);//0为源点 到本身到距离为0 其余点到源点到距离为正无穷for(int i=1;i<=n;i++){ int x,m=INF; for(int y=1;y<=n;y++)//选取到源点最的点 if(!v[y]&&d[y]<=m) { m=d[y]; x=y; } v[x]=1;//点x到最短路径已经找到 阅读全文
posted @ 2011-05-19 20:23 Crazy_yiner 阅读(578) 评论(0) 推荐(1) 编辑
摘要: SkyscraperDescriptionThe Build n' Profit construction company is about to build its tallest building. It will be huge, the tallest building in the world by a wide margin. It will house hundreds of thousands of people and have rocket-powered elevators to the upper floors. They even plan for a shu 阅读全文
posted @ 2011-05-16 23:33 Crazy_yiner 阅读(498) 评论(0) 推荐(0) 编辑
摘要: Median Weight BeadDescriptionThere are N beads which of the same shape and size, but with different weights. N is an odd number and the beads are labeled as 1, 2, ..., N. Your task is to find the bead whose weight is median (the ((N+1)/2)th among all beads). The following comparison has been perfor. 阅读全文
posted @ 2011-05-16 23:32 Crazy_yiner 阅读(436) 评论(0) 推荐(0) 编辑
摘要: Travelling TomTom is a used popsicle salesman. His recent sales at his stand on Gloshaugen haven't been very good, so he's decided that he wants to travel the world selling his merchandise. He has already compiled a list of cities to visit, and have also gathered the costs of the plane trip 阅读全文
posted @ 2011-05-16 23:31 Crazy_yiner 阅读(398) 评论(0) 推荐(1) 编辑