上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页
摘要: 给一棵n个节点的树,覆盖m条树链,统计每个顶点和每条边被覆盖了多少次。 dfs1:标记深度、子树大小、找重儿子 dfs2:轻重链剖分 chain:覆盖一条树链 calc:统计每个顶点和每条边被覆盖了多少次 const int MAXN = 3e5 + 5; int n, m; vector<int> 阅读全文
posted @ 2021-03-10 19:04 purinliang 阅读(84) 评论(0) 推荐(0)
该文被密码保护。 阅读全文
posted @ 2021-03-09 21:35 purinliang 阅读(0) 评论(0) 推荐(0)
摘要: 简易的多项式。用来粗暴模拟。 struct Poly { static const int MAXN = 1e3 + 10; int deg, f[MAXN]; Poly() { deg = 0, memset(f, 0, sizeof(f)); } int& operator[](int inde 阅读全文
posted @ 2021-03-09 19:56 purinliang 阅读(95) 评论(0) 推荐(0)
摘要: 复杂度确定的分治算法(还带有一个最优性剪枝) const int MAXN = 2e5 + 10; const double MAXDIS = 1e20; int n; struct Point { double x, y; } p[MAXN]; double calc(int l, int r, 阅读全文
posted @ 2021-03-09 15:10 purinliang 阅读(102) 评论(0) 推荐(0)
摘要: https://codeforces.com/contest/1239/problem/C 人为规定事件的优先级 永续事件用个触发器触发 int n; ll p; ll ans[100005]; struct Event { ll Time; int Type, Id; bool operator< 阅读全文
posted @ 2021-03-09 03:13 purinliang 阅读(66) 评论(0) 推荐(0)
摘要: 使得队列可以快速求解出队列中的某些值,使用于没有逆元(最大最小值)或者逆元很难求(矩阵的逆(有时不存在))。 struct MinQueue { stack<pii> F; stack<pii> B; int Min() { int res = INF; if (!F.empty()) res = 阅读全文
posted @ 2021-03-09 01:06 purinliang 阅读(183) 评论(0) 推荐(0)
摘要: 匈牙利算法,优点:代码短 邻接矩阵:复杂度 \(O(n^3)\) 。邻接表:复杂度 \(O(nm)\) 。 /* nx X侧顶点的数量 ny Y侧顶点的数量 vis 顶点i是否在交错路中 cx X侧顶点i匹配的Y侧顶点 cy Y侧顶点i匹配的X侧顶点 */ const int MAXN = 500 阅读全文
posted @ 2021-03-08 19:18 purinliang 阅读(403) 评论(0) 推荐(0)
摘要: 期望复杂度 \(O(n)\) const double PI = acos(-1.0); const double EPS = 1e-10; double sqr(double x) { return x * x; } struct Point { double x, y; }; struct Ci 阅读全文
posted @ 2021-03-08 02:32 purinliang 阅读(89) 评论(0) 推荐(0)
摘要: https://codeforces.com/contest/320/problem/E 斜率优化dp https://codeforces.com/contest/631/problem/E 单调栈维护一个决策凸包,二分。 int n; ll a[200005]; ll sum[200005]; 阅读全文
posted @ 2021-03-04 01:24 purinliang 阅读(47) 评论(0) 推荐(0)
摘要: https://codeforces.com/contest/1281/problem/F 题意:每个顶点有两个权值b和w。最多3000个节点的树,分成恰好m个非空的连通块,使得尽可能多的连通块满足w的和严格大于b的和。 树上背包的套路题,这里背包 \(dp[i][j]\) 表示以i为根的子树,已经 阅读全文
posted @ 2021-03-02 21:32 purinliang 阅读(183) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 18 下一页