<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>tom0727's blog</title><link>https://tom0727.github.io/</link><description>Recent content on tom0727's blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 27 May 2022 12:43:51 +0800</lastBuildDate><atom:link href="https://tom0727.github.io/index.xml" rel="self" type="application/rss+xml"/><item><title>[置顶]竞赛注意事项/通用模版</title><link>https://tom0727.github.io/post/072-%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9-%E9%80%9A%E7%94%A8%E6%A8%A1%E7%89%88/</link><pubDate>Mon, 19 Sep 2022 10:26:35 -0500</pubDate><guid>https://tom0727.github.io/post/072-%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9-%E9%80%9A%E7%94%A8%E6%A8%A1%E7%89%88/</guid><description>注意事项 Set中的Comparator定义 在定义Set的Comparator时，一定要小心保证元素不会因为定义被判定为重复，例如： • 注意这里</description></item><item><title>一些数论性质与方法</title><link>https://tom0727.github.io/post/119-%E6%95%B0%E8%AE%BA%E6%80%A7%E8%B4%A8/</link><pubDate>Sat, 21 Oct 2023 19:17:29 -0500</pubDate><guid>https://tom0727.github.io/post/119-%E6%95%B0%E8%AE%BA%E6%80%A7%E8%B4%A8/</guid><description>结论 因数个数 对于一个数 $n$，它的因数个数的数量级为 $O(n^{\frac{1}{3}})$。 小于 $n$ 的质数个数 小于 $n$ 的质数个数为 $O(\frac{n}{\log n})$。</description></item><item><title>Splay</title><link>https://tom0727.github.io/post/118-splay/</link><pubDate>Mon, 16 Oct 2023 21:57:15 -0500</pubDate><guid>https://tom0727.github.io/post/118-splay/</guid><description>介绍 Splay 是一种自平衡的 BST（二叉搜索树）。 模版 代码 struct Splay { struct Node { int par, child[2], sz, cnt; ll val, flag; } tr[maxn]; int rt, id = 0; void push_up(int cur) { if (!cur) return; int lc = tr[cur].child[0], rc = tr[cur].child[1]; tr[cur].sz = tr[lc].sz + tr[rc].sz + tr[cur].cnt; } void push_down(int</description></item><item><title>扫描线</title><link>https://tom0727.github.io/post/117-%E6%89%AB%E6%8F%8F%E7%BA%BF/</link><pubDate>Sat, 07 Oct 2023 12:29:25 -0500</pubDate><guid>https://tom0727.github.io/post/117-%E6%89%AB%E6%8F%8F%E7%BA%BF/</guid><description>介绍 扫描线是一种思想，本质上是利用了线段树。可以用来处理 矩形面积并，矩形周长并 等经典问题。 如图，我们用一条竖着的线从左到右扫描。我们将每一个</description></item><item><title>可并堆/左偏树</title><link>https://tom0727.github.io/post/116-%E5%8F%AF%E5%B9%B6%E5%A0%86/</link><pubDate>Wed, 04 Oct 2023 16:05:48 -0500</pubDate><guid>https://tom0727.github.io/post/116-%E5%8F%AF%E5%B9%B6%E5%A0%86/</guid><description>介绍 可并堆是一种特殊的最小/大堆，使得两个堆之间能用 $O(\log n)$ 的时间内进行合并。由于其形态，也叫左偏树。 定义 距离：一个节点 $x$ 的距离 dis[x] 定义为：$x$</description></item><item><title>线段树优化建图</title><link>https://tom0727.github.io/post/115-%E7%BA%BF%E6%AE%B5%E6%A0%91%E4%BC%98%E5%8C%96%E5%BB%BA%E5%9B%BE/</link><pubDate>Mon, 04 Sep 2023 23:51:58 -0500</pubDate><guid>https://tom0727.github.io/post/115-%E7%BA%BF%E6%AE%B5%E6%A0%91%E4%BC%98%E5%8C%96%E5%BB%BA%E5%9B%BE/</guid><description>介绍 线段树优化建图用于解决图中边数过多，不能直接建的问题。 直接看例题： 例1 CF786B. Legacy 题意 给定 $n$ 个点的有向带权图，初始状态下图中没有边。给定 $q$ 个操作</description></item><item><title>笛卡尔树</title><link>https://tom0727.github.io/post/114-%E7%AC%9B%E5%8D%A1%E5%B0%94%E6%A0%91/</link><pubDate>Fri, 01 Sep 2023 11:14:35 -0500</pubDate><guid>https://tom0727.github.io/post/114-%E7%AC%9B%E5%8D%A1%E5%B0%94%E6%A0%91/</guid><description>定义 笛卡尔树是一种二叉树，每一个结点由一个键值二元组 $(k,v)$ 构成。 性质 $k$ 满足 BST 的性质 $v$ 满足 min-heap 的性质。 如果笛卡尔树的 $k,v$ 值确定，且 $k$ 互不相同，$v$ 互</description></item><item><title>整体二分</title><link>https://tom0727.github.io/post/113-%E6%95%B4%E4%BD%93%E4%BA%8C%E5%88%86/</link><pubDate>Sat, 15 Jul 2023 22:57:54 -0500</pubDate><guid>https://tom0727.github.io/post/113-%E6%95%B4%E4%BD%93%E4%BA%8C%E5%88%86/</guid><description>介绍 整体二分是一种思想，用于同时二分多组询问，在题目满足以下条件时可以用： 有多组询问，每组询问可以通过二分解决。 询问离线。 询问之间互相独立。</description></item><item><title>线性筛</title><link>https://tom0727.github.io/post/112-%E7%BA%BF%E6%80%A7%E7%AD%9B/</link><pubDate>Sun, 04 Jun 2023 18:25:03 -0500</pubDate><guid>https://tom0727.github.io/post/112-%E7%BA%BF%E6%80%A7%E7%AD%9B/</guid><description>介绍 线性筛不仅能用 $O(n)$ 求出每一个数是否为质数，它还能求出每一个数的因数数量，因数和，甚至更加general的除数函数，莫比乌斯函数等等。 总结来</description></item><item><title>NAC2023 Training Camp Day2</title><link>https://tom0727.github.io/post/111-nac2023-day2/</link><pubDate>Sat, 27 May 2023 17:07:31 -0400</pubDate><guid>https://tom0727.github.io/post/111-nac2023-day2/</guid><description>A. Fair Bandwidth Sharing 题意 给定 $n$ 个区间 $[l_i, r_i]$，并且给定 $n$ 个权值 $d_i$，和一个常数 $t$。 定义 $y_i = t \frac{d_i}{\sum\limits_{j=1}^n d_j}$。 求一组 $x_i$，使得满足以下所</description></item><item><title>随机化</title><link>https://tom0727.github.io/post/110-%E9%9A%8F%E6%9C%BA%E5%8C%96/</link><pubDate>Sat, 27 May 2023 09:22:42 -0400</pubDate><guid>https://tom0727.github.io/post/110-%E9%9A%8F%E6%9C%BA%E5%8C%96/</guid><description>构造题的应用 在 $n$ 较小时，确定一个随机数的seed mt19937 rng(SOME_SEED);，如果在本地成功跑出来结果，就直接把这个seed交上去，这样</description></item><item><title>CodeSprint UCLA 2023</title><link>https://tom0727.github.io/post/109-codesprintla2023/</link><pubDate>Mon, 22 May 2023 10:56:21 -0500</pubDate><guid>https://tom0727.github.io/post/109-codesprintla2023/</guid><description>L. Blooper Game 题意 给定 $n$ 个概率 $S_1, S_2, &amp;hellip;, S_n$，同时给定一个实数 $P \in (0,1)$。 现在有 $L$ 次操作机会，每次操作可以选择一个 $S_i$，让 $S_i = (S_i)</description></item><item><title>Universal Cup 15 (Hangzhou)</title><link>https://tom0727.github.io/post/108-universal15/</link><pubDate>Thu, 18 May 2023 23:54:00 -0500</pubDate><guid>https://tom0727.github.io/post/108-universal15/</guid><description>L. Barkley 题意 给定长度为 $n$ 的数组 $a_i$，有 $q$ 个询问，每次询问为 $l~r~k$ 回答在 $[l,r]$ 这个区间内，可以去掉至多 $k$ 个数后，得到的最大 gcd 是多少？ 其中，$n \leq 10^5, q</description></item><item><title>线段树分治</title><link>https://tom0727.github.io/post/107-%E7%BA%BF%E6%AE%B5%E6%A0%91%E5%88%86%E6%B2%BB/</link><pubDate>Wed, 17 May 2023 17:42:06 -0500</pubDate><guid>https://tom0727.github.io/post/107-%E7%BA%BF%E6%AE%B5%E6%A0%91%E5%88%86%E6%B2%BB/</guid><description>介绍 线段树分治一般用于处理一些 “只存在/不存在 权值为 $w$“，或者 ”某个特定时间点” 对应状态的问题。 原理是在线段树上进行 DFS，进入 DFS 时加入</description></item><item><title>DFS/BFS树</title><link>https://tom0727.github.io/post/106-dfs-bfs-tree/</link><pubDate>Mon, 15 May 2023 23:50:50 -0500</pubDate><guid>https://tom0727.github.io/post/106-dfs-bfs-tree/</guid><description>介绍 在一个 无向图 中，DFS树是一个生成树（包含 $n-1$ 条边）。DFS树是在DFS过程中，如果从 dfs(u) 走到 dfs(v)，那么 $(u,v)$ 这条边将会加入DFS树。 B</description></item><item><title>NAC2020</title><link>https://tom0727.github.io/post/105-nac2020/</link><pubDate>Mon, 03 Apr 2023 19:24:17 -0500</pubDate><guid>https://tom0727.github.io/post/105-nac2020/</guid><description>G. ICPC Camp 题意 给定一个整数 $n$，和两个长度分别为 $p,q$ 的数组，$a_1,a_2,&amp;hellip;,a_p$ 和 $b_1,b_2,&amp;hellip;,b</description></item><item><title>CF1862F题解</title><link>https://tom0727.github.io/post/104-cf1862f/</link><pubDate>Sun, 02 Apr 2023 23:43:29 -0500</pubDate><guid>https://tom0727.github.io/post/104-cf1862f/</guid><description>CF1805F1. Survival of the Weakest (easy version) 题意 给定一个数组 $a_1,a_2&amp;hellip;,a_n$，定义 $F(a_1,a_2,&amp;hellip;,a_n)$ 为如下的函数： $F(a_1,a_2,&amp;hellip;,a_n)$ 将会在 $\forall 1\leq i &amp;lt; j \leq n$ 中，选取最小的 $n-1$ 个 $a_</description></item><item><title>Bitset优化</title><link>https://tom0727.github.io/post/103-bitset/</link><pubDate>Thu, 30 Mar 2023 22:13:18 -0500</pubDate><guid>https://tom0727.github.io/post/103-bitset/</guid><description>bitset作为C++自带的数据结构，利用bit储存信息，由于 1 byte = 8 bits，并且一个int就有 4 bytes，所以通常情况下用 bitset 可以达到 32</description></item><item><title>后缀数组</title><link>https://tom0727.github.io/post/102-%E5%90%8E%E7%BC%80%E6%95%B0%E7%BB%84/</link><pubDate>Wed, 22 Mar 2023 11:30:39 -0500</pubDate><guid>https://tom0727.github.io/post/102-%E5%90%8E%E7%BC%80%E6%95%B0%E7%BB%84/</guid><description>模版 代码(nlogn) // sa[i]：所有的后缀排序后，第 $i$ 小的后缀的编号。（排第 $i$ 名的是 sa[i] 这个后缀）。 // rk[i]：后缀 $i$（指 s[i...n]) 的排名。</description></item><item><title>二维ST表</title><link>https://tom0727.github.io/post/101-%E4%BA%8C%E7%BB%B4st%E8%A1%A8/</link><pubDate>Tue, 21 Mar 2023 23:33:04 -0500</pubDate><guid>https://tom0727.github.io/post/101-%E4%BA%8C%E7%BB%B4st%E8%A1%A8/</guid><description>介绍 二维ST表就是在一维的ST表上加一个维度，这样可以 $O(nm\log n \log m)$ 内预处理以后，$O(1)$ 询问一个矩阵的最大/最小值。 例题 例1 洛谷P2216[</description></item><item><title>Universal Cup 8 (Slovenia)</title><link>https://tom0727.github.io/post/100-universal8/</link><pubDate>Sun, 19 Mar 2023 22:24:00 -0500</pubDate><guid>https://tom0727.github.io/post/100-universal8/</guid><description>C. Constellations 题意 二维平面中有 $n$ 个点，一开始每个点都属于自己的一组。 有 $n-1$ 轮合并过程，每次合并选择距离最近的两组点进行合并，两组点 $A,B$ 之间的距离定义为： $$d(A,B)</description></item><item><title>二项式反演</title><link>https://tom0727.github.io/post/099-%E4%BA%8C%E9%A1%B9%E5%BC%8F%E5%8F%8D%E6%BC%94/</link><pubDate>Sun, 12 Mar 2023 22:40:28 -0500</pubDate><guid>https://tom0727.github.io/post/099-%E4%BA%8C%E9%A1%B9%E5%BC%8F%E5%8F%8D%E6%BC%94/</guid><description>介绍 二项式反演是一种特殊的容斥，用来解决 &amp;ldquo;恰好选 $k$ 个的方案有多少种&amp;rdquo; 的问题。 一般，我们可以求出 &amp;ldquo;至多/至</description></item><item><title>NAC2022</title><link>https://tom0727.github.io/post/098-nac2022/</link><pubDate>Sun, 05 Mar 2023 18:59:57 -0600</pubDate><guid>https://tom0727.github.io/post/098-nac2022/</guid><description>G. Rafting Trip 题意 给定一个 $n \times m$ 的网格，每个网格要么是河流，要么是陆地。 如果是河流，那么它一定是上下左右四个方向之一，代表走到这个位置，下一个位置就</description></item><item><title>吉司机线段树（Segment Tree Beats）</title><link>https://tom0727.github.io/post/097-segment-tree-beats/</link><pubDate>Wed, 22 Feb 2023 15:48:08 -0600</pubDate><guid>https://tom0727.github.io/post/097-segment-tree-beats/</guid><description>介绍 吉司机线段树可以做到： 区间最大/最小操作（对一个区间内的所有数取 max 或者 min） 维护区间历史最值 我们直接看一道例题： 题意 给定一个数组 $a_1, a_2, &amp;hellip;</description></item><item><title>01BFS 最短路</title><link>https://tom0727.github.io/post/096-bfs01/</link><pubDate>Mon, 20 Feb 2023 23:51:42 -0600</pubDate><guid>https://tom0727.github.io/post/096-bfs01/</guid><description>老是忘，简单记录一下吧。 介绍 一个边权仅为 $0,1$ 的图中跑最短路可以直接用 bfs。 维护一个 deque，每次更新 dis[v] 时就将 v push进去，如果 w(u,v) == 0 就p</description></item><item><title>三元环计数</title><link>https://tom0727.github.io/post/095-%E4%B8%89%E5%85%83%E7%8E%AF%E8%AE%A1%E6%95%B0/</link><pubDate>Mon, 06 Feb 2023 22:06:05 -0600</pubDate><guid>https://tom0727.github.io/post/095-%E4%B8%89%E5%85%83%E7%8E%AF%E8%AE%A1%E6%95%B0/</guid><description>介绍 给定一个无向图，找出图中所有的三元环，每个环只能被计一次。(比如 $a,b,c$ 和 $b,a,c$ 都是同一个环)。 我们先处理出每个点的 degree，然后建一个新的图</description></item><item><title>博弈论与SG函数</title><link>https://tom0727.github.io/post/094-%E5%8D%9A%E5%BC%88%E8%AE%BA/</link><pubDate>Fri, 20 Jan 2023 13:51:32 -0600</pubDate><guid>https://tom0727.github.io/post/094-%E5%8D%9A%E5%BC%88%E8%AE%BA/</guid><description>公平组合游戏 公平组合游戏 Impartial Combinatorial Game (ICG) 满足以下性质： 有 $2$ 名玩家。 $2$ 名玩家轮流操作，在一个游戏集合中选其中一个进行操作。 对于任意一个合法的局面，当前</description></item><item><title>2-SAT</title><link>https://tom0727.github.io/post/093-2sat/</link><pubDate>Mon, 09 Jan 2023 18:27:02 -0600</pubDate><guid>https://tom0727.github.io/post/093-2sat/</guid><description>模版 struct Edge { int from, to, nxt; }; int n; // 变量个数 struct SAT2 { // from[u] 代表 u 所在的SCC编号，scc代表scc编号，sz[scc] 代表对应scc的大小 int dfn[maxn], low[maxn], id, from[maxn], scc = 0,</description></item><item><title>二进制枚举子集</title><link>https://tom0727.github.io/post/092-%E6%9E%9A%E4%B8%BE%E5%AD%90%E9%9B%86/</link><pubDate>Sat, 07 Jan 2023 11:57:31 -0600</pubDate><guid>https://tom0727.github.io/post/092-%E6%9E%9A%E4%B8%BE%E5%AD%90%E9%9B%86/</guid><description>介绍 我们希望在二进制下枚举所有的 mask，并且枚举每个mask的所有子集。 for (int mask = 0; mask &amp;lt; (1 &amp;lt;&amp;lt; n); mask++) { // i 枚举所有物体的选择情况 for (int sub = mask; sub; sub =</description></item><item><title>容斥原理</title><link>https://tom0727.github.io/post/091-%E5%AE%B9%E6%96%A5%E5%8E%9F%E7%90%86/</link><pubDate>Sat, 31 Dec 2022 21:16:36 -0600</pubDate><guid>https://tom0727.github.io/post/091-%E5%AE%B9%E6%96%A5%E5%8E%9F%E7%90%86/</guid><description>介绍 容斥原理用于计算集合的 union 和 intersection 的大小。 集合的 Union: $$|\bigcup_{i=1}^{n} S_i| = \sum_{i} |S_i| - \sum_{i &amp;lt; j} |S_i \cap S_j| + \sum_{i &amp;lt; j &amp;lt; k} |S_i \cap S_j \cap S_k| - &amp;hellip; + (-1)^{n-1} |S_1 \cap &amp;hellip; \cap S_n|$$ 集合的 Intersection = 全集 - 补集的并集 $$|\bigcap_{i=1}^n</description></item><item><title>点分治</title><link>https://tom0727.github.io/post/090-%E7%82%B9%E5%88%86%E6%B2%BB/</link><pubDate>Thu, 29 Dec 2022 16:07:08 -0600</pubDate><guid>https://tom0727.github.io/post/090-%E7%82%B9%E5%88%86%E6%B2%BB/</guid><description>介绍 点分治用于处理 树上的路径问题。 点分治的主要思想是，对于一棵子树，子树内的所有路径只有两种情况： 不经过根节点 经过根节点 对于第一种，我们可以</description></item><item><title>树状数组二分</title><link>https://tom0727.github.io/post/089-%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84%E4%BA%8C%E5%88%86/</link><pubDate>Tue, 27 Dec 2022 23:39:23 -0600</pubDate><guid>https://tom0727.github.io/post/089-%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84%E4%BA%8C%E5%88%86/</guid><description>这篇 blog 记录一个树状数组上二分的小技巧。 介绍 对于树状数组，我们知道它支持 $O(\log n)$ 内进行如下操作： 单点修改 前缀和查询 现在我们希望它用 $O(\log n)$ 支持第三种操</description></item><item><title>2020-2021 ICPC NERC (NEERC), North-Western Russia Regional Contest</title><link>https://tom0727.github.io/post/088-icpc-2020-neerc-regional/</link><pubDate>Mon, 26 Dec 2022 23:07:50 -0600</pubDate><guid>https://tom0727.github.io/post/088-icpc-2020-neerc-regional/</guid><description>L. Lost Permutation 题意 交互题。 有一个隐藏的 permutation $\pi$，长度为 $n$。 现在只有一种询问： $? ~f_1 ~f_2 &amp;hellip; ~f_n$：给定一个 permutation $f$，系统会回答你一个 permutation $g$，</description></item><item><title>树同构</title><link>https://tom0727.github.io/post/087-%E6%A0%91%E5%90%8C%E6%9E%84/</link><pubDate>Sun, 25 Dec 2022 18:14:24 -0600</pubDate><guid>https://tom0727.github.io/post/087-%E6%A0%91%E5%90%8C%E6%9E%84/</guid><description>介绍 两个树同构 $\iff$ 有且仅有一种重新编号方式，使得一棵树的节点重新编号后得到另外一棵树。 • 如果是有根树同构，那么还要额外加一个限制条件：树的节点</description></item><item><title>树的重心</title><link>https://tom0727.github.io/post/086-%E6%A0%91%E7%9A%84%E9%87%8D%E5%BF%83/</link><pubDate>Fri, 23 Dec 2022 22:49:22 -0600</pubDate><guid>https://tom0727.github.io/post/086-%E6%A0%91%E7%9A%84%E9%87%8D%E5%BF%83/</guid><description>定义 树的重心是指： 在一棵无权无根树中，对于每一个点 $u$，计算它所有子树中最大的子树的节点数，这个最大值最小的点 $u$ 就是树的重心。 性质 点 $u$ 为重</description></item><item><title>2019 Jakarta Regional</title><link>https://tom0727.github.io/post/085-icpc-2019-jakarta-regional/</link><pubDate>Fri, 23 Dec 2022 18:57:28 -0600</pubDate><guid>https://tom0727.github.io/post/085-icpc-2019-jakarta-regional/</guid><description>K. Addition Robot 题意 给定 $n$ 个字母 $s_1, s_2 &amp;hellip;, s_n$，每个字母要么为 $A$ 要么为 $B$。 现在有 $Q$ 个询问，每个询问有两种类型： $1 ~ L ~ R$：将 $i \in [L,R]$ 的所有 $A$ 改成 $</description></item><item><title>2021 NERC</title><link>https://tom0727.github.io/post/084-icpc-2021-nerc/</link><pubDate>Tue, 20 Dec 2022 16:57:11 -0600</pubDate><guid>https://tom0727.github.io/post/084-icpc-2021-nerc/</guid><description>CF1666J Job Lookup 题意 给定一个 $n \times n$ 的矩阵 $c_{ij}$。 求一个BST，使得 $\sum\limits_{i,j} c_{ij} \cdot d_{ij}$ 最小。 其中，$d_{ij}$ 代表节点 $i,j$ 在BST中的距离。 输出这个 BST</description></item><item><title>2022 NERC Regional</title><link>https://tom0727.github.io/post/083-icpc-2022-nerc-regional/</link><pubDate>Sun, 04 Dec 2022 23:48:35 -0600</pubDate><guid>https://tom0727.github.io/post/083-icpc-2022-nerc-regional/</guid><description>A. Access Levels 题意 有 $n$ 个程序员，$m$ 个文档。 给定一个 $n \times m$ 的矩阵 $a$，其中 $a_{ij} = 1$ 表示程序员 $i$ 可以访问文档 $j$，否则不行。 现在我们需要选择一个数</description></item><item><title>线性规划</title><link>https://tom0727.github.io/post/082-%E7%BA%BF%E6%80%A7%E8%A7%84%E5%88%92/</link><pubDate>Tue, 29 Nov 2022 22:05:01 -0600</pubDate><guid>https://tom0727.github.io/post/082-%E7%BA%BF%E6%80%A7%E8%A7%84%E5%88%92/</guid><description>介绍 线性规划问题一般表示为如下： 给定 $c_j, a_{ij}, b_i$，求 $x$ 的值使得 $$\max_x \sum_{j=1}^d c_jx_j$$ 其中 $$\sum_{j=1}^d a_{ij} x_j \leq b_i, \forall i = 1&amp;hellip;n$$ $$x_j \geq 0, \forall j = 1&amp;hellip;d$$ 等价的，可以把上式写作： $$\max_x ~ c \cdot x$$ 其</description></item><item><title>KMP</title><link>https://tom0727.github.io/post/081-kmp/</link><pubDate>Sat, 29 Oct 2022 11:43:01 -0500</pubDate><guid>https://tom0727.github.io/post/081-kmp/</guid><description>介绍 KMP算法能在 $O(n)$ 的时间内，求出一个字符串的每个前缀的最长 border 长度。 利用 border 的性质，也可以在 $O(n)$ 的时间内，求出一个字符串 $t$ 在文本串 $s$ 中出现的所有</description></item><item><title>Treap</title><link>https://tom0727.github.io/post/080-treap/</link><pubDate>Fri, 28 Oct 2022 17:44:57 -0500</pubDate><guid>https://tom0727.github.io/post/080-treap/</guid><description>介绍 Treap是一个自平衡的 BST (Binary Search Tree)。与普通BST不同的在于，每个节点会有一个随机的优先级 (priority/rank)，在不破坏 BST</description></item><item><title>Meissel-Lehmer算法</title><link>https://tom0727.github.io/post/079-meissel-lehmer/</link><pubDate>Mon, 24 Oct 2022 00:02:14 -0500</pubDate><guid>https://tom0727.github.io/post/079-meissel-lehmer/</guid><description>介绍 给定一个正整数 $n$，Meissel-Lehmer算法用于求 $\leq n$ 的质数数量。 时间复杂度：$O(\frac{n^{\frac{2}{3}}</description></item><item><title>COMPFEST13</title><link>https://tom0727.github.io/post/078-icpc-compfest13/</link><pubDate>Sun, 23 Oct 2022 23:48:58 -0500</pubDate><guid>https://tom0727.github.io/post/078-icpc-compfest13/</guid><description>B. Building an Amusement Park 题意 二维平面上给定 $n$ 个点，求一个最小的圆，使得： $(0,0)$ 在圆上。 圆内（包括圆上）包含至少 $k$ 个点。 输出最小圆半径。 其中，$1 \leq n \leq 10^5, 1 \leq k</description></item><item><title>2020-2021 ICPC, NERC, Southern and Volga Russian Regional Contest</title><link>https://tom0727.github.io/post/077-icpc-2020-nerc-regional/</link><pubDate>Mon, 17 Oct 2022 13:51:05 -0500</pubDate><guid>https://tom0727.github.io/post/077-icpc-2020-nerc-regional/</guid><description>G. Hobbits 题意 二维平面上有 $n$ 个点，第 $i$ 个点的坐标是 $(x_i,y_i)$，其中 $x_i &amp;lt; x_{i+1}, \forall i \in [1, n-1]$，点 $i$ 与点 $(i+1)$ 之间由一条线段链接。 在 $(x_n, y_n + H)$ 位</description></item><item><title>SWERC 2021-2022</title><link>https://tom0727.github.io/post/076-icpc-2021-swerc/</link><pubDate>Mon, 10 Oct 2022 13:32:05 -0500</pubDate><guid>https://tom0727.github.io/post/076-icpc-2021-swerc/</guid><description>D. Evolution of Weasels 题意 给定两个字符串 $s,t$，字符串中仅包含 $ABC$ 这三个字母。 我们对于 $s$ 可以在任意位置增加/删除子串 $AA,BB,CC,ABAB,BCB</description></item><item><title>MAPS 2022</title><link>https://tom0727.github.io/post/075-icpc2022maps/</link><pubDate>Mon, 10 Oct 2022 13:30:58 -0500</pubDate><guid>https://tom0727.github.io/post/075-icpc2022maps/</guid><description>M. Yet Another Divisor Problem 题意 设 $f(n)$ 为正整数 $n$ 的 divisor 个数。 给定 $a, b$，求有多少个满足以下条件的数 $n$？ $n$ 是奇数。 $n \in [a,b]$。 $f(f(n^n))$ 是 $n$ 的 divisor。 其中</description></item><item><title>NAQ 2019</title><link>https://tom0727.github.io/post/074-icpc2019naq/</link><pubDate>Mon, 26 Sep 2022 11:41:02 -0500</pubDate><guid>https://tom0727.github.io/post/074-icpc2019naq/</guid><description>I. Slow Leak 题意 $n$ 个节点的带权无向图中有 $m$ 条边，有一个汽车从 $1$ 出发要到 $n$，汽车有油箱，油箱一开始是满的，最多可以装 $d$ 升油。 每走 $1$ 单位距离就要消</description></item><item><title>斜率优化DP</title><link>https://tom0727.github.io/post/073-%E6%96%9C%E7%8E%87dp/</link><pubDate>Wed, 21 Sep 2022 14:47:44 -0500</pubDate><guid>https://tom0727.github.io/post/073-%E6%96%9C%E7%8E%87dp/</guid><description>介绍 斜率DP一般用于解决类似于如下的问题： $$dp[i] = \min\limits_{j&amp;lt;i} \{ g(j) + f(i, j) + h(i)\}$$ • 注意到上述式子中，当我们固定 $i$，仅有的变量为 $j$，需要最小化的是 $g(j) + f(i,</description></item><item><title>ICPC2020 Mid Central USA</title><link>https://tom0727.github.io/post/071-icpc2020mid-central/</link><pubDate>Tue, 13 Sep 2022 14:05:04 -0500</pubDate><guid>https://tom0727.github.io/post/071-icpc2020mid-central/</guid><description>I. Trip Tik 题意 给定一个坐标轴，坐标轴上有 $n$ 个点，每个点坐标 $x_i$ 互不相同。每个点 $i$ 都有一个重要性 $w_i$，其中第 $i$ 个点的重要性 $w_i = i$。 现在有一个</description></item><item><title>字符串Hash</title><link>https://tom0727.github.io/post/070-%E5%AD%97%E7%AC%A6%E4%B8%B2hash/</link><pubDate>Sun, 28 Aug 2022 23:23:53 -0500</pubDate><guid>https://tom0727.github.io/post/070-%E5%AD%97%E7%AC%A6%E4%B8%B2hash/</guid><description>介绍 字符串哈希可以在 $O(n)$ 时间内预处理一个字符串，然后在 $O(1)$ 的时间内查询任何字串的哈希值。 一般来讲我们从左往右 build 哈希值，一个 string $a_1a_2a_3&amp;hellip;a_n$ 的哈希值为： $$a_1 p^{n-1} +</description></item><item><title>原神圣遗物计算器</title><link>https://tom0727.github.io/ys-calculator/</link><pubDate>Fri, 27 May 2022 12:43:51 +0800</pubDate><guid>https://tom0727.github.io/ys-calculator/</guid><description/></item><item><title>ICPC2020澳门</title><link>https://tom0727.github.io/post/069-icpc2020%E6%BE%B3%E9%97%A8/</link><pubDate>Sun, 30 Jan 2022 23:43:21 +0800</pubDate><guid>https://tom0727.github.io/post/069-icpc2020%E6%BE%B3%E9%97%A8/</guid><description>A. Accelerator 题意 给定 $n$ 个正整数 $a_1,a_2,&amp;hellip;,a_n$，它们总共有 $n!$ 种 permutation。 对于每一种 permutation $a_{k_1},a_</description></item><item><title>二维差分</title><link>https://tom0727.github.io/post/068-%E4%BA%8C%E7%BB%B4%E5%B7%AE%E5%88%86/</link><pubDate>Mon, 24 Jan 2022 12:14:30 +0800</pubDate><guid>https://tom0727.github.io/post/068-%E4%BA%8C%E7%BB%B4%E5%B7%AE%E5%88%86/</guid><description>介绍 一维差分可以用于解决以下问题： 给定一系列的区间加/减操作，最后询问整个数组的元素。 那么二维差分就可以解决： 给定一系列的矩阵加/减操作，最</description></item><item><title>树套树</title><link>https://tom0727.github.io/post/067-%E6%A0%91%E5%A5%97%E6%A0%91/</link><pubDate>Thu, 20 Jan 2022 18:30:51 +0800</pubDate><guid>https://tom0727.github.io/post/067-%E6%A0%91%E5%A5%97%E6%A0%91/</guid><description>介绍 树套树常常用于解决一些二维数点问题。 经典的问题如：矩阵内查询和/最大值，更新矩阵内一个点的值等等。 在介绍树套树之前，先简单讲一下树状数组</description></item><item><title>组合数学</title><link>https://tom0727.github.io/post/066-%E7%BB%84%E5%90%88%E6%95%B0%E5%AD%A6/</link><pubDate>Sat, 15 Jan 2022 21:52:47 +0800</pubDate><guid>https://tom0727.github.io/post/066-%E7%BB%84%E5%90%88%E6%95%B0%E5%AD%A6/</guid><description>本文主要记录一些组合数学的常用模型。 组合数 $C(n,m)$ $C_n^0 = C_n^n = 1$ $C_n^k = C_{n-1}^k + C_{n-1}^{k-1}$ $C_n^k = \frac{n!}{k!(n-k)!}$ $\sum\limits_{i=l}^r C_i^m = C_{r+1}^{m+1}-C_{l}^{m+1}$ • 注：$0! = 1, (0!)^{-1} = 1$ 证明公式2 $n$ 个中选 $k$ 个， 考虑 $n$ 个元素中的</description></item><item><title>拉格朗日插值</title><link>https://tom0727.github.io/post/065-%E6%8B%89%E6%A0%BC%E6%9C%97%E6%97%A5%E6%8F%92%E5%80%BC/</link><pubDate>Wed, 12 Jan 2022 12:43:19 +0800</pubDate><guid>https://tom0727.github.io/post/065-%E6%8B%89%E6%A0%BC%E6%9C%97%E6%97%A5%E6%8F%92%E5%80%BC/</guid><description>拉格朗日插值 给定 $n$ 个点，我们可以确定唯一的最高 degree 为 $(n-1)$ 的多项式。 设多项式为 $f(x)$，第 $i$ 个点的坐标为 $(x_i,y_i)$，那么这个多项式</description></item><item><title>最大权闭合子图</title><link>https://tom0727.github.io/post/064-%E6%9C%80%E5%A4%A7%E6%9D%83%E9%97%AD%E5%90%88%E5%AD%90%E5%9B%BE/</link><pubDate>Mon, 10 Jan 2022 11:11:05 +0800</pubDate><guid>https://tom0727.github.io/post/064-%E6%9C%80%E5%A4%A7%E6%9D%83%E9%97%AD%E5%90%88%E5%AD%90%E5%9B%BE/</guid><description>定义 闭合子图 对于一个 有向图 $G=(V,E)$，它的一个闭合子图 $G'=(V&amp;rsquo;,E&amp;rsquo;)$ 满足： $\forall u \in V'$，如果 $(u,v) \in E$，则 $v \in V&amp;rsquo;, (u,v) \in E'$ 简单来说，就是对于子图中的每</description></item><item><title>曼哈顿距离 和 切比雪夫距离</title><link>https://tom0727.github.io/post/063-%E6%9B%BC%E5%93%88%E9%A1%BF-%E5%88%87%E6%AF%94%E9%9B%AA%E5%A4%AB%E8%B7%9D%E7%A6%BB/</link><pubDate>Wed, 29 Dec 2021 19:14:56 +0800</pubDate><guid>https://tom0727.github.io/post/063-%E6%9B%BC%E5%93%88%E9%A1%BF-%E5%88%87%E6%AF%94%E9%9B%AA%E5%A4%AB%E8%B7%9D%E7%A6%BB/</guid><description>曼哈顿距离 定义两个点 $A(x_1,y_1), B(x_2,y_2)$，则 $A,B$ 之间的曼哈顿距离为： $$d(A,B) = |x_1 - x_2| + |y_1 - y_2|$$ 曼哈顿距离的性质： 对称性：$d(A,B) = d(B,A)$ 三角形不</description></item><item><title>并查集</title><link>https://tom0727.github.io/post/062-%E5%B9%B6%E6%9F%A5%E9%9B%86/</link><pubDate>Mon, 27 Dec 2021 18:43:41 +0800</pubDate><guid>https://tom0727.github.io/post/062-%E5%B9%B6%E6%9F%A5%E9%9B%86/</guid><description>介绍 这篇博客主要介绍一些并查集的高级应用。 目前我所知的并查集应用有： 权值并查集 可撤销并查集 可持久化并查集（还没学） 权值并查集 略，目前我所知的</description></item><item><title>最短路径树</title><link>https://tom0727.github.io/post/061-%E6%9C%80%E7%9F%AD%E8%B7%AF%E5%BE%84%E6%A0%91/</link><pubDate>Fri, 24 Dec 2021 18:19:49 +0800</pubDate><guid>https://tom0727.github.io/post/061-%E6%9C%80%E7%9F%AD%E8%B7%AF%E5%BE%84%E6%A0%91/</guid><description>介绍 最短路径树是指一个图，在以 某个点 为根，跑出来单源最短路以后，形成的树结构。 具体建树方法就是：在跑单源最短路的时候，用一个 pre[] 数组记录一下每</description></item><item><title>最小生成树</title><link>https://tom0727.github.io/post/060-%E6%9C%80%E5%B0%8F%E7%94%9F%E6%88%90%E6%A0%91/</link><pubDate>Tue, 21 Dec 2021 21:33:24 +0800</pubDate><guid>https://tom0727.github.io/post/060-%E6%9C%80%E5%B0%8F%E7%94%9F%E6%88%90%E6%A0%91/</guid><description>介绍 最小生成树就是给定一张边有权值的图，求一个生成树使得边权和最小。 最小生成树有着以下几个性质： 最小生成树不唯一，次小生成树可以通过枚举非树</description></item><item><title>Trie 和 01 Trie</title><link>https://tom0727.github.io/post/059-01trie/</link><pubDate>Fri, 17 Dec 2021 14:23:29 +0800</pubDate><guid>https://tom0727.github.io/post/059-01trie/</guid><description>介绍 01-Trie 指将整数拆成二进制，然后将二进制以字符串的形式储存在 Trie 中。 Trie可以解决以下问题： 给定一些数 $a_1,a_2,&amp;hellip;,a_</description></item><item><title>单调栈/队列</title><link>https://tom0727.github.io/post/058-%E5%8D%95%E8%B0%83%E9%98%9F%E5%88%97/</link><pubDate>Wed, 17 Nov 2021 17:24:34 +0800</pubDate><guid>https://tom0727.github.io/post/058-%E5%8D%95%E8%B0%83%E9%98%9F%E5%88%97/</guid><description>单调栈介绍 单调栈可以在 $O(n)$ 时间内解决 &amp;ldquo;对于每一个index，求右侧/左侧第一个对应数字比它大/小的index&amp;rdquo; 的问题。</description></item><item><title>基环树</title><link>https://tom0727.github.io/post/057-%E5%9F%BA%E7%8E%AF%E6%A0%91/</link><pubDate>Tue, 16 Nov 2021 15:38:25 +0800</pubDate><guid>https://tom0727.github.io/post/057-%E5%9F%BA%E7%8E%AF%E6%A0%91/</guid><description>定义 基环树指的是一个 $n$ 个节点，$n$ 条边的联通图。 叫基环树的原因是：给定一棵树，在这棵树上加上 任意一条边，就可以形成一个基环树了。 基环树的性</description></item><item><title>CCPC2020秦皇岛</title><link>https://tom0727.github.io/post/056-ccpc2020%E7%A7%A6%E7%9A%87%E5%B2%9B/</link><pubDate>Sun, 31 Oct 2021 11:32:46 +0800</pubDate><guid>https://tom0727.github.io/post/056-ccpc2020%E7%A7%A6%E7%9A%87%E5%B2%9B/</guid><description>排名 Solve: 5 (ADEFJ) Penalty: 767 Rank: 122/343 (35%) 题解 D - Exam Results 题意 给定 $n$ 个学生，第 $i$ 个学生的分数要么为 $a_i$，要么为 $b_i$。 给定整数 $P \in [1,100]$，如果最高</description></item><item><title>二次剩余</title><link>https://tom0727.github.io/post/055-%E4%BA%8C%E6%AC%A1%E5%89%A9%E4%BD%99/</link><pubDate>Sat, 30 Oct 2021 11:19:19 +0800</pubDate><guid>https://tom0727.github.io/post/055-%E4%BA%8C%E6%AC%A1%E5%89%A9%E4%BD%99/</guid><description>二次剩余用于解决在 模意义下开根 的问题： 题意 给定一个质数 $P$ 和一个非负整数 $N$，求 $x$ 使得 $$x^2 \equiv N (\text{mod } P)$$ 本问题等价于求 $$\sqrt N ~(\text{mod } P)$$ 性质 这个问题可能无</description></item><item><title>普通生成函数（OGF）</title><link>https://tom0727.github.io/post/054-%E7%94%9F%E6%88%90%E5%87%BD%E6%95%B0/</link><pubDate>Thu, 23 Sep 2021 15:42:20 +0800</pubDate><guid>https://tom0727.github.io/post/054-%E7%94%9F%E6%88%90%E5%87%BD%E6%95%B0/</guid><description>介绍 生成函数可以解决形如 满足XX条件的方案数共有多少种 的问题，它也能够解决 推导通项公式 等问题，生成函数常常与多项式运算结合在一起。 定义 对于一</description></item><item><title>多项式全家桶</title><link>https://tom0727.github.io/post/053-polynomial/</link><pubDate>Tue, 21 Sep 2021 20:09:39 +0800</pubDate><guid>https://tom0727.github.io/post/053-polynomial/</guid><description>模版 多项式全家桶（比较精简的版本，利用了Z） template&amp;lt;class T&amp;gt; T qpow(T a, int b) { T res = 1; while (b) { if (b &amp;amp; 1) res *= a; a *= a; b &amp;gt;&amp;gt;= 1; } return res; } int norm(int x) { if (x &amp;lt; 0) { x += mod; } if (x &amp;gt;=</description></item><item><title>NTT</title><link>https://tom0727.github.io/post/052-ntt/</link><pubDate>Sat, 18 Sep 2021 19:51:17 +0800</pubDate><guid>https://tom0727.github.io/post/052-ntt/</guid><description>模版 NTT const int mod = 998244353; const int maxn = (1&amp;lt;&amp;lt;22) + 5; struct NTT { const ll g = 3, invg = inv(g); // mod = 998244353 inline ll qpow(ll a, ll b) { ll res = 1; while (b) { if (b &amp;amp; 1) res = res * a % mod; a = a * a % mod; b &amp;gt;&amp;gt;= 1; } return res; } inline</description></item><item><title>FFT</title><link>https://tom0727.github.io/post/051-fft/</link><pubDate>Fri, 17 Sep 2021 13:52:57 +0800</pubDate><guid>https://tom0727.github.io/post/051-fft/</guid><description>.center { margin-left: auto; margin-right: auto; display: table; width: auto; } 模版 FFT const int maxn = (1&amp;lt;&amp;lt;22) + 5; // 注意这里需要是 &amp;gt; 2^k struct Complex { double x,y; Complex(double _x = 0.0, double _y = 0.0) { x = _x; y = _y; } Complex operator+(const Complex&amp;amp; b) const { return Complex(x + b.x, y + b.y); } Complex operator-(const Complex&amp;amp; b)</description></item><item><title>线性基</title><link>https://tom0727.github.io/post/050-%E7%BA%BF%E6%80%A7%E5%9F%BA/</link><pubDate>Tue, 14 Sep 2021 13:44:57 +0800</pubDate><guid>https://tom0727.github.io/post/050-%E7%BA%BF%E6%80%A7%E5%9F%BA/</guid><description>介绍 线性基是一般用于解决 子集XOR，XOR最值 一类问题的算法。 定义 线性基是一个 linear space，在这个space中，所有的向量为 非负整数，而 scalar 则</description></item><item><title>高斯消元</title><link>https://tom0727.github.io/post/049-%E9%AB%98%E6%96%AF%E6%B6%88%E5%85%83/</link><pubDate>Fri, 10 Sep 2021 22:00:43 +0800</pubDate><guid>https://tom0727.github.io/post/049-%E9%AB%98%E6%96%AF%E6%B6%88%E5%85%83/</guid><description>板子 代码 struct GaussianElimination { int n, m; // n: 行 （方程个数）, m: 列 (变量个数) double A[1002][1002]; GaussianElimination(int n, int m) : n(n), m(m) {} vector&amp;lt;double&amp;gt; solve(int B = (int)1e6) { // B: band 大小，指对于任意 A(i,j) != 0，若 i2-i &amp;gt; B || j2-i &amp;gt; B 则任意</description></item><item><title>概率期望</title><link>https://tom0727.github.io/post/048-%E6%A6%82%E7%8E%87%E6%9C%9F%E6%9C%9B/</link><pubDate>Tue, 27 Jul 2021 17:57:28 +0800</pubDate><guid>https://tom0727.github.io/post/048-%E6%A6%82%E7%8E%87%E6%9C%9F%E6%9C%9B/</guid><description>模型 例1 几何分布 题意 一次伯努利试验的成功概率为 $p$，那么期望试验多次才能获得第一次成功？ 答案是 $\frac{1}{p}$。 证明：设 $E[X]$ 为期望</description></item><item><title>CF Problems</title><link>https://tom0727.github.io/cf-problems/</link><pubDate>Wed, 09 Jun 2021 12:19:07 +0800</pubDate><guid>https://tom0727.github.io/cf-problems/</guid><description/></item><item><title>网络流</title><link>https://tom0727.github.io/post/047-%E7%BD%91%E7%BB%9C%E6%B5%81/</link><pubDate>Fri, 04 Jun 2021 12:03:44 +0800</pubDate><guid>https://tom0727.github.io/post/047-%E7%BD%91%E7%BB%9C%E6%B5%81/</guid><description>介绍 网络 是一个有向图 $G = (V,E)$，每条边 $(u,v) \in E$ 都拥有一个容量 $c(u,v)$。 在一个网络中，拥有两个特殊的节点 $s, t$ （源点，汇点）。 定义 流</description></item><item><title>二分图 &amp; 二分图匹配</title><link>https://tom0727.github.io/post/046-%E4%BA%8C%E5%88%86%E5%9B%BE/</link><pubDate>Sun, 30 May 2021 22:31:30 +0800</pubDate><guid>https://tom0727.github.io/post/046-%E4%BA%8C%E5%88%86%E5%9B%BE/</guid><description>二分图 - 定义 二分图是一种特殊的无向图，可以将点集划分为两部分，在同一集合中的节点之间没有 edge。 二分图 - 性质 二分图 $\iff$ 图中没有奇环（指节点个</description></item><item><title>换根DP</title><link>https://tom0727.github.io/post/045-%E6%8D%A2%E6%A0%B9dp/</link><pubDate>Thu, 22 Apr 2021 21:49:20 +0800</pubDate><guid>https://tom0727.github.io/post/045-%E6%8D%A2%E6%A0%B9dp/</guid><description>介绍 换根DP是一种特殊的树形DP。主要特点在于需要进行两次DFS。 第一次DFS：固定任意节点（一般为 $1$）为根。对于每一个节点 $u$，仅考</description></item><item><title>Codeforces Round #717 (Div.2) 解题报告</title><link>https://tom0727.github.io/post/044-cf1516-tutorial/</link><pubDate>Thu, 22 Apr 2021 12:07:06 +0800</pubDate><guid>https://tom0727.github.io/post/044-cf1516-tutorial/</guid><description>全是数学的一场Div2，$D$ 题是常规操作了，但是考场上没想起来，这里记录一下。 结尾也记录了 CF1514D，一道使用随机算法的神奇题目。 CF1516B AGAGA</description></item><item><title>树的直径</title><link>https://tom0727.github.io/post/043-%E6%A0%91%E7%9A%84%E7%9B%B4%E5%BE%84/</link><pubDate>Sun, 18 Apr 2021 15:34:17 +0800</pubDate><guid>https://tom0727.github.io/post/043-%E6%A0%91%E7%9A%84%E7%9B%B4%E5%BE%84/</guid><description>定义 树的直径是指：在一棵有权/无权树中，所有简单路径中，权值和最大的那一条。 树的直径有以下性质：（以下，我们假设所有边上的权值均 $\geq 0$）。 直</description></item><item><title>分层图最短路</title><link>https://tom0727.github.io/post/042-%E5%88%86%E5%B1%82%E5%9B%BE/</link><pubDate>Sat, 17 Apr 2021 22:38:10 +0800</pubDate><guid>https://tom0727.github.io/post/042-%E5%88%86%E5%B1%82%E5%9B%BE/</guid><description>定义 分层图最短路一般用于解决一种特殊的最短路问题： 给定一个图，在图上可以进行 $k$ 次决策（一般 $k \leq 10$），每次决策并不影响图的结构，只会影响目</description></item><item><title>割点 桥 点/边双连通分量（BCC）</title><link>https://tom0727.github.io/post/041-%E5%89%B2%E7%82%B9-%E6%A1%A5-bcc/</link><pubDate>Wed, 14 Apr 2021 11:23:25 +0800</pubDate><guid>https://tom0727.github.io/post/041-%E5%89%B2%E7%82%B9-%E6%A1%A5-bcc/</guid><description>定义 割点 在一个 无向图 中，如果删掉节点 $u$ 使得整个图的连通分量增加，那么 $u$ 是一个割点。 桥 在一个 无向图 中，如果删掉一条边 $(u,v)$ 使得整个图的连通分量增加</description></item><item><title>强连通分量（SCC）</title><link>https://tom0727.github.io/post/040-scc/</link><pubDate>Mon, 12 Apr 2021 22:02:41 +0800</pubDate><guid>https://tom0727.github.io/post/040-scc/</guid><description>定义 在一个 有向图 中，任意取两个节点 $(u,v)$，$u \rightarrow v, v \rightarrow u$ 均有路径，这样的图叫做强连通。 SCC（强连通分量）：一个极大的强连通子图。 缩</description></item><item><title>背包问题</title><link>https://tom0727.github.io/post/039-%E8%83%8C%E5%8C%85/</link><pubDate>Sun, 11 Apr 2021 21:42:06 +0800</pubDate><guid>https://tom0727.github.io/post/039-%E8%83%8C%E5%8C%85/</guid><description>多重背包 01 背包中每个物品只有一个，而多重背包中每个物品有 $s_i$ 个。 多重背包二进制优化 对于第 $i$ 个物品，如果它有 $s_i$ 个，就将其用二进制拆分，然后转成 01</description></item><item><title>HDU Contest 1 解题报告</title><link>https://tom0727.github.io/post/038-hdu-contest1/</link><pubDate>Wed, 07 Apr 2021 21:24:21 +0800</pubDate><guid>https://tom0727.github.io/post/038-hdu-contest1/</guid><description>友情出场本次HDU新生赛，题目质量一如既往的优秀。写一下解题报告吧。 题目 &amp;amp; 题解 题目PDF 题解PDF Q1 选课 题意 有一些学生档案，每个档案上记录了</description></item><item><title>树上差分</title><link>https://tom0727.github.io/post/037-%E6%A0%91%E4%B8%8A%E5%B7%AE%E5%88%86/</link><pubDate>Mon, 05 Apr 2021 15:02:19 +0800</pubDate><guid>https://tom0727.github.io/post/037-%E6%A0%91%E4%B8%8A%E5%B7%AE%E5%88%86/</guid><description>介绍 树上差分就是将数组上的差分思想，转化到树上。 树上差分是一种思想，很多时候树链剖分可以代替树上差分，如果询问不复杂的时候，就可以用树上差分</description></item><item><title>主席树</title><link>https://tom0727.github.io/post/036-%E4%B8%BB%E5%B8%AD%E6%A0%91/</link><pubDate>Wed, 31 Mar 2021 10:42:02 +0800</pubDate><guid>https://tom0727.github.io/post/036-%E4%B8%BB%E5%B8%AD%E6%A0%91/</guid><description>介绍 主席树全名叫做 可持久化权值线段树，一般用于一个数组上，有以下的功能： 对于每一个区间 都能 开一个权值线段树。 能够维护数组的 历史版本。（仅用于</description></item><item><title>权值线段树（动态开点）</title><link>https://tom0727.github.io/post/035-%E6%9D%83%E5%80%BC%E7%BA%BF%E6%AE%B5%E6%A0%91/</link><pubDate>Sat, 27 Mar 2021 20:13:23 +0800</pubDate><guid>https://tom0727.github.io/post/035-%E6%9D%83%E5%80%BC%E7%BA%BF%E6%AE%B5%E6%A0%91/</guid><description>介绍 权值线段树 权值线段树用于维护一定值域内，各个元素出现的次数，结合动态开点可以 避免离散化的处理。 举个例子，我们现在有一个长度为 $10$ 的数组 $[1,5,2,3,4,1,3,4,4,4]$ $1$</description></item><item><title>CF 1499D（数学，筛法）</title><link>https://tom0727.github.io/post/034-cf-1499d/</link><pubDate>Mon, 22 Mar 2021 23:47:16 +0800</pubDate><guid>https://tom0727.github.io/post/034-cf-1499d/</guid><description>题目链接 题意 给定正整数 $c,d,x$，求正整数pair $(a,b)$ 的数量使得 $$c \times lcm(a,b) - d \times gcd(a,b) = x$$ 其中，共 $T \leq 10^4$ 个testcase，$1 \leq c,d,x \leq 10^7$ • $(a,b)$ 和 $(b,a)$ 不</description></item><item><title>数位DP</title><link>https://tom0727.github.io/post/033-%E6%95%B0%E4%BD%8Ddp/</link><pubDate>Thu, 18 Mar 2021 10:53:51 +0800</pubDate><guid>https://tom0727.github.io/post/033-%E6%95%B0%E4%BD%8Ddp/</guid><description>介绍 数位DP是指这样一类题型： 给定一些限定条件，求 $[L,R]$ 内满足这些条件的数字数量，一般 $L,R$ 可能非常大（例如$10^{18}, 10^{1000}$）</description></item><item><title>线段树/树状数组/分块 例题</title><link>https://tom0727.github.io/post/032-%E7%BA%BF%E6%AE%B5%E6%A0%91%E4%BE%8B%E9%A2%98/</link><pubDate>Tue, 16 Mar 2021 22:10:22 +0800</pubDate><guid>https://tom0727.github.io/post/032-%E7%BA%BF%E6%AE%B5%E6%A0%91%E4%BE%8B%E9%A2%98/</guid><description>主要记录一些遇到的线段树/分块例题。 例1 CF438D 题意 给定 $N$ 个正整数和 $M$ 个询问，询问有 3 种： $1 ~ l ~ r$：输出 $\sum\limits_{i=l}^r a_i$ $2 ~ l ~ r ~ x$：将 $a_l$ 到 $a_r$ 的所有数</description></item><item><title>树上启发式合并（DSU on Tree）</title><link>https://tom0727.github.io/post/031-%E6%A0%91%E4%B8%8A%E5%90%AF%E5%8F%91%E5%BC%8F%E5%90%88%E5%B9%B6/</link><pubDate>Mon, 15 Mar 2021 20:53:14 +0800</pubDate><guid>https://tom0727.github.io/post/031-%E6%A0%91%E4%B8%8A%E5%90%AF%E5%8F%91%E5%BC%8F%E5%90%88%E5%B9%B6/</guid><description>介绍 树上启发式合并 一般用于 满足以下条件的问题： 所有询问离线，无修改，仅询问子树的信息（不能用于链的询问） $ans[u]$ 可以转化为 $\sum\limits_{v}ans[v]$ 的形式（其中，$v$ 是</description></item><item><title>Atcoder ABC 131F（图论）</title><link>https://tom0727.github.io/post/030-at-abc131f/</link><pubDate>Fri, 12 Mar 2021 21:48:23 +0800</pubDate><guid>https://tom0727.github.io/post/030-at-abc131f/</guid><description>题目链接 https://atcoder.jp/contests/abc131/tasks/abc131_f 题意 给定 $N$ 个二维平面中的点 $(x_i,y_i)$，我们可以一直重复以下操作： 选择 4 个整数 $a,b,c,d$，保证 $(a,b),(a,d),(c,b),(c,d)$ 中 有且仅有 3 个点</description></item><item><title>CF 165E题解（状压dp）</title><link>https://tom0727.github.io/post/029-cf-165e/</link><pubDate>Thu, 11 Mar 2021 23:20:32 +0800</pubDate><guid>https://tom0727.github.io/post/029-cf-165e/</guid><description>题目链接 https://codeforces.com/contest/165/problem/E 题意 给定 $n$ 个数 $a_1,a_2,&amp;hellip;,a_n$，对于每一个 $a_i$，找出是否存在 $a_j$ 使得 $a_i$ &amp;amp; $a_j = 0$？ 其中 $1 \leq n \leq 10^6, 1</description></item><item><title>CF 1188B（枚举优化）</title><link>https://tom0727.github.io/post/028-cf-1188b/</link><pubDate>Thu, 11 Mar 2021 14:37:13 +0800</pubDate><guid>https://tom0727.github.io/post/028-cf-1188b/</guid><description>题目链接 https://codeforces.com/contest/1188/problem/B 题意 给定 $n$ 个正整数 $a_1,a_2,&amp;hellip;,a_n$，和一个非负整数 $k$，求满足以下条件的 $(i,j)$ 数量： $1\leq i &amp;lt; j \leq n$ $(a_i+a_j)(a_i^2+a_j^2) \equiv k \text{</description></item><item><title>数论分块</title><link>https://tom0727.github.io/post/027-%E6%95%B0%E8%AE%BA%E5%88%86%E5%9D%97/</link><pubDate>Wed, 10 Mar 2021 15:49:46 +0800</pubDate><guid>https://tom0727.github.io/post/027-%E6%95%B0%E8%AE%BA%E5%88%86%E5%9D%97/</guid><description>介绍 数论分块一般用于解决 含有 $\lfloor \frac{N}{i} \rfloor$ 的求和问题。 数论分块主要利用了 $\lfloor \frac{N}{i} \rfloor$ 的取值范围相当有限的特点，所以有 $$i \leq j, ~\lfloor \frac{N}{i} \rfloor = \lfloor \frac{N}{j} \rfloor$$ 这样一些求和问题就</description></item><item><title>CF1243E 题解（图论，状压dp）</title><link>https://tom0727.github.io/post/026-cf-1243e/</link><pubDate>Tue, 09 Mar 2021 12:34:01 +0800</pubDate><guid>https://tom0727.github.io/post/026-cf-1243e/</guid><description>题目链接 https://codeforces.com/contest/1243/problem/E 题意 给定 $k$ 个 box，每个 box $i$ 里有 $n_i$ 个整数，所有整数均不同。 现在我们需要执行 Exactly Once 以下操作： 从每一个box中拿一个数出来，然后以per</description></item><item><title>CF1154G 题解（gcd/lcm的枚举优化）</title><link>https://tom0727.github.io/post/025-cf-1154g/</link><pubDate>Mon, 08 Mar 2021 21:36:22 +0800</pubDate><guid>https://tom0727.github.io/post/025-cf-1154g/</guid><description>题目链接 https://codeforces.com/contest/1154/problem/G 题意 给定 $n$ 个正整数 $a_1,a_2,&amp;hellip;,a_n$，求 $i \neq j$ 使得 $\text{lcm}(a_i, a_j)$ 最小？ 其中 $2 \leq n \leq 10^6, 1 \leq a_i \leq 10^7$ 题解 一般和 $gcd, lcm$ 相关的</description></item><item><title>莫队</title><link>https://tom0727.github.io/post/024-%E8%8E%AB%E9%98%9F/</link><pubDate>Sun, 07 Mar 2021 21:50:41 +0800</pubDate><guid>https://tom0727.github.io/post/024-%E8%8E%AB%E9%98%9F/</guid><description>介绍 莫队算法是一种基于分块思想的暴力算法，一般应用于同时满足以下条件的区间问题中： 已知 $[L,R]$ 之间的答案，能在 $O(1)$ 时间内转移到 $[L+1,R], [L-1,R], [L,R+1], [L,R-1]$ 的答案。 所有询</description></item><item><title>Atcoder ABC 194F（数位DP，进制处理）</title><link>https://tom0727.github.io/post/023-at-abc194f/</link><pubDate>Sat, 06 Mar 2021 22:16:46 +0800</pubDate><guid>https://tom0727.github.io/post/023-at-abc194f/</guid><description>题目链接 https://atcoder.jp/contests/abc194/tasks/abc194_f 题意 给定一个数 $1\leq N \leq 16^{2\times10^5}$，求： 在 16进制 下，满足以下条件的整数 $x$ 数量： 拥有 Exactly $K$ 个不同的digit （例</description></item><item><title>树链剖分</title><link>https://tom0727.github.io/post/022-%E6%A0%91%E9%93%BE%E5%89%96%E5%88%86/</link><pubDate>Sat, 06 Mar 2021 15:58:27 +0800</pubDate><guid>https://tom0727.github.io/post/022-%E6%A0%91%E9%93%BE%E5%89%96%E5%88%86/</guid><description>介绍 树链剖分主要用于将 树上修改/查询 通过 DFS序 变成 区间修改/查询，然后利用 线段树 进行修改/查询。 我们可以用模版来举个例子： 题意 已知一棵包含</description></item><item><title>最近公共祖先 LCA</title><link>https://tom0727.github.io/post/021-lca/</link><pubDate>Sat, 06 Mar 2021 11:57:25 +0800</pubDate><guid>https://tom0727.github.io/post/021-lca/</guid><description>介绍 给定一棵有根树（不一定为binary tree），求两个节点的最近公共祖先？ 算法 LCA的思路和ST表比较相似，都是利用了倍增思想，大概流程</description></item><item><title>三分法</title><link>https://tom0727.github.io/post/020-%E4%B8%89%E5%88%86%E6%B3%95/</link><pubDate>Fri, 05 Mar 2021 22:20:54 +0800</pubDate><guid>https://tom0727.github.io/post/020-%E4%B8%89%E5%88%86%E6%B3%95/</guid><description>介绍 三分法 (tenary search) 和 二分法(binary search) 类似，只不过三分法可以用于搜索一个 二次函数 的最值。 以搜索二次函数最值为例，假如有一个二次函数存在最大值</description></item><item><title>Luogu P5664 Emiya家今天的饭（计数，dp）</title><link>https://tom0727.github.io/post/019-luogu-p5664/</link><pubDate>Fri, 05 Mar 2021 14:58:19 +0800</pubDate><guid>https://tom0727.github.io/post/019-luogu-p5664/</guid><description>题目链接 https://www.luogu.com.cn/problem/P5664 题意 有 $n$ 种烹饪方法，$m$ 种主要食材。每道菜都只用 恰好一种 烹饪方法和主要食材，同时对于 每种烹饪方法 $i$ 和 主要食材 $j$，有 $a_{ij}$ 种不同的</description></item><item><title>Luogu P1450 硬币购物（计数，容斥）</title><link>https://tom0727.github.io/post/018-luogu-p1450/</link><pubDate>Thu, 04 Mar 2021 23:29:54 +0800</pubDate><guid>https://tom0727.github.io/post/018-luogu-p1450/</guid><description>题目链接 https://www.luogu.com.cn/problem/P1450 题意 共有 $4$ 种硬币。面值分别为 $c_1,c_2,c_3,c_4$ 某人去商店买东西，去了 $n$ 次，对于每次购买，他带了 $d_i$ 枚的 第 $i$ 种硬币，想购买价值为 $s$ 东西（不设找零）。请</description></item><item><title>Atcoder ABC 127F（对顶堆动态维护中位数）</title><link>https://tom0727.github.io/post/016-at-abc127f/</link><pubDate>Mon, 01 Mar 2021 21:35:11 +0800</pubDate><guid>https://tom0727.github.io/post/016-at-abc127f/</guid><description>题目链接 https://atcoder.jp/contests/abc127/tasks/abc127_f 题意 初始时有个函数 $f(x) = 0$，现在有 $Q$ 个询问，询问有两种： 1 a b：令 $f(x) = f(x) + |x-a| + b$ 2：求 $x$ 使得 $f(x)$ 最小，并求出这个 $f(x)$ 的最小值 题解 $f(x)$ 必然</description></item><item><title>Atcoder ABC 127E（数学，计数，概率）</title><link>https://tom0727.github.io/post/015-at-abc127e/</link><pubDate>Sun, 28 Feb 2021 23:20:51 +0800</pubDate><guid>https://tom0727.github.io/post/015-at-abc127e/</guid><description>题目链接 https://atcoder.jp/contests/abc127/tasks/abc127_e 题意 给定一个矩阵，包含 $N \times M$ 个格子，现在从中选出 $K \leq N \times M$ 个不同的格子，记为 $(x_1,y_1), (x_2, y_2), &amp;hellip; , (x_K, y_K)$ ，记 $cost = \sum\limits_{i=1}^{K-1}\sum\limits_{j=i+1}^{K}(|x_i-x_j| + |y_i-y_j|)$ 求：对于所有不同的 $K$ 个格子</description></item><item><title>Atcoder ABC 162E（数学，计数）</title><link>https://tom0727.github.io/post/014-at-abc162e/</link><pubDate>Sat, 27 Feb 2021 14:59:58 +0800</pubDate><guid>https://tom0727.github.io/post/014-at-abc162e/</guid><description>题目链接 https://atcoder.jp/contests/abc162/tasks/abc162_e 题意 给定 $2 \leq N \leq 10^5, 2 \leq K \leq 10^5$，现有长度为 $N$ 的序列 $\{ a_1, a_2, &amp;hellip;, a_N \}$，其中 $1 \leq a_i \leq K$ 这样的序列总共有 $K^N$ 个，求所有这些序列的 $\sum \</description></item><item><title>最小环</title><link>https://tom0727.github.io/post/013-%E6%9C%80%E5%B0%8F%E7%8E%AF/</link><pubDate>Thu, 25 Feb 2021 23:41:02 +0800</pubDate><guid>https://tom0727.github.io/post/013-%E6%9C%80%E5%B0%8F%E7%8E%AF/</guid><description>定义 最小环：指图中的一个环，它不包含任何更小的环。 在无向图中，最小的最小环为3个节点。在有向图中，最小的最小环为2个节点。（不考虑self-</description></item><item><title>CF 1395E(集合哈希)</title><link>https://tom0727.github.io/post/012-cf-1395e/</link><pubDate>Thu, 25 Feb 2021 15:25:22 +0800</pubDate><guid>https://tom0727.github.io/post/012-cf-1395e/</guid><description>题目链接 https://codeforces.com/contest/1395/problem/E 题意 给定一个 directed and weighted graph，$2 \leq n \leq 2\cdot10^5, 2 \leq m \leq \min(2\cdot10^5, n(n-1))$，每个vertex的 out-degree 最多为 $1\leq k \leq 9$，每个edge的weig</description></item><item><title>CF 1492E(暴搜)</title><link>https://tom0727.github.io/post/011-cf-1492e/</link><pubDate>Wed, 24 Feb 2021 22:27:41 +0800</pubDate><guid>https://tom0727.github.io/post/011-cf-1492e/</guid><description>题目链接 https://codeforces.com/contest/1492/problem/E 题意 给定 $n$ 个长度为 $m$ 的正整数array，其中 $n \geq 2, m \geq 1, n \times m \leq 250000$ 问是否存在一个array，使得这个array 与 其他每个array</description></item><item><title>HTML/CSS/JS笔记</title><link>https://tom0727.github.io/post/010-%E7%BD%91%E9%A1%B5%E5%BC%80%E5%8F%91/</link><pubDate>Sun, 21 Feb 2021 23:39:36 +0800</pubDate><guid>https://tom0727.github.io/post/010-%E7%BD%91%E9%A1%B5%E5%BC%80%E5%8F%91/</guid><description>这篇博客主要收录一些关于HTML,CSS,JS的知识点 CSS 当前页面的selector 假设我们有一个nav bar，有很多个link，我们希望检测</description></item><item><title>vim笔记</title><link>https://tom0727.github.io/post/009-vim/</link><pubDate>Sat, 20 Feb 2021 23:15:28 +0800</pubDate><guid>https://tom0727.github.io/post/009-vim/</guid><description>这篇博客主要收录一些关于vim的知识点 HTML Match Tags 我们想要显示opening/closing tag的matching情况，并且从一个opening</description></item><item><title>树形dp</title><link>https://tom0727.github.io/post/008-%E6%A0%91%E5%BD%A2dp/</link><pubDate>Thu, 18 Feb 2021 15:42:09 +0800</pubDate><guid>https://tom0727.github.io/post/008-%E6%A0%91%E5%BD%A2dp/</guid><description>介绍 树形dp就是在树上进行dp，常用于 &amp;ldquo;树上选一组点/边，满足某些条件，且使得某些权值和最大&amp;rdquo; 的问题。 一般来说，DP</description></item><item><title>01分数规划</title><link>https://tom0727.github.io/post/007-01%E5%88%86%E6%95%B0%E8%A7%84%E5%88%92/</link><pubDate>Wed, 17 Feb 2021 17:20:49 +0800</pubDate><guid>https://tom0727.github.io/post/007-01%E5%88%86%E6%95%B0%E8%A7%84%E5%88%92/</guid><description>介绍 01分数规划用于 求一个分式的极值 例如： 给定 $a_i, b_i$，选出一组$i$， 使得 $\frac{\sum a_i}{\sum b_i}$ 最大/最小？ 方法 (二分) 一般使用二分答案的方法进行求解，</description></item><item><title>CF1159B 题解(枚举优化)</title><link>https://tom0727.github.io/post/006-cf-1159b/</link><pubDate>Wed, 17 Feb 2021 15:19:54 +0800</pubDate><guid>https://tom0727.github.io/post/006-cf-1159b/</guid><description>题目链接 https://codeforces.com/contest/1159/problem/B 题意 给定 $n$ 个非负整数 $a_1,a_2,&amp;hellip;,a_n$，求 $\frac{\min(a_i, a_j)}{|i-j|}$ ？其中 $i, j \in [1,n], i \neq j$ 题解 对于这类的枚举问题，一般套路都是 &amp;</description></item><item><title>爬虫笔记</title><link>https://tom0727.github.io/post/005-%E7%88%AC%E8%99%AB%E7%AC%94%E8%AE%B0/</link><pubDate>Wed, 10 Feb 2021 22:52:26 +0800</pubDate><guid>https://tom0727.github.io/post/005-%E7%88%AC%E8%99%AB%E7%AC%94%E8%AE%B0/</guid><description>这篇博客主要收录一些爬虫相关的知识点： 分段下载 如果我们需要设定下载的timeout怎么办？ 直接指定 requests.get() 中的 timeout 是不行的！因为这里的timeout</description></item><item><title>欧拉函数</title><link>https://tom0727.github.io/post/004-euler-function/</link><pubDate>Sat, 06 Feb 2021 17:23:34 +0800</pubDate><guid>https://tom0727.github.io/post/004-euler-function/</guid><description>定义 给定正整数$n$，求$\varphi(n)$， 即 小于等于$n$ 且 与$n$互质 的正整数个数。 性质 $\varphi(p) = p-1, ~\forall \text{prime } p$ $\varphi(mn) = \varphi(m)\varphi(n) \iff \gcd(m,n) = 1$ $\varphi(p^k) = p^k - p^{k-1} = p^k(1-\frac{1}{p})$</description></item><item><title>exgcd/中国剩余定理介绍</title><link>https://tom0727.github.io/post/003-crt/</link><pubDate>Sat, 06 Feb 2021 10:46:42 +0800</pubDate><guid>https://tom0727.github.io/post/003-crt/</guid><description>扩展欧几里得 (exgcd) 这是 CRT 的前置知识，用于解决如下问题： 题意 给定方程 ax + by = c，其中 $a,b,c$ 为已知的正整数，求一组正整数解 $x,y$？ Follow up: 如果解不存在，</description></item><item><title>初学爬虫小记</title><link>https://tom0727.github.io/post/002-%E7%88%AC%E8%99%AB/</link><pubDate>Mon, 01 Feb 2021 22:45:03 +0800</pubDate><guid>https://tom0727.github.io/post/002-%E7%88%AC%E8%99%AB/</guid><description>写博客好累啊，是我太久没有写作了吗 这次来记录一下我第一次学习爬虫的经历 起因 补完とにかくかわいい的番，感觉真好看啊，漫画也不错，就打算补补とに</description></item><item><title>Hugo博客搭建小记</title><link>https://tom0727.github.io/post/001-hugo-tutorial/</link><pubDate>Mon, 01 Feb 2021 21:21:41 +0800</pubDate><guid>https://tom0727.github.io/post/001-hugo-tutorial/</guid><description>起因 在几天前折腾了爬虫，成功爬下来とにかくかわいい的漫画以后，我发现我折腾似乎上瘾了。聊天时无意提到”要是我有个人网站就好了“，于是就决定动</description></item><item><title>About</title><link>https://tom0727.github.io/about/</link><pubDate>Sun, 31 Jan 2021 22:57:58 +0800</pubDate><guid>https://tom0727.github.io/about/</guid><description>Hello, this is Tom! If you have trouble visiting this site (especially for mainland China users), please try visit
https://tom0727.gitee.io/
About me Undergraduate study CS @ HKU (The University of Hong Kong), Sep 2018 - June 2022 Graduate study CS @ UIUC (University of Illinois, Urbana-Champaign), Sep 2022 - Dec 2023 Competitive programmer Resume Resume (in English): https://github.com/tom0727/Resume/blob/master/Zhenwei%20Hu_Resume.pdf Links Linkedin: Zhenwei Hu Codeforces: Leetcode: Contact Email: huzhenweitom@gmail.</description></item><item><title>搜索</title><link>https://tom0727.github.io/search/</link><pubDate>Fri, 07 Feb 2020 17:43:21 +0800</pubDate><guid>https://tom0727.github.io/search/</guid><description/></item></channel></rss>