摘要: 建立结构体保存每个结点的前驱,操作符,来回两遍拓扑排序~ #include<bits/stdc++.h> using namespace std; const int maxn=50014; struct node { vector<int> pre; double data; int fuhao= 阅读全文
posted @ 2020-02-14 22:07 zlc0405 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 我们定义r[i][j] b[i][j]分别为以红色、黑色的点为根节点,black height为i,internel node数量为j的情况下,所能形成的树的种数。 易知b[1][1] = 1; r[0][1] = 1; b[1][2] = 2;,这是根节点具有null孩子结点的三种情况; 下面我们 阅读全文
posted @ 2020-02-14 21:43 zlc0405 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 二维dp,i表示删除几个字符,j表示当前遍历到第几个字符,注意判重复~ #include<bits/stdc++.h> using namespace std; const int maxn=1e6+14; string s; long long dp[5][maxn]; int main () { 阅读全文
posted @ 2020-02-14 21:41 zlc0405 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 先对所有点极角排序,再动态规划~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; struct node { double x,y,dx,dy; int id; }Node[maxn]; double dp[400] 阅读全文
posted @ 2020-02-14 21:39 zlc0405 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 双下标法寻找最长不重复子串~ #include<bits/stdc++.h> using namespace std; const int maxn=10014; int a[maxn],w[maxn]; int main () { int n; scanf ("%d",&n); for (int 阅读全文
posted @ 2020-02-14 21:37 zlc0405 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 删除字符的镜像问题,状态转移方程一样~ #include<bits/stdc++.h> using namespace std; const int maxn=1014; const int mod=1e9+7; string s; long long dp[maxn][maxn]; int mai 阅读全文
posted @ 2020-02-14 21:34 zlc0405 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 树链剖分,线段树维护~ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> using namespace std; const int MAXN = 1001 阅读全文
posted @ 2020-02-14 21:31 zlc0405 阅读(105) 评论(0) 推荐(0) 编辑
摘要: DFS遍历树,把时间轴投到线段树上,单点查询~ #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<string> using namespace std; const int maxn 阅读全文
posted @ 2020-02-14 20:38 zlc0405 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 线段树保存每个区间的左边最大连续长度和右边最大连续长度~ #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> using namespace std; const int 阅读全文
posted @ 2020-02-14 20:15 zlc0405 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 有两种操作,一是给区间内所有的数开根号,二是区间求和。 线段树单点更新,区间求和的模板~ #include<cstdio> #include<algorithm> #include<cmath> using namespace std; const int maxn=1e6+14; struct n 阅读全文
posted @ 2020-02-14 19:45 zlc0405 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 建两颗线段树分别存最大和最小值,模板题~ #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=1e6+14; struct node { int l; int r; in 阅读全文
posted @ 2020-02-14 19:00 zlc0405 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 给出每一线段的颜色,存在颜色覆盖,要求最后能看到的每种颜色及其段数 线段树区间更新~ #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=10014; struct no 阅读全文
posted @ 2020-02-14 18:31 zlc0405 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 给出两个字符串,询问有多少种反转方法可以使字符串1变成字符串2。 如果两个串相同,就用马拉车算法找回文串的数量~ 如果两个串不同,从前往后找第一个不同的位置l,从后往前找第二个不同的位置r,反转l和r,判断是否成功~ 如果不成功,记为0 如果成功,以l和r为起点判断是否能反转,记录次数 #inclu 阅读全文
posted @ 2020-02-14 15:32 zlc0405 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 初始的时候,整个序列都是1,接下来,每次输入l,r,x。表示将l到r之间修改为x且x只会是1、2、3,最后问你序列总和。 线段树成段更新~ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; cons 阅读全文
posted @ 2020-02-14 13:25 zlc0405 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 线段树+区间增量累加法lnc 区间更新,区间查询~ #include<cstdio> #include<algorithm> #include<iostream> using namespace std; typedef long long ll; const int maxn=1e6+14; st 阅读全文
posted @ 2020-02-14 11:27 zlc0405 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 简单线段树,单点更新,区间查询,自下向上更新结点的信息~ #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=1e6+14; struct node { int l; i 阅读全文
posted @ 2020-02-14 11:13 zlc0405 阅读(92) 评论(0) 推荐(0) 编辑