2013年7月24日

EOJ 1271 The Tower of Babylon

摘要: http://www.acm.cs.ecnu.edu.cn/problem.php?problemid=1271因为盒子的方向是任意定的,所以把盒子的三个方向都存下来在dp会方便很多 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 struct Node10 {11 int x, y, z;12 }b[100];13 int n;14 15 bool cmp(const Node &a, const Node &b)16 {17 ... 阅读全文

posted @ 2013-07-24 20:58 KimKyeYu 阅读(150) 评论(0) 推荐(0) 编辑

2013年7月23日

EOJ-1765 Nested Dolls

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1765题意:给出一系列物体的宽与高,满足w1 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 #include13 #include14 #include15 #include16 using namespace std;17 struct node{18 int w,h;19 }a[20005];20 bool c... 阅读全文

posted @ 2013-07-23 03:54 KimKyeYu 阅读(250) 评论(1) 推荐(0) 编辑

2013年7月22日

LCA 离线算法 Tarjan

摘要: 转载一篇博客:http://www.cnblogs.com/ylfdrib/archive/2010/11/03/1867901.htmlTarjan实现: dfs + 并查集;通过这道题体会一下把:(思路详见上面的博客)hdu 2586 http://acm.hdu.edu.cn/showproblem.php?pid=2586 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 1... 阅读全文

posted @ 2013-07-22 19:45 KimKyeYu 阅读(266) 评论(0) 推荐(0) 编辑

2013年7月17日

EOJ 1180 Inglish-Number Translator

摘要: http://www.acm.cs.ecnu.edu.cn/problem.php?problemid=1180poj 2121 http://poj.org/problem?id=2121题目大意:输入数字的英文写法,输出阿拉伯数字。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 using namespace std; 13 14 mapmy; ... 阅读全文

posted @ 2013-07-17 16:25 KimKyeYu 阅读(250) 评论(0) 推荐(0) 编辑

sg 函数模版

摘要: 1 #define MAXN 1005 2 3 using namespace std; 4 5 int s[MAXN], ns; //取值集合 6 int sg[10005]; 7 8 int mex(int x) 9 {10 if(sg[x] != -1)11 return sg[x]; 12 bool v[MAXN]; //x的后继集合13 memset(v, 0, sizeof(v));14 for(int i=0; i<ns; i++){ //求后继集合15 int t = x-s... 阅读全文

posted @ 2013-07-17 15:55 KimKyeYu 阅读(172) 评论(1) 推荐(0) 编辑

2013年7月16日

EOJ 1494 Coins

摘要: http://www.acm.cs.ecnu.edu.cn/problem.php?problemid=1494poj 1742 http://poj.org/problem?id=1742这题是一个部分背包,本来想过用二分的方法变成一个0-1背包,时间复杂度为(nlogV*V),但是还是超时了,所以要优化成(nV)的才能过 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 int dp[100005], cou[100... 阅读全文

posted @ 2013-07-16 13:25 KimKyeYu 阅读(243) 评论(0) 推荐(0) 编辑

2013年7月13日

EOJ 2743 Stock Exchange

摘要: EOJ 2743 http://acm.cs.ecnu.edu.cn/problem.php?problemid=2743本题为LIS:即Longest Increasing Sequence.(本题中严格递增)最长上升子序列(LIS)长度的O(nlogn)算法:(对状态转移时查找的优化) 用len[ i ]存放当前(需不断更新) 长度为 i 的上升子序列的末尾 的最小值, 注意到,len[]严格递增,可对其进行二分查找, 找到最大的i ,且满足len[ i ] 2 #include 3 #include 4 #include 5 #include 6 #include 7 ... 阅读全文

posted @ 2013-07-13 21:18 KimKyeYu 阅读(281) 评论(0) 推荐(0) 编辑

POJ-3468 A Simple Problem with Integers

摘要: http://poj.org/problem?id=3468第一次手写的线段树,以后就用这个做模板好了。自己风格的线段树:(区段更新 1 #define maxn 100005 2 #define ls(p) p=L && R>=r){37 t[p].f+=v;38 ... 阅读全文

posted @ 2013-07-13 01:30 KimKyeYu 阅读(313) 评论(0) 推荐(0) 编辑

2013年7月11日

EOJ-1104 bitmap

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1104题意:给一张只有1和0的图,求图上所有'0'的点到'1'的点的最短距离.解法:若对每个0进行BFS到1的距离会超时,故从每个1进行BFS,更新到每个0的距离,可假象有一个源点连接着所有的1,从该源点进行BFS的搜索就可以达成一遍BFS更新所有0,方法即 先将所有1的点入队后,再进行BFS。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #includ 阅读全文

posted @ 2013-07-11 21:17 KimKyeYu 阅读(186) 评论(0) 推荐(0) 编辑

【转】旋转卡壳——凸多边形间对踵点对(定义)

摘要: 凸多边形间对踵点对有向切线一个有向切线就如同其名字所阐述的。 有向切线在区分平行切线同向与反向时候是十分必要的。 进一步假设多边形是顺时针序的(当顶点顺序排布时候是顺时针的)并且多边形的切线当多边形在线的右侧时候是正向的。 相反的, 当多边形在切线的左侧时多边形能够按照逆时针序给出。 虽然只是约定, 但制定一些标准, 来避免混淆结构与结果是必要的。 并且采用这个约定绝不会影响结果并且带来任何限制。 注意: 切线的定义导出了对踵点对. 凸多边形间的对踵点对给定两个多边形 P 和 Q, 一对点 (p, q) (分别属于 P 和 Q), 当通过 p 和 q 的(有向)平行切线指向不同的方向时, 他们 阅读全文

posted @ 2013-07-11 20:15 KimKyeYu 阅读(542) 评论(0) 推荐(0) 编辑

导航