随笔分类 -  模板

摘要:#include using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; const int MAXN = 5e5 + 100; const int MAXM = 3e3 + 10; template inline void read(T &x) { x = 0; T ff = 1, ch =... 阅读全文
posted @ 2019-05-12 13:06 海边微风起 阅读(163) 评论(0) 推荐(0)
摘要:#include using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; const int MAXN = 1e7 + 100; const int MAXM = 3e3 + 10; inline int read() { int x = 0, ff = 1; char ch = getchar... 阅读全文
posted @ 2019-03-28 19:55 海边微风起 阅读(143) 评论(0) 推荐(0)
摘要:最短路,即第1短路有很多种求法,SPFA,Dijkstra等,但第k短路怎么求呢?其实也是基于Dijkstra;因为Dijkstra用的是堆优化,这样保证每次弹出来的都是最小值,只是求最短路只是弹出一次就返回了,我们可以用Dijkstra弹出k个距离后再返回,这样根据弹出的先后顺序能够求出1~k短路 阅读全文
posted @ 2019-03-28 12:51 海边微风起 阅读(1075) 评论(1) 推荐(1)
摘要:#include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long inline int read() { int x = 0,ff = 1; char ch = ge... 阅读全文
posted @ 2019-03-28 06:33 海边微风起 阅读(137) 评论(0) 推荐(0)
摘要:#include using namespace std; inline int read() { int x = 0,ff = 1; char ch = getchar(); while(!isdigit(ch)) { if(ch == '-') ff = -1; ch = getchar(); } while(isdig... 阅读全文
posted @ 2019-03-27 20:47 海边微风起 阅读(192) 评论(0) 推荐(0)
摘要:#include using namespace std; #define ll long long #define INF 0x3f3f3f3f #define MAXN 300010 #define MAXM 3010 #define _ 0 inline int read() { int x = 0,ff = 1, ch = getchar(); while(!i... 阅读全文
posted @ 2019-03-26 13:48 海边微风起 阅读(176) 评论(0) 推荐(0)
摘要:给出一道例题 poj2823 我们知道,在暴力枚举的过程中,有一个地方是重复比较了,就是在找当前的f(i)的时候,i的前面其它m-1个数在算f(i-1)的时候我们就比较过了。当你一个个往下找时,每一次都是少一个然后多一个,如果少的不是最大值,然后再问新加进来的,看起来很省时间对吧,那么如果少了的是最 阅读全文
posted @ 2019-03-26 09:42 海边微风起 阅读(178) 评论(0) 推荐(0)
摘要:1.0/1背包 2.完全背包 3.多重背包 二进制优化: 阅读全文
posted @ 2019-03-25 11:00 海边微风起 阅读(127) 评论(0) 推荐(0)
摘要:题目描述 给出一个序列a, 求a的最长上升子序列 输入输出格式 输入格式: 第一行是一个数n, 接下来一行,每行为n个数 输出格式: 一个数,即最长上升子序列的长度 朴素版的lis是O(N ^ 2)的做法,这里就不在给出;当数据大时很容易被卡,通过二分优化 + 贪心可以优化成为O(NlogN),首先 阅读全文
posted @ 2019-03-13 13:52 海边微风起 阅读(639) 评论(0) 推荐(0)
摘要:题目描述 小C最近学了很多最小生成树的算法,Prim算法、Kurskal算法、消圈算法等等。正当小C洋洋得意之时,小P又来泼小C冷水了。小P说,让小C求出一个无向图的次小生成树,而且这个次小生成树还得是严格次小的,也就是说:如果最小生成树选择的边集是EM,严格次小生成树选择的边集是ES,那么需要满足 阅读全文
posted @ 2019-03-11 13:12 海边微风起 阅读(477) 评论(2) 推荐(1)
摘要:求的是最大强连通分量且字典序最小 阅读全文
posted @ 2019-02-16 20:22 海边微风起 阅读(139) 评论(0) 推荐(0)
摘要:#include using namespace std; #define INF 0x3f3f3f3f #define MAXN 1000010 #define MAXM 5010 inline int read() { int x = 0,ff = 1;char ch = getchar(); while(!isdigit(ch)) { if... 阅读全文
posted @ 2019-02-16 18:45 海边微风起 阅读(263) 评论(0) 推荐(0)
摘要:#include using namespace std; #define INF 0x3f3f3f3f #define MAXN 1000010 #define MAXM 5010 inline int read() { int x = 0,ff = 1;char ch = getchar(); while(!isdigit(ch)) { if... 阅读全文
posted @ 2019-02-16 18:02 海边微风起 阅读(207) 评论(0) 推荐(0)
摘要:#include using namespace std; #define INF 0x3f3f3f3f #define MAXN 100010 #define MAXM 5010 inline int read() { int x = 0,ff = 1;char ch = getchar(); while(!isdigit(ch)) { if(... 阅读全文
posted @ 2019-02-15 18:04 海边微风起 阅读(311) 评论(0) 推荐(0)
摘要:#include using namespace std; #define INF 0x3f3f3f3f #define MAXN 1000010 #define MAXM 5010 inline int read() { int x = 0,ff = 1;char ch = getchar(); while(!isdigit(ch)) { if... 阅读全文
posted @ 2019-02-13 18:52 海边微风起 阅读(275) 评论(0) 推荐(0)
摘要:#include using namespace std; #define INF 0x3f3f3f3f #define MAXN 1000010 #define MAXM 5010 inline int read() { int x = 0,ff = 1;char ch = getchar(); while(!isdigit(ch)) { if(... 阅读全文
posted @ 2019-02-13 18:22 海边微风起 阅读(387) 评论(0) 推荐(3)
摘要:大量图结构模板,可能会有帮助... 阅读全文
posted @ 2018-12-12 12:42 海边微风起 阅读(278) 评论(0) 推荐(0)