上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 44 下一页
摘要: 题目链接比着模版改的。改成静态的,一直在RE与超内存之间徘徊,最后出现了WA,忘记了一个初始化。。。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 using namespace std; 6 char str[1000001]; 7 int t; 8 int tire[252222][26]; 9 int que[352222]; 10 int o[252222]; 11 int fail[252222]; 12 void CL( 阅读全文
posted @ 2013-04-21 22:01 Naix_x 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 题目链接离散化后rmq,新白书上对这个题有讲解。 1 #include <iostream> 2 #include <cstring> 3 #include <cmath> 4 #include <cstdio> 5 using namespace std; 6 #define N 100000 7 int p[N]; 8 int dp[22][N+1]; 9 int hash[3*N];10 int que[N+1];11 int L[N+1];12 int R[N+1];13 int o[N+1];14 void init_rmq(int n 阅读全文
posted @ 2013-04-19 18:55 Naix_x 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 题目链接RMQ就是利用DP的思想,主要是解决求快速求区间最值的问题的。网上很多资料。 1 #include <iostream> 2 #include <cstring> 3 #include <cmath> 4 #include <cstdio> 5 using namespace std; 6 #define N 500000 7 int p[N]; 8 int dpmin[22][N]; 9 int dpmax[22][N];10 int bin[21];11 void CL(int n)12 {13 int i,j;14 for(i = 阅读全文
posted @ 2013-04-18 20:38 Naix_x 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目链接拆点+KM,建图思路看的题解。。。看懂的题意后,想了好一会。知道这题是KM,但是不会建图,无奈啊。建图很巧妙,假如同一个机器上加工了k件物品,那么实际花费时间k*a1+(k-1)*a2+(k-3)*a3....其实对这个拆点,也不是很懂。这样把m个机器拆成n个点,表示是第几个加工的。套上模版,这题是求最小权,取一下相反数就行了。拆成两个集合一个存n个物品,另一个存第i个机器上第j个加工。 1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <cstd 阅读全文
posted @ 2013-04-17 21:15 Naix_x 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 题目链接最大的二分图带权匹配,KM算法模版题,抄的别人的。 1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <cstdio> 5 using namespace std; 6 #define N 301 7 #define INF 0x7fffffff 8 int mat[N][N]; 9 int match[N];10 int inx[N],iny[N];11 int lx[N],ly[N];12 int n;13 int dfs(int u)1 阅读全文
posted @ 2013-04-17 19:03 Naix_x 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 第一个最小割,理解了好一会。实数的最大流,注意eps,然后把乘法取log后变为加法。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <queue> 5 using namespace std; 6 #define eps 1e-8 7 #define INF 0x3f3f3f3f 8 int dis[201],first[201]; 9 int n,m,t; 10 struct node 11 { 12 int u,v,next,re; 13 doub 阅读全文
posted @ 2013-04-17 14:49 Naix_x 阅读(158) 评论(2) 推荐(0) 编辑
摘要: 题目链接比赛的时候题给看错了。。当作神题了,看了一下题解,思考了好一会,终于在虎哥的帮助下,明白了。求出所有的位置上s1[i]>=s2[i]的情况数,s1[i] <= s2[i]的情况数,小小的容斥一下,即可。中间各种错误,各种WA。 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 using namespace std; 5 #define LL __int64 6 #define MOD 1000000007 7 char s1[100001],s2[10000 阅读全文
posted @ 2013-04-16 21:14 Naix_x 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 题目链接看这个题解:http://blog.csdn.net/zhang20072844/article/details/8145588对于Tarjan还是不太理解。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 using namespace std; 6 #define N 10001 7 #define M 50001 8 struct node 9 {10 int u,v,next;11 } edge[M+10]; 阅读全文
posted @ 2013-04-16 19:52 Naix_x 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题目链接比赛的时候,无想法。。看了题解之后,很难理解。。上个CF上的组合DP,感觉都有类似之处把。。。dp[i][j]表示前i组有j个相邻左右都是相同系的位置。讲当前a[i]个人,可以分为k组,枚举u,假如这k组里,有u组在j个位置之中。此时相连的就变为j-u+a[i]-k了。各种组合乘起来。 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 #define MOD 1000000007 5 #define LL __int64 6 LL c[501][501]; 7 int a[501] 阅读全文
posted @ 2013-04-10 15:57 Naix_x 阅读(381) 评论(4) 推荐(0) 编辑
摘要: 最近跪了两场CF,rating直接回到解放前了,这场DIV2,第二题DP,我一直没贪过去,第三题,也看了,没啥想法。。。很神的组合题。先是亮的灯泡把暗的灯泡分成很多段,特殊考虑第一段和最后一段(如果存在)。然后中间每一段的组合方式是2^(a[i]-1)。然后就是把n个有顺序的数,插入m个有顺序的数字(fun函数)。注意精度神马的,各种细节。。 1 #include <cstdio> 2 #include <string> 3 using namespace std; 4 #define MOD 1000000007 5 #define LL __int64 6 int 阅读全文
posted @ 2013-04-09 21:06 Naix_x 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 题目链接以前的坑,以前做的时候,用暴力各种跪,其实是状态压缩DP。暴力处理出来后,状态+标记最后一个单词。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <iostream> 5 using namespace std; 6 char p[12][12]; 7 int o[12][12]; 8 int dp[1026][12]; 9 int dfs(int x,int y)10 {11 int i,j,k,len1,len2,ret,ans;12 le 阅读全文
posted @ 2013-04-02 20:20 Naix_x 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 看着DISCUSS各种改。。Tarjan每个点属于那个连通块,枚举度数,统计出度。如果出度为0的有一个,这个块的个数就是结果。出度为0的大于1,则没有。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 using namespace std; 6 #define N 10001 7 #define M 50001 8 struct node 9 { 10 int u,v,next; 11 } edge[M+10]; 12 i 阅读全文
posted @ 2013-04-01 21:06 Naix_x 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 题目链接写了久。DEBUG很久。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <map> 6 #include <queue> 7 #include <vector> 8 #include <algorithm> 9 using namespace std; 10 int dp1[101][101],dp2[101][101]; 11 int que[10 阅读全文
posted @ 2013-04-01 11:04 Naix_x 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Tarjan算法模版求强连通分量。 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 using namespace std; 6 #define N 10000 7 #define M 100000 8 struct node 9 {10 int u,v,next;11 }edge[M+10];12 int t,top,scnt;13 int DFN[N+1],Low[N+1],Belong[N+1],stack[N+1], 阅读全文
posted @ 2013-03-31 15:27 Naix_x 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 比较有意思的一个题,虽然不知道为什么这么做。。。看样例就可以发现一般是w_ _b wb_ _bw只能这样4种操作。。。没想到就这样过了。。注意了一下20个换行,2Y。。。我开始还在想bfs还想过,直接构造,构造不出来。。。 1 /* 2 ID:cuizhe 3 LANG: C++ 4 TASK: shuttle 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <map> 9 #include <algorithm> 10 #include <cstring> 11 # 阅读全文
posted @ 2013-03-29 14:29 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 44 下一页