摘要: /*p 横q 竖顺序...这题要按照字典序顺序搜索,深搜策略,判断成功的条件是走的步数等于格子的数目*/#include <stdio.h>#include <string.h>#define MAXN 27int map[MAXN][MAXN];int p, q, cas, ok, step;;int pathX[MAXN], pathY[MAXN];int dr[8][2] = {{-2, -1}, {-2, 1}, {-1, -2}, {-1, 2},{1, -2}, {1, 2}, {2, -1}, {2, 1}}; //字典序顺序int legal(int x 阅读全文
posted @ 2011-04-07 22:51 L.. 阅读(157) 评论(0) 推荐(0) 编辑
摘要: /*题目已按x,y轴排序 画个图就理解了*/#include <stdio.h>#include <stdlib.h>const int MAXN = 15001;int n;int a[32001]; //树状数组 int level[MAXN];int lowbit(int t){ return t & (-t); }void add(int t){ while(t <= 32001){ a[t]++; t += lowbit(t); }}int sum(int t){ int ans = 0; while(t > 0){ ans += a[t] 阅读全文
posted @ 2011-04-07 20:43 L.. 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 经典的染色问题,很明显的体现了lazy——tag思想.../*用cin超时...*/#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#define L(t) ((t) << 1)#define R(t) ((t) << 1 | 1)using namespace std;const int MAXN = 1000002;bool used[33];struct SegTree{ int l, r; int color; 阅读全文
posted @ 2011-04-07 20:41 L.. 阅读(206) 评论(0) 推荐(0) 编辑
摘要: /*第一类信息ll, rr, len递推求解第二类信息state.表示整个子树的性质*/#include <stdio.h>#include <algorithm>#define L(x) ((x) << 1)#define R(x) ((x) << 1 | 1)using namespace std;const int MAXN = 50002;int N, M;struct SegTree{ int l, r; int ll, rr; //最左边,右边可用连续区间长度 int len; //最长连续可用房间长度 int state; //0 阅读全文
posted @ 2011-04-07 20:33 L.. 阅读(355) 评论(0) 推荐(1) 编辑
摘要: //通过这题知道了可并堆这个东西.其实挺好理解的,体会到了//数据结构的强大啊!!!#include <stdio.h>#include <algorithm>using namespace std;const int MAXN = 100100;int father[MAXN];struct Monkey{ int l,r; int dis; int strong;}LTree[MAXN];int find(int x){ if(x != father[x]) father[x] = find(father[x]); return father[x];}int mer 阅读全文
posted @ 2011-04-07 17:45 L.. 阅读(641) 评论(0) 推荐(0) 编辑
摘要: 数状数组 模板题/*(1) Add i j,i和j为正整数,表示第i个营地增加j个人(j不超过30)(2)Sub i j ,i和j为正整数,表示第i个营地减少j个人(j不超过30);(3)Query i j ,i和j为正整数,i<=j,表示询问第i到第j个营地的总人数;(4)End 表示结束,这条命令在每组数据最后出现;当然线段树也可以解决,不过没树状数组方便 哈哈*/#include <iostream>#include <stdlib.h>#include <string.h>using namespace std;const int MAXN = 阅读全文
posted @ 2011-04-07 17:23 L.. 阅读(178) 评论(0) 推荐(1) 编辑
摘要: #include <stdio.h>#include <string.h>#include <queue>using namespace std;const int MAXN = 250010;const int K = 26;struct Trie{ int wordEnd; int fail; int next[K]; void init(){ wordEnd = 0; fail = -1; memset(next, 0, sizeof(next)); } }tree[MAXN];int cnt;char str[1000010];void prePro 阅读全文
posted @ 2011-04-07 16:46 L.. 阅读(229) 评论(0) 推荐(0) 编辑