随笔分类 - spoj
摘要:初识后缀自动机;推荐学习:http://blog.sina.com.cn/s/blog_7812e98601012dfv.html 1 #include 2 #include 3 #include 4 #define maxn 600009 5 using namespace std; 6 7 char s[maxn]; 8 9 struct node10 {11 int l;12 node *ch[28],*fail;13 } pool[maxn],*head,*tail;14 int top;15 void add(int x)16 {17 node *p=&p...
阅读全文
摘要:三维DP 第K字典序从左向右找 根据dp数组的值算出每一位该打印什么代码: 1 #include 2 #include 3 using namespace std; 4 long long memo[9][221][221]; 5 long long solve(int n, int m, int last)//n划分成m个数最小值为last; 6 { 7 if(n==0) 8 { 9 if(m>=last) return 1;10 return 0;11 }12 long long &ret = memo[n][m][las...
阅读全文
摘要:简单的博弈题,用dp解;每个人只能拿1,l,k个硬币;dp[i][j]表示第j个人拿是否能拿第i枚硬币;代码: 1 #include 2 #define maxn 1000007 3 using namespace std; 4 bool dp[maxn][2]; 5 int x,l,m,k; 6 7 int main() 8 { 9 scanf("%d%d%d",&k,&l,&m);10 for(int i=1;i=l)dp[i][j]|=1-dp[i-l][j^1];15 if(i>=k)dp[i][j]|=1-dp[i-k][j^1];1
阅读全文