04 2013 档案

摘要:题目链接数据范围较小,直接离散后暴力。等等学习一下线段树的思路。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <algorithm> 5 using namespace std; 6 #define N 101 7 #define eps 1e-6 8 double xr[N],xc[N],yr[N],yc[N]; 9 double x[3*N],y[3*N];10 int dblcmp(double x)11 {12 if(fabs(x) < 阅读全文
posted @ 2013-04-24 15:44 Naix_x 阅读(188) 评论(0) 推荐(0)
摘要:题目链接此题挺裸的模版的,然后多组的判断,让我WA了很多次,用flag标记一下,就好。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define N 60000 6 #define C_NUM 128 7 int trie[N][C_NUM]; 8 int o[N],fail[N],que[N],flag[N]; 9 int t,num; 10 void CL() 11 { 12 memset(trie,-1,sizeo 阅读全文
posted @ 2013-04-24 14:10 Naix_x 阅读(396) 评论(0) 推荐(0)
摘要:题目链接这题在经过强哥讲解,看了很多题解之后AC了,矩阵乘法回顾了一下,然后AC自动机换了一份模版。。。慢慢理解。。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string> 5 using namespace std; 6 #define N 1000001 7 #define LL __int64 8 int t; 9 int tire[N][4]; 10 int que[N]; 11 int o[N]; 12 int fail[N]; 13 阅读全文
posted @ 2013-04-24 10:22 Naix_x 阅读(159) 评论(0) 推荐(0)
摘要:题目链接比着模版改的。改成静态的,一直在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 阅读(264) 评论(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 阅读(153) 评论(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 阅读(150) 评论(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 阅读(195) 评论(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 阅读(164) 评论(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 阅读(161) 评论(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 阅读(304) 评论(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 阅读(138) 评论(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 阅读(393) 评论(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 阅读(259) 评论(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 阅读(179) 评论(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 阅读(138) 评论(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 阅读(165) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示