上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 40 下一页

2013年7月1日

Codeforces Round #190 (Div. 2) E. Ciel the Commander 题目与题解翻译

摘要: E. Ciel the Commandertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output现在Fox Ciel成为了Tree Land的指挥官。Tree Land,正如它的名字所说,有n个城市由n-1条无向道路连接,并且其中任意两个城市之间总是存在一条路径。Fox Ciel需要在每个城市分配一个官员。每个官员都有一个等级---一个’A’到’Z’之间的字母。所以会有26个不同的等级,’A’是最高的,’Z’是最低的。每个等级都有足够的官员。但是必 阅读全文

posted @ 2013-07-01 18:48 电子幼体 阅读(154) 评论(0) 推荐(0) 编辑

树的直径与树的中心

摘要: 1. 树的直径概念:树中的最长路。求法:两次深搜或DP。1-两次深搜:任找一点A为源点,深搜遍历得到最远点B,这个最远点B必定在直径中(感性想想,以A点为源点找到的最长路后面一段必定属于树的直径的一部分);再以这个最远点B为源点深搜遍历求一个最长路,这个最长路即为树的直径。2-DP:显然最长路的两个端点必然是叶子或者根节点。设f(i)表示到i最远的叶子,g(i)表示到i次远的叶子,则有f(i)=max{f(j)}+1;g(i)=second{f(j)}+1;其中j必须是i的儿子,计算顺序是自底向上。最终答案为max{f(i)+g(i)}+12. 树的中心概念:树的直径的中点。求法:有多种,如D 阅读全文

posted @ 2013-07-01 16:06 电子幼体 阅读(418) 评论(0) 推荐(1) 编辑

2013年6月29日

Codeforces Round #190 (Div. 2) 解题报告

摘要: -----------------A. Ciel and Dancingn个男孩和m个女孩配对跳舞,每首歌有一对男女跳舞,要求配对男孩和女孩中至少有一个没有跳过舞。求最多的能放的歌曲数并输出配对方案。分析可知最多能放n+m-1首歌曲。----贪心,男孩1和所有的女孩跳舞。女孩1和所有的男孩跳舞。除去男孩1和女孩1重复的情况#include #include #include using namespace std; int main() { int n,m; int s; while (cin>>n>>m) { s=0; ... 阅读全文

posted @ 2013-06-29 21:13 电子幼体 阅读(141) 评论(0) 推荐(0) 编辑

2013年6月19日

一个矩阵的类与矩阵连乘模板

摘要: 我的模板#include #include #include #include using namespace std; const int maxsize=32; struct Matrix { int element[maxsize][maxsize]; int size; int modulo; void init_matrix(int _size,int _modulo) { size=_size; modulo=_modulo; for (int i=0; i #include ... 阅读全文

posted @ 2013-06-19 21:30 电子幼体 阅读(145) 评论(0) 推荐(0) 编辑

2013年6月16日

poj 1269 Intersecting Lines 直线交点

摘要: Intersecting LinesTime Limit:1000MSMemory Limit:10000KTotal Submissions:8222Accepted:3746DescriptionWe all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect 阅读全文

posted @ 2013-06-16 15:16 电子幼体 阅读(184) 评论(0) 推荐(0) 编辑

poj 2007 Scrambled Polygon 极角排序

摘要: Scrambled PolygonTime Limit:1000MSMemory Limit:30000KTotal Submissions:5868Accepted:2777DescriptionA closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the vertices of the polygon. When one starts at any vertex of a clos 阅读全文

posted @ 2013-06-16 15:12 电子幼体 阅读(139) 评论(0) 推荐(0) 编辑

poj 1113 Wall 凸包

摘要: WallTime Limit:1000MSMemory Limit:10000KTotal Submissions:25770Accepted:8575DescriptionOnce upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to build a b 阅读全文

posted @ 2013-06-16 15:09 电子幼体 阅读(106) 评论(0) 推荐(0) 编辑

几何中点/线/多边形模板

摘要: ----------#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define pb push_back using 阅读全文

posted @ 2013-06-16 15:00 电子幼体 阅读(185) 评论(0) 推荐(0) 编辑

poj 2653 Pick-up sticks 线段相交

摘要: DescriptionStan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he 阅读全文

posted @ 2013-06-16 14:20 电子幼体 阅读(126) 评论(0) 推荐(0) 编辑

MUTC 3 A - Flowers 树状数组

摘要: FlowersTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1829Accepted Submission(s): 901Problem DescriptionAs is known to all, the blooming time and duration varies between different kinds of flowers. Now there is a garden planted full of flowers. Th 阅读全文

posted @ 2013-06-16 13:48 电子幼体 阅读(139) 评论(0) 推荐(0) 编辑

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 40 下一页

导航