2012年9月21日

0-1背包 系列问题

摘要: hdu 1203I NEED A OFFER!Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit StatusDescriptionSpeakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内 阅读全文

posted @ 2012-09-21 11:20 yumao 阅读(213) 评论(0) 推荐(0) 编辑

2012年9月14日

图论 最短路 poj 1062

摘要: 昂贵的聘礼Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 27723Accepted: 7777Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东 阅读全文

posted @ 2012-09-14 22:43 yumao 阅读(299) 评论(0) 推荐(0) 编辑

2012年9月5日

二维DP 建房子

摘要: 题目要求: 求最大正方形边长: 输入a[][];为1则可以建房,为0则不可建房,求可以建房的最大正方形边长。 子问题:dp[i][j] 表示以a[i][j]为左上角的正方形的最大边长。 Dp[i][j]=min{dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}+1可以从最尾端开始。 最后的答案为dp[][]中的最大值。代码实现:View Code 1 #include<iostream> 2 using namespace std; 3 int dp[100][100]; //dp[i][j] means start by a[i][j],the la.. 阅读全文

posted @ 2012-09-05 21:52 yumao 阅读(320) 评论(0) 推荐(0) 编辑

STl 中set的用法

摘要: set为集合其特征就是集合中没有相同的元素所以在要求去重时,可以用到集合。基本用法: set <int> sett; 初始化 sett.insert(1); 插入元素(如果集合中存在此元素,则相当于这个操作无效) sett.find(2); 这个函数还有接下来的begin(),end()等,都返回的是迭代器;如果可以找到2,那么返回的迭代器的值为2,如果找不到,则返回end()的值 set <int> ::iterator it1 迭代器 set.erase(2);删除集合中的元素2,如果集合中没有这个元素,则操作无效,另外也可以是迭代器。 for(it1=sett.b 阅读全文

posted @ 2012-09-05 21:49 yumao 阅读(166) 评论(0) 推荐(0) 编辑

线段树优化 lazy算法 poj3468

摘要: A Simple Problem with IntegersTime Limit: 5000MSMemory Limit: 131072KTotal Submissions: 35742Accepted: 10240Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a gi 阅读全文

posted @ 2012-09-05 21:30 yumao 阅读(2891) 评论(0) 推荐(0) 编辑

线段树的实现(求段和)

摘要: View Code 1 #include<iostream> 2 #include<stdio.h> 3 using namespace std; 4 struct node{ 5 int r; //root to the right's range 6 int l; 7 node * rt; //the subtree of root's right 8 node * lt; 9 __int64 key; //the value of the root,... 阅读全文

posted @ 2012-09-05 21:11 yumao 阅读(190) 评论(0) 推荐(0) 编辑

DP poj 2192

摘要: ZipperTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 13247Accepted: 4655DescriptionGiven three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in it 阅读全文

posted @ 2012-09-05 21:02 yumao 阅读(177) 评论(0) 推荐(0) 编辑

DFS poj 3009

摘要: Curling 2.0Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7141Accepted: 2991DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. 阅读全文

posted @ 2012-09-05 20:50 yumao 阅读(169) 评论(0) 推荐(0) 编辑

2012年9月4日

DFS 剪枝1 poj 1011

摘要: SticksTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 100527Accepted: 22858DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originall 阅读全文

posted @ 2012-09-04 19:40 yumao 阅读(318) 评论(0) 推荐(0) 编辑

2012年8月31日

回文串 poj 1159

摘要: PalindromeTime Limit: 3000MSMemory Limit: 65536KTotal Submissions: 43607Accepted: 14862DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal number 阅读全文

posted @ 2012-08-31 09:10 yumao 阅读(420) 评论(0) 推荐(0) 编辑

导航