上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 18 下一页
摘要: http://poj.org/problem?id=1562 水题。code:#include<cstdio>#include<cstring>inttur[8][2]={-1,-1,-1,0,-1,1,1,-1,1,0,1,1,0,1,0,-1};charmap[101][101];intn,m,ans,num;boolvis[101][101];structnode{intx,y;}coor[10005];boolinmap(nodep){if(p.x>=0&&p.x<n&&p.y>=0&&p.y&l 阅读全文
posted @ 2012-03-01 19:17 追逐. 阅读(233) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2907 挺简单的一题,但是上来就给想错了。应该是按各个可用点搜索,累加各点间距离取最小,我想的是按坐标全搜,标记过程值。code:#include<cstdio>#include<cstring>usingnamespacestd;constintMAX=1e8;intn,m,sx,sy,num,ans;structnode{intx,y;boolvis;}bee[11];intdis(intp,intq){intdx=bee[p].x-bee[q].x<0?bee[q].x-bee[p].x:bee[p].x 阅读全文
posted @ 2012-03-01 19:14 追逐. 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3065 AC自动机,主要注意的就是两个特征码的重叠情况。code:#include<iostream>#include<cstring>#include<cstdio>usingnamespacestd;constintkind=30;structnode{node*fail;node*next[kind];intcount;intid;node(){fail=NULL;count=0;id=-1;memset(next,NULL,sizeof(next));}}*q[50 阅读全文
posted @ 2012-02-22 01:26 追逐. 阅读(223) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2896 这题WA了好多好多次,大概8、9次吧,从cf进行到一半就开始在这调。经过不懈的努力终于发现,TMD,vis的memset放错地方了!!!这都什么事啊,老被这种错给整的那么郁闷。。。code:#include<iostream>#include<cstring>#include<cstdio>usingnamespacestd;constintkind=130;structnode{node*fail;node*next[kind];intcount;intid;no 阅读全文
posted @ 2012-02-21 01:56 追逐. 阅读(215) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2251 刷水题好爽!但是别真跟xcy说的一样,把rp都给用完了... 三维空间的bfs,只是搜索的时候多了两个方向而已。code:#include<cstdio>#include<cstring>boolvis[31][31][31];intlve[6]={1,0,0,0,0,-1};introw[6]={0,-1,0,0,1,0};intcol[6]={0,0,-1,1,0,0};boolflag;inta,b,c;structnode{intx;inty;intz;intstep;}q[1000000];node 阅读全文
posted @ 2012-02-16 03:18 追逐. 阅读(191) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3126 给两个素数,求第一个素数转变成第二个素数所需最小步骤数。每次转换只能改变一位,且转换的中间数都为素数。 最短路径问题,打出一个素数表,对4位数的各个位置0..9暴搜。 比较郁闷的是sqrt()和pow()中必须要用强制转换才行,不记得以前要这样用啊??CE了几次。code:#include<cstdio>#include<cmath>#include<cstring>usingnamespacestd;boolprim[10000];boolvis[10000];intq[1000];voidge 阅读全文
posted @ 2012-02-16 01:48 追逐. 阅读(240) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=2676 单纯的dfs,用三个数组记录行、列以及3×3方格的情况。 只是一开始不知道为什么没办法结束程序的运行,提交两次TLE,感觉应该是getchar()的问题。code:#include<cstdio>#include<iostream>#include<cstring>usingnamespacestd;boolc[10][10];boolr[10][10];bools[4][4][10];boolvis[10][10];charstr[10];intdata[10][10];boolfla 阅读全文
posted @ 2012-02-16 00:22 追逐. 阅读(234) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 18 下一页