2013年8月15日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4679f[u],g[u],k[u]:分别代表u延伸出去的最长边长,第二长边长,第三长边长;ff[u]:f[u]对应的子节点gg[u]:g[u]对应的子节点h[u]:沿着u的父节点方向的最长边dp[u][0]:以u的所有子节点为根的子树中的子树的直径最大值dp[u][1]:以u的所有子节点为根的子树中的子树的直径次大值flag[u]:dp[u][0]对应的u的子节点ddp[u]:除以u为根的子树外的子树的直径#include #include #include #include #include using n 阅读全文
posted @ 2013-08-15 20:51 tobec 阅读(203) 评论(0) 推荐(0) 编辑
2013年8月12日
摘要: http://poj.org/problem?id=3580给一个长度为N(N 2 #include 3 #include 4 #include 5 using namespace std; 6 #define inf (1= nowsz) return 0; 63 int x = tree[0].chd[1]; 64 while(1) { 65 pushdown(x); 66 int u = tree[x].chd[0]; 67 int v = tree[x].chd[1]; 68 if(tree... 阅读全文
posted @ 2013-08-12 13:37 tobec 阅读(338) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1890给一个长度为N(N 2 #include 3 #include 4 #include 5 using namespace std; 6 #define inf (1<<29) 7 const int maxn = 100010; 8 int n , splaysz; 9 struct node {10 int p,chd[2],sz,flag;11 node (int P=0) {12 chd[0]=chd[1]=0;sz=0;13 p = P; f... 阅读全文
posted @ 2013-08-12 13:35 tobec 阅读(229) 评论(0) 推荐(0) 编辑
2013年8月10日
摘要: http://www.lydsy.com/JudgeOnline/problem.php?id=1588splay tree 中的一些操作的说明:sc函数: inline void sc(int y,int x,int p) { 如果p==0,则y是x的父亲,x是y的左儿子; 如果p==1,则y是x的父亲,x是y的右儿子; }rot函数: inline void rot(int x) { y是x的父亲节点; 如果x是y的左儿子,则w=0;如果x是y的右儿子,则w=1; 设p是y的父亲; 对x,y,p进行zig或zag操作; } 效果:每次rot(x),x向根靠近一单位深度splay函数: vo 阅读全文
posted @ 2013-08-10 15:04 tobec 阅读(197) 评论(0) 推荐(0) 编辑
摘要: http://www.lydsy.com/JudgeOnline/problem.php?id=1503#include #include #include #include using namespace std;#define inf (1 tree[now].v; if(tree[now].chd[w]) now = tree[now].chd[w]; else { tree[++splaysz] = node(now,val); tree[now].chd[w]= splaysz; updat... 阅读全文
posted @ 2013-08-10 15:02 tobec 阅读(234) 评论(0) 推荐(0) 编辑
摘要: ACM国际大学生程序设计竞赛(ACM-ICPC)是国际上公认的水平最高、规模最大、影响最深的计算机专业竞赛,目前全球参与人数达20多万。《ACM国际大学生程序设计竞赛(ACM-ICPC)系列丛书:题目与解读》作者将16年的教练经验与积累撰写成本系列丛书,全面、深入而系统地将ACM-ICPC展现给读者、本系列丛书包括《ACM国际大学生程序设计竞赛:知识与入门》、《ACM国际大学生程序设计竞赛:算法与实现》、《ACM国际大学生程序设计竞赛:题目与解读》、《ACM国际大学生程序设计竞赛:比赛与思考》等4册,其中《ACM国际大学生程序设计竞赛:知识与入门》介绍了ACM-ICPC的知识及其分类、进阶.. 阅读全文
posted @ 2013-08-10 12:13 tobec 阅读(1753) 评论(0) 推荐(0) 编辑
摘要: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=214&page=show_problem&problem=1491We can generate a random string by generating a sequence of random characters and concatenating them together. Each character is chosen independently from the first 阅读全文
posted @ 2013-08-10 11:28 tobec 阅读(279) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1229Problem FCouponsInput:standard inputOutput:standard outputTime Limit:2secondsMemory Limit:32 MBCoupons in cereal boxes are numbered1ton, and a set of one of each is required 阅读全文
posted @ 2013-08-10 11:16 tobec 阅读(757) 评论(0) 推荐(0) 编辑
2013年8月9日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4654stoer-wagner算法 + dfs#include #include #include #include #include using namespace std;#define inf (1 vst[maxn];vector pa , pb;int prim(int n) { memset(vis,0,sizeof(vis)); memset(d,0,sizeof(d)); int mincut = 0 , tmp = -1; s = t = -1; int to... 阅读全文
posted @ 2013-08-09 15:55 tobec 阅读(331) 评论(0) 推荐(0) 编辑
2013年8月8日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4647树上的博弈,直接把边权平分到两边的节点上,然后排个序,从大往小取#include #include #include #include using namespace std;const int maxn = 100100;int n , m;double a[maxn];int main() { while(~scanf("%d%d",&n,&m)) { for(int i=1;i=1;i-=2) { ans += a[i] - a[i-1]; ... 阅读全文
posted @ 2013-08-08 19:34 tobec 阅读(162) 评论(0) 推荐(0) 编辑