11 2013 档案
Minimum Cost(最小费用最大流)
摘要:DescriptionDearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K different kinds of goods (marked from 1 to K). Once s 阅读全文
posted @ 2013-11-30 22:00 straw_berry 阅读(889) 评论(0) 推荐(0)
Electrification Plan(最小生成树)
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=50#problem/D最小生成树模板,注意的是这里有k个发电站,它们不再需要连接其他的发电站,所以任何两个发电站之间的权值是0; 1 #include 2 #include 3 const int maxn = 110; 4 const int INF = 0x3f3f3f3f; 5 int map[maxn][maxn],power[maxn]; 6 int n,k; 7 8 void prim() 9 {10 int dis[maxn],vis[maxn];11... 阅读全文
posted @ 2013-11-30 17:29 straw_berry 阅读(248) 评论(0) 推荐(0)
Is the Information Reliable?(差分约束)
摘要:DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line withNdefense stations. Because of the cooperation of the stations, Zibu’s Marine Glory cannot march any further but stay out 阅读全文
posted @ 2013-11-29 21:48 straw_berry 阅读(272) 评论(0) 推荐(0)
TC598 div2
摘要:题意:给一些物品item[],这些物品的重量在101至300之间,要将这些物品全部放进若干个bins中,已知bins盛的重量为300,可以将bins装满也可以不装满,问放这些物品最少需要几个bins.思路:当时把最关键的地方忽略了,就是物品的重量在101至300之间,这就说明每个bins至多放2个物品。然后从小到大排序,倒着贪心就可以了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 class BinPackingEasy10 {11 private:. 阅读全文
posted @ 2013-11-29 14:23 straw_berry 阅读(247) 评论(0) 推荐(0)
King(差分约束)
摘要:http://poj.org/problem?id=1364题意真心看不大懂啊。。。现在假设有一个这样的序列,S={a1,a2,a3,a4...ai...at}其中ai=a*si,其实这句可以忽略不看现在给出一个不等式,使得ai+a(i+1)+a(i+2)+...+a(i+n)ki首先给出两个数分别代表S序列有多少个,有多少个不等式不等式可以这样描述给出四个参数第一个数i可以代表序列的第几项,然后给出n,这样前面两个数就可以描述为ai+a(i+1)+...a(i+n),即从i到n的连续和,再给出一个符号和一个ki当符号为gt代表‘>’,符号为lt代表‘02 2 lt 2a2+a3+a40 阅读全文
posted @ 2013-11-26 20:02 straw_berry 阅读(327) 评论(0) 推荐(0)
C - Point on Spira
摘要:Time Limit:2000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeCodeForces 279ADescriptionValera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments:[(0, 0),  阅读全文
posted @ 2013-11-26 17:16 straw_berry 阅读(219) 评论(0) 推荐(0)
Intervals(差分约束)
摘要:http://poj.org/problem?id=1201题意:给出N个整数区间[ai,bi],并且给出一个约束ci,( 1= ci个,求出数组Z的最小长度。思路:建立差分约束系统。因为这里要求数组长度的最小值,要变为x-y>=k的标准形式。设数组 s[j] 表示数组 Z 区间[0,j]里包含的元素个数。所以 s[bi+1] - s[ai] >= ci,注意是 j+1,隐含条件 0 = ci;s[i+1] - s[i] >= 0;s[i] - s[i+1] >= -1;然后邻接表建图求最长路。 1 #include 2 #include 3 #include 4 #i 阅读全文
posted @ 2013-11-24 19:31 straw_berry 阅读(459) 评论(0) 推荐(0)
Books
摘要:DescriptionWhen Valera has got some free time, he goes to the library to read some books. Today he's gottfree minutes to read. That's why Valera tooknbooks in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 ton 阅读全文
posted @ 2013-11-23 21:24 straw_berry 阅读(291) 评论(0) 推荐(0)
大数A-B
摘要:还没写过大数减法,今天比赛还WA了两次。。。 1 #include 2 #include 3 using namespace std; 4 5 void sub(string a, string b) 6 { 7 string tmp,ans = "",c = ""; 8 int flag = 0;//借位 9 int k = 0;10 bool flag1 = false;//判断是否加负号11 12 if(a.length() = 0 && j >= 0)22 {23 if(a[i] + flag > b[j])24 .. 阅读全文
posted @ 2013-11-23 17:34 straw_berry 阅读(268) 评论(0) 推荐(0)
Candies(差分约束)
摘要:http://poj.org/problem?id=3159题意:flymouse是幼稚园班上的班长,一天老师给小朋友们买了一堆的糖果,由flymouse来分发,在班上,flymouse和snoopy是死对头,两人势如水火,不能相容,因此fly希望自己分得的糖果数尽量多于snoopy,而对于其他小朋友而言,则只希望自己得到的糖果不少于班上某某其他人就行了。比如A小朋友强烈希望自己的糖果数不能少于B小朋友m个,即B- A 2 #include 3 #include 4 using namespace std; 5 6 const int INF = 0x3f3f3f3f; 7 const in. 阅读全文
posted @ 2013-11-22 22:01 straw_berry 阅读(336) 评论(0) 推荐(0)
Constructing Roads(SPFA+邻接表)
摘要:题目描述 Long long ago, There was a country named X, the country has N citieswhich are numbered from 1 to N. The king of Country-X wants to construct some roads. Please note that Country-X is blessed by an angel. He(The angel is a boy? This is no science, but do not care about those details, this ange.. 阅读全文
posted @ 2013-11-22 18:55 straw_berry 阅读(209) 评论(0) 推荐(0)
Coach(并查集)
摘要:DescriptionA programming coach hasnstudents to teach. We know thatnis divisible by3. Let's assume that all students are numbered from1ton, inclusive.Before the university programming championship the coach wants to split all students into groups of three. For some pairs of students we know that 阅读全文
posted @ 2013-11-16 19:53 straw_berry 阅读(615) 评论(0) 推荐(0)
Invitation Cards(邻接表+逆向建图+SPFA)
摘要:Time Limit:8000MSMemory Limit:262144KTotal Submissions:17538Accepted:5721DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They have printed inv 阅读全文
posted @ 2013-11-12 21:56 straw_berry 阅读(413) 评论(0) 推荐(0)
Rectangle and Square(判断正方形、矩形)
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=42#problem/D改了N多次之后终于A了,一直在改判断正方形和矩形那,判断正方形时算出六条边再排序,若前四条边相等并且与后两条边满足勾股定理,说明是正方形,判断矩形时,我先对结构体二级排序,这样四个点有确定的顺序,再用点积判断是否有三个角是直角,是的话就是矩形。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 struct node 7 { 8 int x,y; 9 }po... 阅读全文
posted @ 2013-11-10 20:38 straw_berry 阅读(447) 评论(0) 推荐(0)
zoj 3088 Easter Holidays(最长路+最短路+打印路径)
摘要:Scandinavians often make vacation during the Easter holidays in the largest ski resort Are. Are provides fantastic ski conditions, many ski lifts and slopes of various difficulty profiles. However, some lifts go faster than others, and some are so popular that a queue forms at the bottom.Per is a be 阅读全文
posted @ 2013-11-08 21:31 straw_berry 阅读(350) 评论(0) 推荐(0)
AOE网上的关键路径(最长路径 + 打印路径)
摘要:题目描述 一个无环的有向图称为无环图(Directed Acyclic Graph),简称DAG图。 AOE(Activity On Edge)网:顾名思义,用边表示活动的网,当然它也是DAG。与AOV不同,活动都表示在了边上,如下图所示: 如上所示,共有11项活动(11条边),9个事件(9个顶点)。整个工程只有一个开始点和一个完成点。即只有一个入度为零的点(源点)和只有一个出度为零的点(汇点)。 关键路径:是从开始点到完成点的最长路径的长度。路径的长度是边上活动耗费的时间。如上图所示,1到2到5到7到9是关键路径(关键路径不止一条,请输出字典序最小的),权... 阅读全文
posted @ 2013-11-08 17:27 straw_berry 阅读(2348) 评论(0) 推荐(0)
Going Home(最小费用最大流)
摘要:Time Limit:1000MSMemory Limit:65536KTotal Submissions:16200Accepted:8283DescriptionOn a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel 阅读全文
posted @ 2013-11-08 11:24 straw_berry 阅读(224) 评论(0) 推荐(0)
Integer Intervals(贪心)
摘要:Time Limit:1000MSMemory Limit:10000KTotal Submissions:12123Accepted:5129DescriptionAn integer interval [a,b], a 2 #include 3 #include 4 using namespace std; 5 6 struct node 7 { 8 int s,t; 9 }L[10010];10 int cmp(const struct node &a, const struct node &b)11 {12 return a.t = L[i].s && 阅读全文
posted @ 2013-11-06 20:40 straw_berry 阅读(278) 评论(0) 推荐(0)
MPI Maelstrom(Dijkstra)
摘要:http://poj.org/problem?id=1502刷一道模板题稳定一下心情。。。Dijkstra求单源最短路,就是输入的时候注意下,是按下三角输入的(无向图),输入字符x表示i与j不通。可以这样输入:if(scanf("%d",&w)) map[i][j] = map[j][i] = w; else scanf("x"); 1 #include 2 #include 3 const int INF = 0x3f3f3f3f; 4 5 int map[110][110],vis[110],dis[110],n; 6 void Dijkst 阅读全文
posted @ 2013-11-06 19:41 straw_berry 阅读(293) 评论(0) 推荐(0)
The Same Game(模拟)
摘要:http://poj.org/problem?id=1027题意:给一个10*15的地图,里面填充R,G,B三种颜色,每次找到当前地图的同色最大区域M,并将其删除,删除M后,上面的小球自然下落,当有空列时,空列右边的小球同时向左移动一列, 当最后地图上同色最大区域的小球个数是1或0时,循环结束;注意输出格式,最后输出一个空行。思路:while(true){ 找到同色最大区域,包括其面积Maxsize,坐标,颜色(BFS,手写队列); if (Maxsize == 1 || Maxsize == 0) break; 删除该最大区域,即将map[i][j] 置为0,(BFS,手写队列)... 阅读全文
posted @ 2013-11-05 20:54 straw_berry 阅读(240) 评论(0) 推荐(0)
France \'98(概率)
摘要:题目描述Today the first round of the Soccer World Championship in France is coming to an end. 16 countries are remaining now, among which the winner is determined by the following tournament: 1 Brazil -----+ +-- ? --+ 2 Chile ------+ | +-- ? --+ 3 Nigeria ----+ | | ... 阅读全文
posted @ 2013-11-03 21:32 straw_berry 阅读(266) 评论(0) 推荐(0)
GCC
摘要:题目描述The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by theGNU Project supporting various programming languages. But it doesn’t contains the math operator “!”.In mathematics the symbol represents the factorial operation. The expression n! means "theproduct of 阅读全文
posted @ 2013-11-03 21:26 straw_berry 阅读(196) 评论(0) 推荐(0)
吉哥系列故事――临时工计划(dp)
摘要:Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescription 俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只能把唯一的希望放到自己身上。可是由于时间段的特殊性和自己能力的因素,只能找到些零零碎碎的工作,吉哥想知道怎么安排自己的假期才能获得最多的工资。 已知吉哥一共有m天的假期,每天的编号从1到m,一共有n份可以做的工作,每份工作都知道起始时间s,终止时间e和 阅读全文
posted @ 2013-11-03 21:05 straw_berry 阅读(443) 评论(0) 推荐(0)
Tribles(概率)
摘要:DescriptionProblemATribblesInput:Standard InputOutput:Standard OutputGRAVITATION,n."The tendency of all bodies to approach one another with a strengthproportion to the quantity of matter they contain -- the quantity ofmatter they contain being ascertained by the strength of their tendencyto app 阅读全文
posted @ 2013-11-03 19:29 straw_berry 阅读(320) 评论(0) 推荐(0)