摘要: http://poj.org/problem?id=3411 这题RE了N多次,到最后也不知道是什么原因。看到网上说vis[x]不会超过3,就试着加上了<=3的限制,我了个去,马上AC! 问题应该还是递归过程爆栈了吧。code:#include<cstdio>#include<cstring>constintMAX=99999999;intvis[15];intans,n,m;boolflag;structnode{inta;intb;intc;intp;intr;}q[15];voiddfs(inti,intv){if(v>ans)return;if(i= 阅读全文
posted @ 2012-02-29 19:00 追逐. 阅读(212) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1655 同poj3107,只要求输出一个数值最小的点。 刚开始的答案值修改的num[]记录的,罪过罪过。。。code:#include<cstdio>#include<cstring>#defineMax(a,b)a>b?a:busingnamespacestd;constintMAX=20001;intk,n,Min,anspoint,ansnum;intvis[MAX],head[MAX],num[MAX];structEdge{intv,next;}edge[2*MAX];voidaddedge(inta 阅读全文
posted @ 2012-02-29 15:11 追逐. 阅读(222) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3107 给定一棵树,取去掉某一节点后形成子树的最大节点数,求使这个数最小的节点。 去掉某一节点后,形成的树包括子树和原树去掉以这个点为根的树所形成的树,在这几个树中求最大值即可。 节点数的计算可用回溯,过程中选取最大值。 貌似是我第一个用邻接表存边的题,贴下模板。邻接表存边code:#include<iostream>#include<cstring>#include<cstdio>usingnamespacestd;constintnMax=1000;classedge{public:intv,nex; 阅读全文
posted @ 2012-02-29 15:03 追逐. 阅读(800) 评论(0) 推荐(0) 编辑