摘要: 题目: 乔治有一些同样长的小木棍,他把这些木棍随意砍成几段,直到每段的长都不超过$50$。现在,他想把小木棍拼接成原来的样子,但是却忘记了自己开始时有多少根木棍和它们的长度。给出每段小木棍的长度,编程帮他找出原始木棍的最小可能长度。 分析: 可以很轻易的写出$\rm dfs$的程序: 1 #incl 阅读全文
posted @ 2018-08-23 10:23 zhylj 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 为了方便,我们不妨设$\rm P \lt Q,R$ 我们发现,有$\rm E$点在$\rm AB$上,$\rm F$点在$\rm CD$上,最优解一定是$\rm AE\rightarrow EF\rightarrow FD$,因为若中途离开某个传送带再回来,显然是不优的。 考虑固定点$E$,观察点$ 阅读全文
posted @ 2018-08-23 07:57 zhylj 阅读(306) 评论(0) 推荐(0) 编辑
摘要: Luogu P3367 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 const int MAXN = 2e5; 6 7 int fa[MAXN]; 8 9 int find(int x) { 10 return fa[x] == x 阅读全文
posted @ 2018-08-22 11:40 zhylj 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Splay(Tyvj 1728/Bzoj 3224 普通平衡树) 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 struct node { 6 int data, size, cnt; 7 node *child[2], *fathe 阅读全文
posted @ 2018-08-22 06:48 zhylj 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 树状数组: 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 const int MAXN = 5e5 + 5; 6 7 struct binit { 8 int a[MAXN], n; 9 void modify(int x, int 阅读全文
posted @ 2018-08-22 06:46 zhylj 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Dinic: 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 const int MAXN = 1e5 + 5, inf = 0x7f7f7f7f; 6 7 struct edge { 8 int to, nxt, cap; 9 } e 阅读全文
posted @ 2018-08-22 06:43 zhylj 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 优先队列优化的Dijkstra: 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 const int MAXN = 5e5 + 5, inf = 0x3f3f3f3f; 6 7 struct point { 8 int id, dis; 阅读全文
posted @ 2018-08-22 06:42 zhylj 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 裸的单调队列优化dp+二分 我居然还调了挺久 日常审题错误 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 typedef long long ll; 6 7 const ll inf = 1e9, MAXN = 5e5 + 5; 8 阅读全文
posted @ 2018-08-20 09:55 zhylj 阅读(649) 评论(0) 推荐(0) 编辑
摘要: 对于每个数$a_i$,易得它对答案的贡献为 它左边比它小的数的个数$\times$它右边比它大的数的个数。可以离散化后再处理也可以使用动态开点的线段树。我使用了动态开点的线段树,只有需要用到这个节点的时候才新建这个节点,这里我是在进行修改的时候新建的。时间复杂度$O(n\log \rm MAX\_I 阅读全文
posted @ 2018-08-17 13:04 zhylj 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 线段树优化$\rm dijkstra$线段树每个节点维护$[l,r]$中$dist$最小的点,删除则把该点$dist$赋值为$+\infty$,然后更新该点影响到的线段树上的其他节点即可。可以得到“更新该节点影响到的线段树上的其他节点”部分的代码:(线段树数组$\rm st[]$) 然后$\rm d 阅读全文
posted @ 2018-08-17 10:44 zhylj 阅读(305) 评论(0) 推荐(0) 编辑