摘要:
在一段时间的分块相关学习过程中,我不出意料遇到了学习分块一定会遇到的问题——超时,于是我就开始了莫名其妙的调试和修改工作,下面列出最有代表性一道题。 首先我要积累两个经验 #define in long long会大幅增加常数,导致TLE STL的.clear()清空是O(n)的,很耽误时间,STL 阅读全文
摘要:
概念 最近公共祖先指两个节点在一棵树上深度最大的公共的祖先节点,即这两个点在这棵树上距离最近的公共祖先节点。 Tarjan 算法介绍 使用倍增思想和动态规划。 基本思路: 任选一个点为根节点,从根节点开始。 遍历该点 u 所有子节点 v ,并标记这些子节点 v 已被访问过。 若是 v 还有子节点,返 阅读全文
摘要:
#include<bits/stdc++.h> using namespace std; const int N = 1e5+10; int n, m, r, p, w[N]; int tot, h[N], e[2*N], nxt[2*N]; void add(int u, int v){ nxt[ 阅读全文
摘要:
#include<bits/stdc++.h> using namespace std; const int N = 1e7; int n, top = 1; struct Node{ int lc = 0, rc = 0, s = 0; } tr[N]; void pushup(int u){ t 阅读全文
摘要:
#include<bits/stdc++.h> using namespace std; const int N = 4e5+10; int n, idx, Y[2*N]; struct line{ long long o, u, z; int b; bool operator < (line x) 阅读全文