随笔分类 -  Guide---ACM/ICPC Beginning Steps

1
摘要:Kruscal Template :很裸的KruscalTemplate(求最小生成树中最长路,即最短路中最长路)//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler#include #include #include #in... 阅读全文
posted @ 2015-05-14 11:14 Jeremy Wu 阅读(278) 评论(0) 推荐(0) 编辑
摘要:使用快排也有一年多了,在此给出快排一个自己写的最简单的版本吧~Conference:http://www.cnblogs.com/foreverking/articles/2234225.htmlSourceCode:void quicksort (vector & v, int left, int... 阅读全文
posted @ 2015-03-30 15:52 Jeremy Wu 阅读(139) 评论(0) 推荐(0) 编辑
摘要:其实会用快速幂已经有好长一阵子了,但是一直没有写一篇入门快速幂的笔记。据说,在递推式优化上具有神奇的效果(效率很高)两矩阵相乘,朴素算法的复杂度是O(N^3)。如果求一次矩阵的M次幂,按朴素的写法就是O(N^3*M)。既然是求幂,不免想到快速幂取模的算法,这里有快速幂取模的介绍,a^b %m 的复杂... 阅读全文
posted @ 2015-03-03 15:26 Jeremy Wu 阅读(225) 评论(0) 推荐(0) 编辑
摘要:后缀数组的用处:快速求出两个后缀Suffix(i), Suffix(j)的最长公共前缀(LCP, Longest Common Perfix)后缀数组的应用先提出后缀数组的几种常用技巧:建议多找找与height数组的关联。将几个字符串贴在一起,用特殊符号间隔开:如aab与aaab,可合并成aab$a... 阅读全文
posted @ 2015-01-25 13:50 Jeremy Wu 阅读(173) 评论(0) 推荐(0) 编辑
摘要:Multiplyand pow Function://计算 (a*b)%c. a,b都是ll的数,直接相乘可能溢出的// a,b,c = c)a %= c; b >>= 1; } return ret;}//计算 x^n %cll pow_mod(ll x,ll n... 阅读全文
posted @ 2014-10-30 13:18 Jeremy Wu 阅读(182) 评论(0) 推荐(0) 编辑
摘要:EK Template :bool bfs(int src, int des){ memset(pre, -1, sizeof(pre)); while(!que.empty()) que.pop(); pre[src] = 0; int index; que.push... 阅读全文
posted @ 2014-08-11 20:11 Jeremy Wu 阅读(196) 评论(0) 推荐(0) 编辑
摘要:The Hungarian algorithm withThe adjacency matrix:计算最大匹配问题int n1, n2, m, ans;int res[MAXN];bool vis[MAXN], map[MAXN][MAXN];void init(){ int t1, t2; ... 阅读全文
posted @ 2014-08-06 11:33 Jeremy Wu 阅读(286) 评论(0) 推荐(0) 编辑
摘要:Gauss elimination:#include #include #include #include using namespace std;const int MAXN = 50;int a[MAXN][MAXN];//增广矩阵int x[MAXN];//解集bool free_x[MAXN... 阅读全文
posted @ 2014-07-28 23:27 Jeremy Wu 阅读(211) 评论(0) 推荐(0) 编辑
摘要:Dijkstra inAdjacency matrix :int Dijkstra(int src,int tec, int n){ bool done[1005]; int d[1005]; memset(done,0,sizeof(done)); map[0][src] ... 阅读全文
posted @ 2014-05-07 21:35 Jeremy Wu 阅读(642) 评论(0) 推荐(0) 编辑
摘要:Find Function Optimization:After Path compression:int find(int x){ return root[x] == x ? x : (root[x] = find(root[x]));}Avoid Stack overflow:int fi... 阅读全文
posted @ 2014-04-23 20:42 Jeremy Wu 阅读(239) 评论(0) 推荐(0) 编辑
摘要:以下资料来自:http://blog.csdn.net/Dinosoft/article/details/6795700http://qianmacao.blog.163.com/blog/static/203397180201222945212647/http://blog.csdn.net/qinmusiyan/article/details/7950642#HDU 1850 Being a Good Boy in Spring Festival下面是一个二人小游戏:桌子上有M堆扑克牌;每堆牌的数量分别为Ni(i=1…M);两人轮流进行;每走一步可以任意选择一堆并取走其中的任意张牌;桌子上 阅读全文
posted @ 2014-03-31 20:09 Jeremy Wu 阅读(416) 评论(0) 推荐(0) 编辑
摘要:以下资料摘自 http://www.cnblogs.com/wally/archive/2012/07/13/hdu1028_1085_1171_.html生成函数是说,构造这么一个多项式函数g(x),使得x的n次方系数为f(n)。对于母函数,看到最多的是这样两句话:1.“把组合问题的加法法则和幂级数的乘幂对应起来。”2.“把离散数列和幂级数一 一对应起来,把离散数列间的相互结合关系对应成为幂级数间的运算关系,最后由幂级数形式来确定离散数列的构造。 “例子:有1克、2克、3克、4克砝码各一枚,问能称出哪几种重量?每种重量各有几种方案?下面是用母函数解决这个问题的思路:首先,我们用X表示砝码,X 阅读全文
posted @ 2014-03-30 20:59 Jeremy Wu 阅读(375) 评论(1) 推荐(0) 编辑
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3324http://blog.csdn.net/xymscau/article/details/6776182 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 const int INF=1000100000; 9 struct node{10 int x,y;11 }n[1010];12 bool cmp(node a,node ... 阅读全文
posted @ 2014-03-26 21:57 Jeremy Wu 阅读(407) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2546http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=3361http://blog.sina.com.cn/s/blog_5123df350100e8p8.htmlhttp://blog.sina.com.cn/s/blog_51cea4040100gvn3.htmlhttp://blog.csdn.net/wukonwukon/article/details/6939050搬寝室Problem Description搬寝室 阅读全文
posted @ 2014-03-24 21:53 Jeremy Wu 阅读(640) 评论(0) 推荐(0) 编辑
摘要:终于开始DP了】HDOJ_1159 Common Subsequence题目链接Sample Inputabcfbc abfcabprogramming contest abcd mnp Sample Output 4 2 0子结构特征:lf(i,j)= f(i-1,j-1)+1 (a[i]==b[j]) max(f(i-1,j),f(i,j-1)) (a[i]!=b[j])由于f(i,j)只和f(i-1,j-1), f(i-1,j)和f(i,j-1)有关, 而在计算f(i,j)时, 只要选择一个合适的顺序, 就可以保证这三项都已经计算出来了, 这样就可以计算出f(i,j).... 阅读全文
posted @ 2014-03-24 11:04 Jeremy Wu 阅读(244) 评论(0) 推荐(0) 编辑
摘要:匈牙利算法样例程序格式说明输入格式:第1行3个整数,V1,V2的节点数目n1,n2,G的边数m第2-m+1行,每行两个整数t1,t2,代表V1中编号为t1的点和V2中编号为t2的点之间有边相连输出格式:1个整数ans,代表最大匹配数//邻接矩阵-C#include #include int n1,n... 阅读全文
posted @ 2014-03-21 22:27 Jeremy Wu 阅读(378) 评论(0) 推荐(0) 编辑
摘要:改革春风吹满地Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16889 Accepted Submission(s): 8636Problem Description“ 改革春风吹满地,不会AC没关系;实在不行回老家,还有一亩三分地。谢谢!(乐队奏乐)”话说部分学生心态极好,每天就知道游戏,这次考试如此简单的题目,也是云里雾里,而且,还竟然来这么几句打油诗。好呀,老师的责任就是帮你解决问题,既然想种田,那就分你一块。这块田位于浙... 阅读全文
posted @ 2014-03-19 22:18 Jeremy Wu 阅读(402) 评论(0) 推荐(0) 编辑
摘要:Attack of Panda VirusTime Limit:3 Seconds Memory Limit:32768 KBIn recent months, a computer virus spread across networks in China. The virus came with an icon of a lovely panda, hence the name Panda Virus. What makes this virus difficult to handle is that it has many variations.Unfortunately, our la 阅读全文
posted @ 2014-03-17 23:20 Jeremy Wu 阅读(242) 评论(0) 推荐(0) 编辑
摘要:FatMouse' TradeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 38780Accepted Submission(s): 12797Problem DescriptionFatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBe 阅读全文
posted @ 2014-03-17 23:15 Jeremy Wu 阅读(355) 评论(0) 推荐(0) 编辑
摘要:集训笔记 阅读全文
posted @ 2014-03-16 21:37 Jeremy Wu 阅读(384) 评论(0) 推荐(0) 编辑

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