上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
  2011年8月31日
摘要: poj 2513题目大意:给一些彩色棒,看能不能组成一个解决:trie+无向图欧拉路(偶数结点度数为0或者2)clude <iostream> #include <cstring>#include <cstdio>using namespace std;struct node{ int next[26]; int wordNo;};int top;int num;node tree[2000000];short adj[510010];int data[510010];void init(){ top=1; num=0; memset(data,-1,si. 阅读全文
posted @ 2011-08-31 20:52 猿类的进化史 阅读(363) 评论(0) 推荐(0) 编辑
  2011年8月30日
摘要: hdoj 2222题目大意:给出一些字符串 ,再给出一段文字,问文字中出现多少个单词解决:AC自动机#include <iostream>#include <cstring>#include <queue>#include <cstdio>using namespace std;#define s scanfint top;struct node{ int cnt; int fail; int next[26];};node tree[400000];char mai[1000005];void init(){ top=1; memset(tre 阅读全文
posted @ 2011-08-30 21:55 猿类的进化史 阅读(557) 评论(0) 推荐(0) 编辑
  2011年8月27日
摘要: poj 3461题目大意:啥都不说了,就是一个模式匹配解决:KMP 刚开始一直wa,后来经同学提醒突然想到了溢出了,改了之后,一次就过了#include <iostream>#include <cstdio>#include <cstring>using namespace std;char s[1000005],t[10005];int next[10005],tlen,slen;void getnext(){ int i=1,j=0; next[1]=0; while(i<=tlen) {//本来的模式匹配 i < tlen 就结束了,但是为 阅读全文
posted @ 2011-08-27 22:27 猿类的进化史 阅读(201) 评论(0) 推荐(0) 编辑
摘要: poj 2157题目大意:S是起点,G是 终点,"."是可走的路,“X”是不可走的路解决:BFS 本题有些难度,因为若为钥匙,将钥匙吃了之后,将这个点变为“.”,若为门,判断是否对应该门的钥匙都拿到手了,若都拿到手了,可以将这个门打开,即变为“.”,否则,等这个点周围的所有点都进队列后,若队列为空说明路都走过了,一定无法通过,若队列非空,说明还有其他的路可以走,将这个点入队列,一会等着把钥匙都得到了,在出队列判断。#include <iostream>#include <cstdio>#include <queue>using names 阅读全文
posted @ 2011-08-27 11:38 猿类的进化史 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 宽度优先搜索bfs一、搜索的bfs,宽度优先搜索,一般用于求最短的得到到目的地的距离,有个起始点,先把这个起始点入队列,不要忘记将这个起始点标记为已经利用,不然会走回来的,然后是与这个起始点的周围的点的监测,若可以行的通,我们一一检测这些扩展出来的点,若是目的地就结束了,若不是目的地,将改点标记为已经利用,并将该点入队列。二、搜索的双向bfs,双向的bfs一般来说可以用单向解决,但是单向的效率上还是差了点,适合双向bfs的题目有一些共同特点:给出起始和最终状态,让求出一条从初始到末状态的最短路。双向bfs的实现过程: 从初始结点开始扩展,每扩展一层,在从目标节点按照产生系统相反的办法来扩展结点 阅读全文
posted @ 2011-08-27 00:21 猿类的进化史 阅读(786) 评论(0) 推荐(1) 编辑
  2011年8月25日
摘要: 基础题:1000、1001、1004、1005、1008、1012、1013、1014、1017、1019、1021、1028、1029、1032、1037、1040、1048、1056、1058、1061、1070、1076、1089、1090、1091、1092、1093、1094、1095、1096、1097、1098、1106、1108、1157、1163、1164、1170、1194、1196、1197、1201、1202、1205、1219、1234、1235、1236、1248、1266、1279、1282、1283、1302、1303、1323、1326、1330、1334、1 阅读全文
posted @ 2011-08-25 20:34 猿类的进化史 阅读(540) 评论(0) 推荐(0) 编辑
摘要: hdoj 1010题目大意:给一个地图,在规定时间内刚好找到出口,不早也不能晚解决:dfs+剪枝#include <iostream>#include <cstdio>#include <cmath>using namespace std;#define s scanf#define p printf#define d "%d"char map[8][8];int n,m,step;bool escape;int sx,sy,ex,ey;int dx[]={1,-1,0,0};int dy[]={0,0,1,-1};void dfs(in 阅读全文
posted @ 2011-08-25 15:02 猿类的进化史 阅读(238) 评论(0) 推荐(0) 编辑
  2011年8月22日
摘要: 题目大意:给出一些数,用最小的交换相邻两个数,使得为正序,求最小交换次数解决:可以用归并排序,由于在士兵杀敌系列中已经用过了,所以为了练练何为树状数组中的离散化,再用树状数组做了一遍/*本题思路,首先将范围在0 ≤ a[i] ≤ 999,999,999之间的点压缩到0- 500,000之间,然后统计每个数之前所有比这个数小的*/#include <iostream> #include <cstdio>#include <algorithm>#include <cstring>using namespace std;int n;struct nod 阅读全文
posted @ 2011-08-22 13:44 猿类的进化史 阅读(802) 评论(0) 推荐(1) 编辑
摘要: poj 2155题目大意:第一行给出测试用例的次数,第二行第一个 给出矩阵的size,第二个给出命令的个数C表示更新数据,将范围在x1<=x<=x2,和y1<=y<=y2区域内的数每个都加上1,Q表示询问某一个点的大小解决:二维树状数组,与poj1195 mobile phones刚好相反,是插入区域,问点#include <iostream> #include <cstdio>#include <cstring>using namespace std;const int N=1010;int c[N][N];void init(){ 阅读全文
posted @ 2011-08-22 13:34 猿类的进化史 阅读(374) 评论(0) 推荐(0) 编辑
摘要: poj 1195题目大意:给出0时初始化,给出1时将矩阵中坐标为x,y的增加A,给出2时 查询区域为l<=x<=r, b<=r<=t范围内的总和解决:二维树状数组,只要知道一维中如何插点问段,这个便顺利写出#include <iostream>#include <cstdio>using namespace std;const int N=1200;int c[N][N];int n;void init(){ memset(c,0,sizeof(c));}int lowbit(int x){ return x&(-x);}void upd 阅读全文
posted @ 2011-08-22 13:28 猿类的进化史 阅读(256) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页