自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

原创 POJ-1442-treap

#include #include #include #include #include #include #include using namespace std; const int inf = 0x3f3f3f3f; const int N = 30009; const double esp = 1e-6; int v[N]; struct treap { tre

2012-07-09 14:36:37 1229

原创 POJ-2486-树背包

一直想把他当树dp做 。。 怎么也想不出来转移方程 。。 后来灵机一动 。。 很像背包啊 。。 于是今天到机房就把他敲了 。。好久好久好久没做背包了 。。虽然某种说法上背包也是dp 。。 const int K = 209; const int N = 109; int dp[2][N][K];//0表示不回来;1表示回来 int val[N]; int vis[N]; int n

2012-07-09 08:50:28 640

原创 POJ-4045-数据结构+dfs

#include #include #include #include #include #include using namespace std; const int maxn = 50009; __int64 start[maxn]; __int64 end[maxn]; __int64 child[maxn]; __int64 val[maxn]; int vis[maxn];

2012-07-08 09:57:17 602

原创 POJ-4052-ac自动机

先把匹配上的串都标记。然后把每个匹配上的串的子串变成非结束。 直接会超时。优化找失败指针的地方。 #include #include #include #include #include #include #include using namespace std; const int maxn = 250009; char str1[5100009], str2[51

2012-07-08 09:55:07 911

原创 POJ-4047-线段树

#include #include #include #include #include #include #include using namespace std; const int maxn = 200009; int n, nn, m, k; int a[maxn], b[maxn]; struct tree { int l, r, v, lazy, mid;

2012-07-08 09:47:17 489

原创 HDU-3695-ac自动机

char str1[5100009], str2[5100009]; int cnt; struct trie { trie *ch[26]; trie *fail; int end; void init() { memset(ch, NULL, sizeof(ch)); fail = NULL; end =

2012-07-07 13:56:22 643

原创 HDU-3658-矩阵

#include #include #include #include #include #include #include using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 1009; const double esp = 1e-6; const __int64 mod = 1000000007;

2012-07-07 13:54:12 424

原创 HDU-2852-树状数组+第k小数

int C[maxn]; int lowbit(int x) { return x&(-x); } void updata(int pos, int tmp) { for(; pos<=100000; pos+=lowbit(pos)) C[pos] += tmp; } int query(int pos) { int a = 0; for(;

2012-07-07 13:45:59 1052

原创 HDU-3887-树状数组

一看这题简单啊 。。 于是写 。。 于是wa 。。。 传说中的暴栈 。。。 人工写 。。 对我来说还是挺难的 。。。 注释掉的就是暴栈的 。。 int start[maxn]; int end[maxn]; int vis[maxn]; int C[maxn]; int ans[maxn]; int ans1[maxn]; int ans2[maxn]; int stac

2012-07-07 13:43:27 589

原创 POJ-1185-状态dp

int dp[109][161][161]; char mp[109][15]; int sta[61];// int nn[61]; void init() { int tol=0, i, j; for(i=0; i<=1024; i++) { int num = 0; for(j=0; j<10; j++) {

2012-07-07 13:37:47 398

原创 POJ-1739-插头dp

int dp[10][10][19690]; //传说中的三进制 int bit[]={1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683}; char ok[13][13]; int st[1000][10], go[19900], p[900][10], slack[10]; int k, num, tot; int main() { int n

2012-07-07 13:35:32 798

原创 POJ-3208-dp

(有点ac自动机思想 (和POJ1037一样,输出麻烦 。。 __int64 dp[15][4]; int s[4][10] = { {0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 2, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 3, 0, 0, 0},

2012-07-07 13:29:03 771

原创 POJ-3691-ac自动机+dp

const double esp = 1e-6; int dp[1009][1009]; int cnt; struct trie { trie *ch[4]; trie *fail; int id; bool end; void init() { memset(ch, NULL, sizeof(ch)); fail

2012-07-07 13:27:43 617

原创 HDU-1693-插头dp

懂了这道题还不算懂插头dp。 我现在就是不懂插头dp。 要想懂插头dp就要先懂状态dp。 状态dp之于插头dp,就像 trie树之于ac自动机。 __int64 dp[13][13][1<<13]; int ok[13][13]; int n, m; int main() { int t; scanf("%d", &t); for(int tt=1; t

2012-07-07 13:26:32 931

原创 POJ-1037-dp

(一到普通的dp , 整了好久才AC。。dp只记录个数,输出时需要逻辑 。。 __int64 dp[22][22][2]; int ans[22]; int vis[22]; void init() { memset(dp, 0, sizeof(dp)); dp[1][1][0] = 1; dp[1][1][1] = 1; for(int i=2; i<

2012-07-07 13:22:54 623

原创 POJ-2440-矩阵

const int inf = 0x3f3f3f3f; const int maxn = 1009; const int mod = 2005; const double esp = 1e-6; int x[5][5]={ {1, 1, 0, 0, 0}, {0, 0, 1, 1, 0}, {0, 0, 0, 1, 1},

2012-07-07 13:21:21 515

原创 POJ-1848-treedp

dp[][3] dp[i][0] 表示第i个节点和他所有孩子们都在一个环里了(i在环里); dp[i][1] 表示第i个节点的孩子们都在一个环里了(i不在环里); dp[i][2] 表示第i个节点除了一条孩子链的其他孩子都在环里了(i不在环里)。 int vis[109]; int dp[109][3]; struct node { int ch[109]; in

2012-07-07 13:19:10 547

原创 POJ-2778-ac自动机+矩阵

(这道题是我的第一道动态矩阵。以前做过ac自动机,做过静态矩阵。于是很想做这道题。可是自己就是想不出来思路。后来是和芳哥一起讨论整理出的思路。非常非常感谢芳哥。。后来我写的时候,半个小时敲完,然后一直wa,发现有个bug,如(GA, AT)那么G后面的C转向状态0,但是我写的trie里面G后面没有C 。 于是我各种想办法。 这种时候,不要找度娘。 因为度娘告诉我很多我看不懂得方法。于是还是自己想。

2012-07-07 13:12:00 528

原创 ZOJ-3612-树状数组+第k小数+离散化

#include #include #include #include #include #include #include using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 10009; const double esp = 1e-6; double bef[maxn]; double aft[m

2012-07-07 13:07:39 1386

原创 POJ-2761-树状数组+第k小数+离散化

#include #include #include #include #include #include #include using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 100009; const double esp = 1e-6; int n, m, num; int bef[maxn];

2012-07-07 13:05:29 1270

原创 后天整理下这几天做的题。

如题。 周六。

2012-07-05 08:58:18 398

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除