<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/scripts/pretty-feed-v3.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:h="http://www.w3.org/TR/html4/"><channel><title>如形の博客</title><description>如形的个人博客，记录学习、科技、生活等内容。</description><link>https://blog.rusin7.com</link><item><title>MDX 组件使用：User &amp; Advanced</title><link>https://blog.rusin7.com/article/mdx-components</link><guid isPermaLink="true">https://blog.rusin7.com/article/mdx-components</guid><description>文章内组件（Aside/Tabs 等）与高级组件（LinkPreview/GithubCard 等）的使用方式。</description><pubDate>Sun, 11 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;import { Aside, Tabs, TabItem, Spoiler } from &apos;@/components/user&apos;
import { GithubCard, LinkPreview, QRCode, ImageGroup, WebVideo } from &apos;@/components/advanced&apos;&lt;/p&gt;
&lt;h2&gt;1. 必须使用 MDX&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;.md&lt;/code&gt; 文章无法 &lt;code&gt;import&lt;/code&gt; 组件；请使用 &lt;code&gt;.mdx&lt;/code&gt;（如 &lt;code&gt;src/content/blogs/&amp;#x3C;slug&gt;/index.mdx&lt;/code&gt;）。&lt;/p&gt;
&lt;h2&gt;2. User 组件示例&lt;/h2&gt;
&lt;h2&gt;3. Advanced 组件示例&lt;/h2&gt;
&lt;h3&gt;GitHub 卡片&lt;/h3&gt;
&lt;h3&gt;链接预览&lt;/h3&gt;
&lt;h3&gt;二维码&lt;/h3&gt;
&lt;h3&gt;图片组（等高拼图）&lt;/h3&gt;
&lt;p&gt;&amp;#x3C;ImageGroup
images={[
{ src: &apos;https://picr2.axi404.top/1767811093734_image.webp&apos;, alt: &apos;Image A&apos;, aspectRatio: 16 / 9 },
{ src: &apos;https://picr2.axi404.top/1767811093734_image.webp&apos;, alt: &apos;Image B&apos;, aspectRatio: 1 },
]}
/&gt;&lt;/p&gt;
&lt;h3&gt;内嵌视频&lt;/h3&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>写作指南：Markdown / MDX</title><link>https://blog.rusin7.com/article/writing-markdown-mdx</link><guid isPermaLink="true">https://blog.rusin7.com/article/writing-markdown-mdx</guid><description>主题内支持的 Markdown 扩展、数学公式、代码高亮与一些写作约定。</description><pubDate>Sun, 11 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;1. Markdown 支持范围&lt;/h2&gt;
&lt;p&gt;主题默认启用了常用扩展：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GFM：表格、删除线、任务列表等&lt;/li&gt;
&lt;li&gt;数学公式：KaTeX（&lt;code&gt;$...$&lt;/code&gt; / &lt;code&gt;$$...$$&lt;/code&gt;）&lt;/li&gt;
&lt;li&gt;代码高亮：Shiki（支持标题、差异标注等）&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;2. 数学公式（KaTeX）&lt;/h2&gt;
&lt;p&gt;行内：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-md&quot;&gt;欧拉公式：$e^{i\\pi}+1=0$
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;块级：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-md&quot;&gt;$$
\\int_0^1 x^2 dx = \\frac{1}{3}
$$
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;3. 代码块增强（差异/高亮）&lt;/h2&gt;
&lt;p&gt;你可以在代码中使用注释标记来展示变更（示例来自主题的高亮 transformer）：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ts&quot;&gt;const a = 1 // [!code --]
const a = 2 // [!code ++]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;也可以做行高亮：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ts&quot;&gt;const token = &apos;secret&apos; // [!code highlight]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;4. 什么时候用 MDX&lt;/h2&gt;
&lt;p&gt;当你需要在文章里使用组件（例如 &lt;code&gt;Aside&lt;/code&gt;、&lt;code&gt;Tabs&lt;/code&gt;、&lt;code&gt;GithubCard&lt;/code&gt; 等）时，请使用 &lt;code&gt;.mdx&lt;/code&gt;，并在文件顶部 &lt;code&gt;import&lt;/code&gt; 组件。&lt;/p&gt;
&lt;p&gt;组件用法示例文档：见 “MDX 组件使用”。&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>博客迁移分流说明</title><link>https://blog.rusin7.com/article/explanation-of-blog-migration</link><guid isPermaLink="true">https://blog.rusin7.com/article/explanation-of-blog-migration</guid><description>博客迁移分流说明在我的陪伴大家4个月后，由于当时技术较差，不会使用 git 命令行和 node.js，所以不够美观</description><pubDate>Mon, 03 Aug 2026 10:59:41 GMT</pubDate><content:encoded>&lt;p&gt;在我的&lt;a href=&quot;https://hexo.blog.rusin7.com&quot;&gt;第 $2$ 个博客&lt;/a&gt;陪伴大家 $4$ 个月后，由于主题过于臃肿，加载太慢，迁移所有文章至此，原博客将归档，望周知。&lt;/p&gt;
&lt;p&gt;谢谢你们的支持！&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>洛谷网校 CSP 初赛笔记</title><link>https://blog.rusin7.com/article/luogu-class-csp-j-note</link><guid isPermaLink="true">https://blog.rusin7.com/article/luogu-class-csp-j-note</guid><description>笔记</description><pubDate>Wed, 22 Jul 2026 21:53:36 GMT</pubDate><content:encoded>&lt;h2&gt;位运算&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;#x26;&lt;/code&gt; 如果 $x,y$ 的对应位都为 $1$，则结果为 $1$，否则结果为 $0$。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;|&lt;/code&gt; 如果 $x,y$ 的对应位都为 $0$，则结果为 $0$，否则结果为 $1$。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;^&lt;/code&gt; 如果 $x,y$ 的对应位不同，则结果为 $1$，否则结果为 $0$。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;#x3C;&amp;#x3C;&lt;/code&gt; $x$ 左移 $y$ 位，高位删除，如：$(1010)_{2}\texttt{&amp;#x3C;&amp;#x3C;}2=1000$；&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&gt;&gt;&lt;/code&gt; $x$ 右移 $y$ 位，低位删除，如：$(1010)_{2}\texttt{&gt;&gt;}2=0010$；&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;应用&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;n^=1&amp;#x3C;&amp;#x3C;x;//反转第x位
n|=1&amp;#x3C;&amp;#x3C;x;//将第x位设为1
n&amp;#x26;=~(1u&amp;#x3C;&amp;#x3C;x)//将第x位设为0 (1u 是无符号数 unsigned 的写法)
int m=n&amp;#x26;((1&amp;#x3C;&amp;#x3C;x)-1);//取出n的前x个位
int k=(n&gt;&gt;x)&amp;#x26;1;//获得n的第x位
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;优先级表&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;~&lt;/code&gt;&gt;&lt;code&gt;&amp;#x3C;&amp;#x3C;&lt;/code&gt;和&lt;code&gt;&gt;&gt;&lt;/code&gt;&gt;&lt;code&gt;&amp;#x26;&lt;/code&gt;&gt;&lt;code&gt;^&lt;/code&gt;&gt;&lt;code&gt;|&lt;/code&gt;，同级运算从左向右。&lt;/p&gt;
&lt;p&gt;如图，是所有运算的优先级表：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/81VTdvyM.png&quot; alt=&quot;优先级表&quot;&gt;&lt;/p&gt;
&lt;h2&gt;ASCLL 码&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;$0 \sim 9$ : $48 \sim 57$&lt;/li&gt;
&lt;li&gt;&lt;code&gt;A&lt;/code&gt; $\sim$ &lt;code&gt;Z&lt;/code&gt;: $65 \sim 90$&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a&lt;/code&gt; $\sim$ &lt;code&gt;a&lt;/code&gt;: $97 \sim 122$&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;:::info
以数字 $0 \sim 9$ 开头的都是数字，例如：$\texttt{0x3f3f3f}$
:::&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>在 Hexo 中复现洛谷插件</title><link>https://blog.rusin7.com/article/luogu-plugin-in-hexo</link><guid isPermaLink="true">https://blog.rusin7.com/article/luogu-plugin-in-hexo</guid><description>前言OIer都知道，洛谷中有个，非常好用，效果如下：succ</description><pubDate>Sun, 07 Jun 2026 18:31:24 GMT</pubDate><content:encoded>&lt;h2&gt;前言&lt;/h2&gt;
&lt;p&gt;OIer 都知道，洛谷中有个 &lt;a href=&quot;https://www.luogu.com.cn/article/70w8j2pj&quot; title=&quot;插件 README&quot;&gt;Markdown 插件&lt;/a&gt;，非常好用，效果如下：&lt;/p&gt;
&lt;p&gt;:::info[这是一个提示]
我是提示内容。
:::&lt;/p&gt;
&lt;p&gt;:::::warning[我是父容器]&lt;/p&gt;
&lt;p&gt;我是一些文字。&lt;/p&gt;
&lt;p&gt;::::success[我是子容器 1]{open}
我是内容 1。
::::&lt;/p&gt;
&lt;p&gt;我是一些文字。&lt;/p&gt;
&lt;p&gt;::::success[我是子容器 2]{open}
:::error[我是子容器 3]{open}
我是内容 2。
:::
::::&lt;/p&gt;
&lt;p&gt;我是一些文字。&lt;/p&gt;
&lt;p&gt;:::::&lt;/p&gt;
&lt;p&gt;:::epigraph[——otto]
大家好啊，我是说的道理。
:::&lt;/p&gt;
&lt;p&gt;:::align{left}
居左内容。
:::&lt;/p&gt;
&lt;p&gt;:::align{center}
居中内容。
:::&lt;/p&gt;
&lt;p&gt;:::align{right}
居右内容。
:::&lt;/p&gt;
&lt;p&gt;源码：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-markdown&quot;&gt;:::info[这是一个提示]
我是提示内容。
:::

:::::warning[我是父容器]

我是一些文字。

::::success[我是子容器 1]{open}
我是内容 1。
::::

我是一些文字。

::::success[我是子容器 2]{open}
:::error[我是子容器 3]{open}
我是内容 2。
:::
::::

我是一些文字。

:::::

:::epigraph[——otto]
大家好啊，我是说的道理。
:::

:::align{left}
居左内容。
:::

:::align{center}
居中内容。
:::

:::align{right}
居右内容。
:::
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;还有更多……&lt;/p&gt;
&lt;p&gt;尽管 &lt;a href=&quot;https://docs.anheyu.com&quot;&gt;安知鱼主题&lt;/a&gt; 自带很多 &lt;a href=&quot;https://hexo.anheyu.com/posts/d50a.html&quot;&gt;标签外挂&lt;/a&gt;，但仍然无法满足~~复制洛谷文章到博客~~编写习惯性的需求，于是，我&lt;strong&gt;全网首发&lt;/strong&gt;了在 Hexo 中使用洛谷 Md 插件教程。&lt;/p&gt;
&lt;p&gt;:::info[闲话]
由于~~不良~~习惯，我的所有 Markdown 文章编写均遵循洛谷的 &lt;a href=&quot;https://help.luogu.com.cn/rules/academic/article-standard&quot;&gt;专栏全站推荐规范&lt;/a&gt;、&lt;a href=&quot;https://help.luogu.com.cn/rules/academic/solution-standard&quot;&gt;洛谷主题库题解规范&lt;/a&gt;和&lt;a href=&quot;https://help.luogu.com.cn/rules/academic/guide/solution&quot;&gt;如何用 Markdown 和 LaTeX 写一篇排版整齐的题解？&lt;/a&gt;
:::&lt;/p&gt;
&lt;h2&gt;方法&lt;/h2&gt;
&lt;p&gt;:::align{center}
知其然，知其所以然
:::&lt;/p&gt;
&lt;p&gt;用 Javasript 自定义 Hexo 的 markdown 解析，用正则匹配把标识等进行匹配，转换为 Html，最后由 Css 完成样式。&lt;/p&gt;
&lt;h2&gt;实现&lt;/h2&gt;
&lt;p&gt;:::warning{open}
本教程以 anzhiyu 主题为例，其他主题亦可，视情况更改 Css 文件目录和引用方式，~~参见你的博客主题的文档~~&lt;em&gt;以后可能会更新&lt;/em&gt;下这篇文章，搞个多主题支持。
:::&lt;/p&gt;
&lt;p&gt;首先，在博客中新建 Css （&lt;code&gt;~/themes/···（主题名称）/source/css/custom_marked.css&lt;/code&gt;）粘贴以下代码并引入（Anzhiyu 主题可以在 config.yml 中的 Inject.head 配置项中引入）。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-css&quot;&gt;.align-left {
  text-align: left !important;
}

.align-center {
  text-align: center !important;
}

.align-right {
  text-align: right !important;
}

.epigraph {
  width: 40%;
  margin-left: 60%;
}

.epigraph &gt; :last-child {
  margin-top: 0;
  border-top: 1px solid #888;
  text-align: right;
}

summary {
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
  outline: 0;
  margin: 0;
  position: relative;
  padding-left: 24px;
  font-weight: 700;
  list-style: none;
  display: list-item;
  min-height: 1em;
}

.foldable {
  padding: 0.5em 1em;
  margin: 1em 0 1em 0.2em;
  border-left-width: 5px;
  border-left-style: solid;
  overflow: hidden;
}

.foldable.info {
  border-left-color: rgb(52, 152, 219);
}

.foldable.warning {
  border-left-color: rgb(255, 193, 22);
}

.foldable.success {
  border-left-color: rgb(82, 196, 26);
}

.foldable.error {
  border-left-color: rgb(231, 76, 60);
}

.foldable.bug {
  border-left-color: rgb(231, 76, 60);
}

.foldable.flask {
  border-left-color: rgb(155, 89, 182);
}

details.info &gt; summary {
  color: rgb(52, 152, 219);
}

details.warning &gt; summary {
  color: rgb(255, 193, 22);
}

details.success &gt; summary {
  color: rgb(82, 196, 26);
}

details.error &gt; summary {
  color: rgb(231, 76, 60);
}

details.bug &gt; summary {
  color: rgb(231, 76, 60);
}

details.flask &gt; summary {
  color: rgb(155, 89, 182);
}

details.info &gt; summary::before {
  -webkit-mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
  mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
}

details.success &gt; summary::before {
  -webkit-mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
  mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
}

details.warning &gt; summary::before {
  -webkit-mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
  mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
}

details.error &gt; summary::before {
  -webkit-mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
  mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;%20viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;path d=&quot;M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
}

details.bug &gt; summary::before {
  -webkit-mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons:CC BY 4.0,Fonts:SIL OFL 1.1,Code:MIT License) Copyright 2024 Fonticons,Inc. --&gt;&amp;#x3C;path d=&quot;M256 0c53 0 96 43 96 96l0 3.6c0 15.7-12.7 28.4-28.4 28.4l-135.1 0c-15.7 0-28.4-12.7-28.4-28.4l0-3.6c0-53 43-96 96-96zM41.4 105.4c12.5-12.5 32.8-12.5 45.3 0l64 64c.7 .7 1.3 1.4 1.9 2.1c14.2-7.3 30.4-11.4 47.5-11.4l112 0c17.1 0 33.2 4.1 47.5 11.4c.6-.7 1.2-1.4 1.9-2.1l64-64c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3l-64 64c-.7 .7-1.4 1.3-2.1 1.9c6.2 12 10.1 25.3 11.1 39.5l64.3 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-64 0c0 24.6-5.5 47.8-15.4 68.6c2.2 1.3 4.2 2.9 6 4.8l64 64c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0l-63.1-63.1c-24.5 21.8-55.8 36.2-90.3 39.6L272 240c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 239.2c-34.5-3.4-65.8-17.8-90.3-39.6L86.6 502.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l64-64c1.9-1.9 3.9-3.4 6-4.8C101.5 367.8 96 344.6 96 320l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64.3 0c1.1-14.1 5-27.5 11.1-39.5c-.7-.6-1.4-1.2-2.1-1.9l-64-64c-12.5-12.5-12.5-32.8 0-45.3z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
  mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 512 512&quot;&gt;&amp;#x3C;!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons:CC BY 4.0,Fonts:SIL OFL 1.1,Code:MIT License) Copyright 2024 Fonticons,Inc. --&gt;&amp;#x3C;path d=&quot;M256 0c53 0 96 43 96 96l0 3.6c0 15.7-12.7 28.4-28.4 28.4l-135.1 0c-15.7 0-28.4-12.7-28.4-28.4l0-3.6c0-53 43-96 96-96zM41.4 105.4c12.5-12.5 32.8-12.5 45.3 0l64 64c.7 .7 1.3 1.4 1.9 2.1c14.2-7.3 30.4-11.4 47.5-11.4l112 0c17.1 0 33.2 4.1 47.5 11.4c.6-.7 1.2-1.4 1.9-2.1l64-64c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3l-64 64c-.7 .7-1.4 1.3-2.1 1.9c6.2 12 10.1 25.3 11.1 39.5l64.3 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-64 0c0 24.6-5.5 47.8-15.4 68.6c2.2 1.3 4.2 2.9 6 4.8l64 64c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0l-63.1-63.1c-24.5 21.8-55.8 36.2-90.3 39.6L272 240c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 239.2c-34.5-3.4-65.8-17.8-90.3-39.6L86.6 502.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l64-64c1.9-1.9 3.9-3.4 6-4.8C101.5 367.8 96 344.6 96 320l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64.3 0c1.1-14.1 5-27.5 11.1-39.5c-.7-.6-1.4-1.2-2.1-1.9l-64-64c-12.5-12.5-12.5-32.8 0-45.3z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
}

details.flask &gt; summary::before {
  -webkit-mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 448 512&quot;&gt;&amp;#x3C;!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons:CC BY 4.0,Fonts:SIL OFL 1.1,Code:MIT License) Copyright 2024 Fonticons,Inc. --&gt;&amp;#x3C;path d=&quot;M288 0L160 0 128 0C110.3 0 96 14.3 96 32s14.3 32 32 32l0 132.8c0 11.8-3.3 23.5-9.5 33.5L10.3 406.2C3.6 417.2 0 429.7 0 442.6C0 480.9 31.1 512 69.4 512l309.2 0c38.3 0 69.4-31.1 69.4-69.4c0-12.8-3.6-25.4-10.3-36.4L329.5 230.4c-6.2-10.1-9.5-21.7-9.5-33.5L320 64c17.7 0 32-14.3 32-32s-14.3-32-32-32L288 0zM192 196.8L192 64l64 0 0 132.8c0 23.7 6.6 46.9 19 67.1L309.5 320l-171 0L173 263.9c12.4-20.2 19-43.4 19-67.1z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
  mask-image: url(&apos;data:image/svg+xml;utf8,&amp;#x3C;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 448 512&quot;&gt;&amp;#x3C;!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons:CC BY 4.0,Fonts:SIL OFL 1.1,Code:MIT License) Copyright 2024 Fonticons,Inc. --&gt;&amp;#x3C;path d=&quot;M288 0L160 0 128 0C110.3 0 96 14.3 96 32s14.3 32 32 32l0 132.8c0 11.8-3.3 23.5-9.5 33.5L10.3 406.2C3.6 417.2 0 429.7 0 442.6C0 480.9 31.1 512 69.4 512l309.2 0c38.3 0 69.4-31.1 69.4-69.4c0-12.8-3.6-25.4-10.3-36.4L329.5 230.4c-6.2-10.1-9.5-21.7-9.5-33.5L320 64c17.7 0 32-14.3 32-32s-14.3-32-32-32L288 0zM192 196.8L192 64l64 0 0 132.8c0 23.7 6.6 46.9 19 67.1L309.5 320l-171 0L173 263.9c12.4-20.2 19-43.4 19-67.1z&quot;/&gt;&amp;#x3C;/svg&gt;&apos;);
}

summary::before {
  content: &quot;&quot;;
  background-color: currentcolor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  margin-right: 8px;
}

summary:after {
  content: &quot;&quot;;
  background-color: currentcolor;
  -webkit-mask-size: contain;
  mask-size: contain;
  mask-image: url(&quot;data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20256%20512%22%3E%3Cpath%20d%3D%22M246.6%20278.6c12.5-12.5%2012.5-32.8%200-45.3l-128-128c-9.2-9.2-22.9-11.9-34.9-6.9s-19.8%2016.6-19.8%2029.6l0%20256c0%2012.9%207.8%2024.6%2019.8%2029.6s25.7%202.2%2034.9-6.9l128-128z%22%2F%3E%3C%2Fsvg%3E&quot;);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

details[open] &gt; summary::after {
  transform: translateY(-50%) rotate(90deg);
}

pre code.hljs {
  display: block;
  overflow-x: auto;
  padding: 1em;
}

code.hljs {
  padding: 3px 5px;
}

code[class*=&quot;language-&quot;],
pre {
  background: #fefefe;
  color: #383a42;
  font-family:
    Fira Code,
    Fira Mono,
    Menlo,
    Consolas,
    DejaVu Sans Mono,
    monospace;
  direction: ltr;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  line-height: 1.5;
  -moz-tab-size: 2;
  -o-tab-size: 2;
  tab-size: 2;
  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

code[class*=&quot;language-&quot;]::-moz-selection,
code[class*=&quot;language-&quot;] *::-moz-selection,
pre *::-moz-selection {
  background: #e5e5e6;
  color: inherit;
}

code[class*=&quot;language-&quot;]::selection,
code[class*=&quot;language-&quot;] *::selection,
pre *::selection {
  background: #e5e5e6;
  color: inherit;
}

pre {
  padding: 1em;
  margin: 0.5em 0;
  overflow: auto;
  border-radius: 0.3em;
}

:not(pre) &gt; code[class*=&quot;language-&quot;] {
  padding: 0.2em 0.3em;
  border-radius: 0.3em;
  white-space: normal;
}

.copy-button[data-v-a7061ca4] {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  padding: 0.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    0.2s ease-in-out opacity,
    0.2s ease-in-out color,
    0.2s ease-in-out background-color;
  opacity: 0;
  background-color: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #555;
}

.code-container {
  margin: 1rem 0;
  position: relative;
  border-radius: 0.3em;
}

.code-container:hover &gt; .copy-button {
  opacity: 1;
}

.code-container:hover &gt; .copy-button:hover {
  background-color: #ddd;
}

h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

h1 {
  margin: 1.5rem 0 1rem;
  font-size: 2em;
  padding-bottom: 0.1em;
  border-bottom: solid 1px #d8d8d8;
}

h2 {
  margin: 1.2rem 0 1rem;
  font-size: 1.5em;
  padding-bottom: 0.1em;
  border-bottom: solid 1px #d8d8d8;
}

h3 {
  margin: 1.2rem 0 1rem;
  font-size: 1.2em;
}

h4 {
  margin: 1rem 0;
  font-size: 1.1em;
}

h5 {
  margin: 1rem 0;
  font-size: 1em;
}

h6 {
  margin: 1rem 0;
  font-size: 1em;
  color: #666;
}

img {
  max-width: 100%;
}

ul,
ol {
  padding-left: 2em;
}

li + li {
  margin-top: 0.2em;
}

li.task-list-item {
  position: relative;
  list-style-type: none;
}

li.task-list-item &gt; input:first-child {
  position: absolute;
  left: -1.5em;
  top: 55%;
  transform: translateY(-50%);
  padding: 0;
  margin: 0;
}

hr {
  margin: 1em 0;
  height: 0;
  border: none;
  border-bottom: solid 1px #eee;
}

a {
  text-decoration: none;
  transition: filter 0.1s ease;
  color: rgb(var(--lcolor--link, 52, 152, 219));
  cursor: pointer;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  display: block;
  width: 100%;
  overflow: auto;
  word-break: keep-all;
  margin: 10px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  border: 1px solid #ddd;
  padding: 6px 13px;
}

blockquote {
  padding: 10px 20px;
  margin: 0 0 20px;
  border-left: 5px solid #eee;
}

a {
  background-color: transparent;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后直接在 &lt;code&gt;~/themes/···（主题名称）/scripts&lt;/code&gt; 中新建 custom_marked.js（也可以是别的名字），粘贴以下代码即可，&lt;strong&gt;不用引入&lt;/strong&gt;。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;const allowedFoldableTypes = new Set([&apos;info&apos;, &apos;warning&apos;, &apos;success&apos;, &apos;error&apos;, &apos;bug&apos;, &apos;flask&apos;]);

function renderMarkdown(content) {
  return hexo.render.renderSync({ text: content.trim(), engine: &apos;markdown&apos; });
}

function renderCustomBlock(blockType, title, opt, body) {
  const type = blockType.toLowerCase();
  const content = renderMarkdown(body.trim());

  if (type === &apos;align&apos;) {
    const dir = title ? title.trim() : &apos;left&apos;;
    return `\n&amp;#x3C;div class=&quot;align-${dir}&quot;&gt;\n${content}\n&amp;#x3C;/div&gt;\n`;
  }

  if (type === &apos;epigraph&apos;) {
    const author = title ? `&amp;#x3C;p class=&quot;epigraph-author&quot;&gt;${title}&amp;#x3C;/p&gt;` : &apos;&apos;;
    return `\n&amp;#x3C;div class=&quot;epigraph&quot;&gt;\n${content}${author}\n&amp;#x3C;/div&gt;\n`;
  }

  if (allowedFoldableTypes.has(type)) {
    const openAttr = opt &amp;#x26;&amp;#x26; opt.includes(&apos;open&apos;) ? &apos; open&apos; : &apos;&apos;;
    const summary = title ? title.trim() : &apos;详情&apos;;
    return `\n&amp;#x3C;details class=&quot;foldable ${type}&quot;${openAttr}&gt;\n  &amp;#x3C;summary&gt;${summary}&amp;#x3C;/summary&gt;\n  &amp;#x3C;div&gt;\n${content}\n  &amp;#x3C;/div&gt;\n&amp;#x3C;/details&gt;\n`;
  }

  return null;
}

function parseCustomBlocks(content) {
  const lines = content.split(/\r?\n/);
  const root = { type: &apos;root&apos;, children: [] };
  const stack = [root];
  let codeFence = null;
  const openRule = /^\s*(:{3,})([a-zA-Z]\w*)(?:\s*\[([^\]]*)\])?(?:\s*\{([^}]*)\})?\s*$/;
  const closeRule = /^\s*(:{3,})\s*$/;

  for (const line of lines) {
    const fenceMatch = line.match(/^\s*(`{3,}|~{3,})/);
    if (fenceMatch) {
      const fence = fenceMatch[1];
      if (!codeFence) {
        codeFence = fence;
      } else if (codeFence === fence) {
        codeFence = null;
      }
      stack[stack.length - 1].children.push({ type: &apos;text&apos;, value: line });
      continue;
    }

    if (codeFence) {
      stack[stack.length - 1].children.push({ type: &apos;text&apos;, value: line });
      continue;
    }

    const openMatch = line.match(openRule);
    if (openMatch) {
      const level = openMatch[1].length;
      const blockType = openMatch[2].toLowerCase();
      const title = openMatch[3] || &apos;&apos;;
      const opt = openMatch[4] || &apos;&apos;;
      const node = { type: &apos;block&apos;, level, blockType, title, opt, children: [] };
      stack[stack.length - 1].children.push(node);
      stack.push(node);
      continue;
    }

    const closeMatch = line.match(closeRule);
    if (closeMatch) {
      const level = closeMatch[1].length;
      if (stack.length &gt; 1 &amp;#x26;&amp;#x26; stack[stack.length - 1].level === level) {
        stack.pop();
        continue;
      }
    }

    stack[stack.length - 1].children.push({ type: &apos;text&apos;, value: line });
  }

  return renderNode(root);
}

function renderNode(node) {
  if (node.type === &apos;root&apos;) {
    return node.children.map(renderNode).join(&apos;\n&apos;);
  }
  if (node.type === &apos;text&apos;) {
    return node.value;
  }
  if (node.type === &apos;block&apos;) {
    const inner = node.children.map(renderNode).join(&apos;\n&apos;);
    const customHtml = renderCustomBlock(node.blockType, node.title, node.opt, inner);
    if (customHtml !== null) {
      return customHtml;
    }
    const start = `${&apos;:&apos;.repeat(node.level)}${node.blockType}${node.title ? `[${node.title}]` : &apos;&apos;}${node.opt ? `{${node.opt}}` : &apos;&apos;}`;
    const end = &apos;:&apos;.repeat(node.level);
    return `${start}\n${inner}\n${end}`;
  }
  return &apos;&apos;;
}

hexo.extend.filter.register(&apos;before_post_render&apos;, data =&gt; {
  if (typeof data.content !== &apos;string&apos;) return data;
  hexo.log.debug(&apos;custom_marked before_post_render&apos;, data.source || data.path || data.title || &apos;unknown&apos;);
  data.content = parseCustomBlocks(data.content);
  return data;
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;:::info[为什么不用引入？]{open}
与前面引入的 Css 不同的是，任意主题的目录 &lt;code&gt;~/themes/···（主题名称）/scripts&lt;/code&gt; 功能都都一样，Hexo 解析时都会运行改此目录下的&lt;strong&gt;所有&lt;/strong&gt; Javascript 文件。
:::&lt;/p&gt;
&lt;p&gt;:::error[可能的错误]
一不小心放到了 &lt;code&gt;~/themes/anzhiyu/source/js/custom_marked.js&lt;/code&gt; 里。~~唐~~
:::&lt;/p&gt;
&lt;h2&gt;完结&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;hexo new &quot;plugin-test&quot;
hexo cl&amp;#x26;&amp;#x26;hexo g&amp;#x26;&amp;#x26;hexo s
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;赶紧在文章里尝试并体验一下吧！是不是很好用？如果有什么建议，可以在&lt;a href=&quot;#post-comment&quot;&gt;评论区&lt;/a&gt;告诉我哦！&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>笔记——树形动态规划</title><link>https://blog.rusin7.com/article/notes-of-dp-on-trees</link><guid isPermaLink="true">https://blog.rusin7.com/article/notes-of-dp-on-trees</guid><description>若如图所示，当前dfs至点u，则转移方程得</description><pubDate>Sun, 07 Jun 2026 17:45:33 GMT</pubDate><content:encoded>&lt;p&gt;:::info{open}
&lt;strong&gt;设计状态&lt;/strong&gt;：用 $dp_{u,0/1}$ 表示以 $u$ 为根的子树的最大快乐指数。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;答案&lt;/strong&gt;：$\max{dp_{root,1},dp_{root,0}}$。
:::&lt;/p&gt;
&lt;h2&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P1352&quot;&gt;P1352 没有上司的舞会&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;若如图所示，当前 dfs 至点 $u$，则转移方程如下：
$$dp_{u,0}\leftarrow dp_{u,0}+\max(dp_{v,0},dp_{v,1})$$
$$dp_{u,1}\leftarrow dp_{u,1}+dp_{v,0}$$&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/dizzn16u.png&quot; alt=&quot;1&quot;&gt;&lt;/p&gt;
&lt;p&gt;所以可以写出以下代码：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int n,r[6005],in[6005],rt,dp[6005][2];
vector&amp;#x3C;int&gt;g[6005];
void dfs(int u){
    for(int v:g[u]){
        dfs(v);
        dp[u][0]+=max(dp[v][0],dp[v][1]);
        dp[u][1]+=dp[v][0];
    }
    dp[u][1]+=r[u];
}
int main(){
    cin&gt;&gt;n;
    for(int i=1;i&amp;#x3C;=n;++i){
        cin&gt;&gt;r[i];
    }
    for(int i=1;i&amp;#x3C;n;++i){
        int u,v;
        cin&gt;&gt;u&gt;&gt;v;
        g[v].push_back(u);
        in[u]=1;
    }
    for(int i=1;i&amp;#x3C;=n;++i){
        if(!in[i]){
            rt=i;
            break;
        }
    }
    dfs(rt);
    cout&amp;#x3C;&amp;#x3C;max(dp[rt][0],dp[rt][1];
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P2016&quot;&gt;P2016 [SEERC 2000] 战略游戏&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;在开始是初始化一下 $dp_{u,0/1}$ 即可。
:::error[为什么不需要初始化 $dp$ 为无穷大]{open}
在 dfs 中会遍历每个子节点，所以初始化子节点即可，&lt;strong&gt;树形 DP 无需 memset&lt;/strong&gt; $dp$ 数组。
:::&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int n,in[5005],dp[5005][2],rt;
vector&amp;#x3C;int&gt;g[5005];
void dfs(int u){
    dp[u][0]=0;
    dp[u][1]=1;
    for(int v:g[u]){
        dfs(v);
        dp[u][0]+=dp[v][1];
        dp[u][1]+=min(dp[v][0],dp[v][1]);
    }
}
int main(){
    cin&gt;&gt;n;
    for(int i=1;i&amp;#x3C;=n;++i){
        int u,k,v;
        cin&gt;&gt;u&gt;&gt;k;
        u++;
        for(int j=1;j&amp;#x3C;=k;++j){
            cin&gt;&gt;v;
            v++;
            g[u].push_back(v);
            in[v]=1;
        }
    }
    for(int i=1;i&amp;#x3C;=n;++i){
        if(!in[i]){
            rt=i;
            break;
        }
    }
    dfs(rt);
    cout&amp;#x3C;&amp;#x3C;min(dp[rt][0],dp[rt][1]);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P1122&quot;&gt;P1122 最大子树和&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/f1kj14gd.png&quot; alt=&quot;1&quot;&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int n,a[16005],dp[16005],ans=INT_MIN;
vector&amp;#x3C;int&gt;g[16005];
void dfs(int u,int fa){
    dp[u]=a[u];
    for(int v:g[u]){
        if(v!=fa){
            dfs(v,u);
            dp[u]+=max(0,dp[v]);
        }
    }
}
int main(){
    cin&gt;&gt;n;
    for(int i=1;i&amp;#x3C;=n;++i)cin&gt;&gt;a[i];
    for(int i=1;i&amp;#x3C;n;++i){
        int u,v;
        cin&gt;&gt;u&gt;&gt;v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i&amp;#x3C;=n;++i){
        ans=max(dp[i],ans);
    }
    cout&amp;#x3C;&amp;#x3C;ans;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P2585&quot;&gt;P2585 [ZJOI2006] 三色二叉树&lt;/a&gt;&lt;/h2&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>题解：AT_pakencamp_2020_day1_d 立方体を壊せ！</title><link>https://blog.rusin7.com/article/at-pakencamp-2020-day1-d</link><guid isPermaLink="true">https://blog.rusin7.com/article/at-pakencamp-2020-day1-d</guid><description>本文讲述了如何使用 C++ 完成洛谷的 AT_pakencamp_2020_day1_d 立方体を壊せ！，思路清晰、排版精美</description><pubDate>Sat, 06 Jun 2026 19:35:33 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;h2&gt;问题分析&lt;/h2&gt;
&lt;p&gt;题目要求计算边长为 $N$ 的立方体被平面 $x+y+z=K$ 切割后，包含原点 $(0,0,0)$ 的部分体积的 &lt;strong&gt;6 倍&lt;/strong&gt;是多少。&lt;br&gt;
立方体的范围为 $0 \le x,y,z \le N$，平面 $x+y+z=K$ 将空间分为两部分，并且&lt;strong&gt;包含原点的部分&lt;/strong&gt;满足 $x+y+z \le K$。&lt;/p&gt;
&lt;h2&gt;核心思路&lt;/h2&gt;
&lt;p&gt;根据 $K$ 与立方体的位置关系，平面切割立方体的效果不同，需分类讨论：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;平面在立方体外部（$K \le 0$）&lt;/strong&gt;：如图 1 ，此时 $x+y+z \le K$ 不包含立方体任何部分，$V_立=0$。&lt;br&gt;
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/2gwzloc6.png&quot; alt=&quot;1&quot;&gt;$\tiny\color{000000}图 1$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;平面切割出小四面体（$0&amp;#x3C;K \le N$）&lt;/strong&gt;：如图 2-1 , 平面与立方体相交形成以原点为顶点的四面体，如图 2-2 ，体积可直接用 $V_四$ 公式计算。&lt;br&gt;
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/2g4gmpiy.png&quot; alt=&quot;1&quot;&gt;&lt;br&gt;
$$\tiny\color{000000}图 2-1$$
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/w7d0dm2o.png&quot; alt=&quot;1&quot;&gt;
$$\tiny\color{000000}图 2-2$$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;平面切割立方体中部（$N&amp;#x3C;K \le 2N$）&lt;/strong&gt;：如图 3 ，平面与立方体的三个面相交，形成复杂区域，需通过几何分解推导体积公式。&lt;br&gt;
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/rlr1lmtg.png&quot; alt=&quot;1&quot;&gt;
$$\tiny\color{000000}图 3$$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;平面靠近立方体对角顶点（$2N&amp;#x3C;K \le 3N$）&lt;/strong&gt;：如图 4 ，平面切割后形成以原点为顶点的七面体，$V_七=V_立-V_四$。&lt;br&gt;
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/f55bsela.png&quot; alt=&quot;1&quot;&gt;
$$\tiny\color{000000}图 4$$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;平面完全在立方体外部（$K &gt; 3N$）&lt;/strong&gt;：如图 5 ，整个立方体都满足 $x+y+z \le K$，$V_立=$ 立方体体积公式。&lt;br&gt;
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/pid9y8n6.png&quot; alt=&quot;1&quot;&gt;
$$\tiny\color{000000}图 5$$&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;公式推导&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;当 $K \le 0$&lt;/strong&gt;&lt;br&gt;
此时 $x+y+z \le K$ 无立方体部分，6 倍体积为：
&lt;blockquote&gt;
&lt;p&gt;$6 \times 0=0$&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;当 $0&amp;#x3C;K \le N$&lt;/strong&gt;&lt;br&gt;
平面切割出的区域是顶点为 $(0,0,0)、(K,0,0)、(0,K,0)、(0,0,K)$ 的四面体。四面体体积公式为 $V_四=\frac{1}{6}K^3$，因此 6 倍体积为：
&lt;blockquote&gt;
&lt;p&gt;$K^3$&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;当 $N &amp;#x3C; K \leq 2N$&lt;/strong&gt;&lt;br&gt;
平面与立方体的三个面相交，需通过积分或几何分解计算。推导得 6 倍体积公式：
&lt;blockquote&gt;
&lt;p&gt;$3K^2N - 3KN^2 + N^3 - 2(K - N)^3$&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;当 $2N &amp;#x3C; K \le 3N$&lt;br&gt;
包含原点的部分是整个立方体减去一个小四面体（顶点为 $(N,N,N)$，边长为 $3N - K$）。&lt;br&gt;
立方体 6 倍体积为 $6N^3$，小四面体 6 倍体积为 $(3N - K)^3$，因此结果为：
&lt;blockquote&gt;
&lt;p&gt;$6N^3 - (3N - K)^3$&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;当 $K &gt; 3N$&lt;/strong&gt;&lt;br&gt;
整个立方体都满足 $x + y + z \le K$，6 倍体积为立方体体积的 6 倍：
&lt;blockquote&gt;
&lt;p&gt;$6N^3$&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;代码实现&lt;/h2&gt;
&lt;p&gt;根据上述推导，分情况计算结果：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
long long n,k,res;
int main(){
    cin&gt;&gt;n&gt;&gt;k;
    if(k==0){
        res=0;
    }else if(k&amp;#x3C;=n){
        res=k*k*k;
    }else if(k&amp;#x3C;=2*n){
        res=3*k*k*n-3*k*n*n+n*n*n-2*(k-n)*(k-n)*(k-n);
    }else if(k&amp;#x3C;=3*n){
        res=6*n*n*n-(3*n-k)*(3*n-k)*(3*n-k);
    }else{
        res=6*n*n*n;
    }
    cout&amp;#x3C;&amp;#x3C;res&amp;#x3C;&amp;#x3C;endl;
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>题解：P13361 [GCJ 2011 Qualification] Bot Trust</title><link>https://blog.rusin7.com/article/p13361-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/p13361-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 P13361 [GCJ 2011 Qualification] Bot Trust」水落溪流浅浅，思路清晰、排版精美</description><pubDate>Sat, 06 Jun 2026 19:31:53 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;p&gt;本题解被打回无法重新提交嘤嘤嘤&lt;/p&gt;
&lt;h2&gt;题意理解&lt;/h2&gt;
&lt;h3&gt;形式化翻译&lt;/h3&gt;
&lt;p&gt;题目翻译有点难懂（~~其实是本蒟蒻懒得看~~），让本蒟蒻来形式化一下：&lt;/p&gt;
&lt;p&gt;对于每组测试用例，有 $n$ 个执行任务的机器人和对应的按钮， $2$ 个机器人需&lt;strong&gt;依次&lt;/strong&gt;按下自己对应的按钮，求计算 $2$ 个机器人按完按钮所需的最少时间。&lt;/p&gt;
&lt;h3&gt;注意事项&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;必须严格按照给定顺序操作，后一个按钮的操作必须在前一个完成后才能开始。&lt;/li&gt;
&lt;li&gt;机器人可同时移动但&lt;strong&gt;不能同时执行&lt;/strong&gt;按键操作。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;解题思路&lt;/h2&gt;
&lt;h3&gt;状态跟踪&lt;/h3&gt;
&lt;p&gt;需使用记录两个机器人的当前位置 $poso$ 和 $posb$ （ $poso$ 对应&lt;code&gt;Orange&lt;/code&gt;， $posb$ 对应&lt;code&gt;Blue&lt;/code&gt;）和各自上次操作完成的时间 $timeo$ 和 $timeb$ ，以及整个流程的总时间 $s$ 。&lt;br&gt;
对于每组测试用例，&lt;strong&gt;千万不要忘记&lt;/strong&gt;对 $poso$ 、 $posb$ 、 $timeo$ 和 $timeb$ 进行&lt;strong&gt;初始化&lt;/strong&gt;！&lt;/p&gt;
&lt;h3&gt;操作逻辑&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;对每个命令，先确定执行的机器人（判断输入为&lt;code&gt;O&lt;/code&gt;或&lt;code&gt;B&lt;/code&gt;）。&lt;/li&gt;
&lt;li&gt;计算从到达目标位置的时间 $|a_i-poso/posb| \times1$ 。&lt;/li&gt;
&lt;li&gt;确定实际完成时间：取到达时间和当前总时间的最大值（保证顺序性），再加 $1$ 秒按键时间，用公式表达即为：
&lt;blockquote&gt;
&lt;p&gt;$$ntime \leftarrow \max{timeo+|a_i-poso/posb|,s}$$&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;更新机器人位置、对应完成时间和总时间。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;代码实现&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
// 存储每个命令的结构体：机器人类型和目标位置
struct Command{
    char robot; 
    int pos;
}a[100]; 
int t,n,poso,posb,timeo,timeb,s,p,ntime;
char c;

// 初始化函数：重置机器人初始状态
void init(){
    poso=1;  // 初始位置均为1
    posb=1;
    timeo=0;  // 初始时间为0
    timeb=0;
    s=0;  // 总时间初始为0
}

int main(){
    cin&gt;&gt;t;
    for (int k=1;k&amp;#x3C;=t;k++) {
        cin&gt;&gt;n;
        for (int i= 0;i&amp;#x3C;n;i++) {
            cin&gt;&gt;a[i].robot&gt;&gt;a[i].pos;
        }
        init();  // 初始化状态
        for(int i=0;i&amp;#x3C;n;++i){
            //核心：顺序按下每个按钮
            c=a[i].robot;  // 当前命令的机器人
            p=a[i].pos;    // 当前命令的目标位置
            if(c==&apos;O&apos;){  // Orange机器人操作
                // 计算完成时间：到达时间与总时间取最大后+1秒按键
                ntime=max(timeo+abs(p-poso),s)+1;
                poso=p;  // 更新位置
                timeo=s=ntime;  // 更新时间
            }else{  // Blue机器人操作
                ntime=max(timeb+abs(p-posb),s)+1;
                posb=p;  //同上
                timeb=s=ntime;
            }
        }
        // 格式化输出结果
        cout&amp;#x3C;&amp;#x3C;&quot;Case #&quot;&amp;#x3C;&amp;#x3C;k&amp;#x3C;&amp;#x3C;&quot;: &quot;&amp;#x3C;&amp;#x3C;s&amp;#x3C;&amp;#x3C;endl;
    }
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;复杂度分析&lt;/h2&gt;
&lt;p&gt;时间复杂度： $O(n)$ ，其中 $n$ 为命令数量，只需遍历一次所有命令。&lt;br&gt;
空间复杂度： $O(n)$ ，用于存储命令数组（可优化为 $O(1)$ ，边读边处理）。&lt;/p&gt;
&lt;h2&gt;闲话&lt;/h2&gt;
&lt;p&gt;~~真是一道水题！~~&lt;br&gt;
提交后，那&lt;a href=&quot;https://www.luogu.com.cn/record/231500600&quot; title=&quot;点此查看我的AC记录&quot;&gt;只有两个的测试点和 20pts&lt;/a&gt; 着实让我大跌眼镜。&lt;br&gt;
本蒟蒻的第一篇题解，看了许多大佬的题解学习格式，花了一下午完成，望管理员大大通过。&lt;/p&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>题解：P8534 「Wdoi-2」比赤色更红的梦</title><link>https://blog.rusin7.com/article/p8534-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/p8534-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 P8534 「Wdoi-2」比赤色更红的梦，思路清晰、排版精美</description><pubDate>Sat, 06 Jun 2026 19:26:35 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P8534&quot;&gt;题目传送门&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;题意分析&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;核心&lt;/strong&gt;：对于每组数据，判断 $x$ 是否 $\ge 3$ 或 $\ge 5$ 并对应地将残机 $+1$，判断 $s$ 是否 $\ge 10000000$、$\ge 20000000$、$\ge 40000000$ 或 $\ge 60000000$ 并对应地将残机 $+1$。&lt;/p&gt;
&lt;h2&gt;思路引导&lt;/h2&gt;
&lt;p&gt;:::warning[提问]
如何处理多组数据？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
使用 &lt;code&gt;while&lt;/code&gt; 循环语句，每次将 $t-1$，因为 $t=0$ 时布尔值为 $0$, 即 false，所以将会跳出循环，此时循环语句正好执行 $t$ 次。格式如下：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;while(t--/*布尔表达式*/){
  //执行____
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;:::&lt;/p&gt;
&lt;p&gt;:::warning[提问]
如何对 $x$ 和 $s$ 的值进行判断？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
使用 &lt;code&gt;if&lt;/code&gt; 分支语句，格式如下：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;//普通版：
if(/*布尔表达式*/){
	//执行____
}
//压行版：
if(/*布尔表达式*/)//执行____（限一句）
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;:::&lt;/p&gt;
&lt;p&gt;:::error[警示]{open}&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果你将 $s$ 开 int ，那么你将喜提 $\color{E74C3C}{\text{WA}}$，$\color{E74C3C}{\text{25pts}}$。请注意观察数据范围！&lt;br&gt;
~~别问我是&lt;a href=&quot;https://www.luogu.com.cn/record/236917936&quot;&gt;怎么知道的&lt;/a&gt;~~&lt;/li&gt;
&lt;li&gt;别忘了每次将 $ans$ 初始化为 $2$。
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;核心代码&lt;/h2&gt;
&lt;p&gt;只提供 &lt;code&gt;while&lt;/code&gt; 循环语句内的代码。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;ans=2;
cin&gt;&gt;x&gt;&gt;s;
if(x&gt;=3)ans++;
if(x&gt;=5)ans++;
if(s&gt;=10000000)ans++;
if(s&gt;=20000000)ans++;
if(s&gt;=40000000)ans++;
if(s&gt;=60000000)ans++;
cout&amp;#x3C;&amp;#x3C;ans&amp;#x3C;&amp;#x3C;endl;
//code by _ruyingsuixing_(UID:1620655)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;| 1  | 1  |
|-|-|
|  1 | &amp;#x3C;  |
|  1 | 1  |&lt;/p&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>AC 自动机笔记</title><link>https://blog.rusin7.com/article/automated-ac</link><guid isPermaLink="true">https://blog.rusin7.com/article/automated-ac</guid><description>AC 自动机笔记</description><pubDate>Sat, 06 Jun 2026 19:22:35 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/ycm2f9av.png&quot; alt=&quot;洛谷炸了&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/akus9280.png&quot; alt=&quot;洛谷炸了&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/rktfergq.png&quot; alt=&quot;洛谷炸了&quot;&gt;&lt;/p&gt;
&lt;p&gt;模板代码（&lt;a href=&quot;https://www.luogu.com.cn/problem/P3808&quot;&gt;P3808 AC 自动机（简单版）&lt;/a&gt;）&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int n,tot,cnt[1000005],ch[1000005][30],ne[1000005];
void insert(string s){
	int u=0;
	for(char c:s){
		int v=c-&apos;a&apos;;
		if(!ch[u][v])ch[u][v]=++tot;
		u=ch[u][v];
	}
	cnt[u]++;
}
void build(){
	queue&amp;#x3C;int&gt;q;
	for(int i=0;i&amp;#x3C;26;++i){
		if(ch[0][i])q.push(ch[0][i]);
	}
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=0;i&amp;#x3C;26;++i){
			int v=ch[u][i];
			if(v)ne[v]=ch[ne[u]][i],q.push(v);
			else ch[u][i]=ch[ne[u]][i];
		}
	}
}
int query(string s){
	int ans=0;
	for(int k=0,i=0;s[k];k++){
		i=ch[i][s[k]-&apos;a&apos;];
		for(int j=i;j&amp;#x26;&amp;#x26;~cnt[j];j=ne[j]){
			ans+=cnt[j],cnt[j]=-1;
		}
	}
	return ans;
}
string t;
int main(){
	cin&gt;&gt;n;
	for(int i=1;i&amp;#x3C;=n;++i){
		string s;
		cin&gt;&gt;s;
		insert(s);
	}
	cin&gt;&gt;t;
	build();
	cout&amp;#x3C;&amp;#x3C;query(t);
	return 0;
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>网络流笔记</title><link>https://blog.rusin7.com/article/the-network--flow-notes</link><guid isPermaLink="true">https://blog.rusin7.com/article/the-network--flow-notes</guid><description>增广路ek模板Dinic模板,网络流的定义</description><pubDate>Sat, 06 Jun 2026 18:57:34 GMT</pubDate><content:encoded>&lt;h2&gt;增广路&lt;/h2&gt;
&lt;p&gt;ek 模板：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using ll=long long;
using namespace std;
const int N=205,M=5005;
int n,m,s,t,cnt=1,head[N],pre[N],mf[N];
/*
mf：当前增广路可通过水流
*/
struct edge{
	int nxt,to,w;
}e[2*M];
void add(int u,int v,int w){
	e[++cnt].w=w;
	e[cnt].to=v;
	e[cnt].nxt=head[u];
	head[u]=cnt;
}
bool bfs(){
	memset(mf,0,sizeof mf);
	queue&amp;#x3C;int&gt;q;
	q.push(s);
	mf[s]=1e9;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=head[u];i;i=e[i].nxt){
			int v=e[i].to;
			if(mf[v]==0&amp;#x26;&amp;#x26;e[i].w){
				mf[v]=min(mf[u],e[i].w);
				pre[v]=i;
				q.push(v);
				if(v==t)return 1;
			}
		}
	}
	return 0;
}
ll ek(){
	ll fl=0;
	while(bfs()){
		int v=t;
		while(v!=s){
			int i=pre[v];
			e[i].w-=mf[t];
			e[i^1].w+=mf[t];
			v=e[i^1].to;
		}
		fl+=mf[t];
	}
	return fl;
}
int main(){
	cin&gt;&gt;n&gt;&gt;m&gt;&gt;s&gt;&gt;t;
	for(int i=1;i&amp;#x3C;=m;++i){
		int u,v,w;
		cin&gt;&gt;u&gt;&gt;v&gt;&gt;w;
		add(u,v,w);
		add(v,u,0);
	}
	cout&amp;#x3C;&amp;#x3C;ek();
	return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Dinic 模板：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
#define ll long long
using namespace std;
const int M=5005;
int n,m,s,t,head[M],tot=1,d[M],cur[M];
struct edge{
	int v,nxt;
	ll flow;
}e[2*M];
void add(int u,int v,int w){
	e[++tot]={v,head[u],w},head[u]=tot;
}
bool bfs(){
	memset(d,0,sizeof d);
	memcpy(cur,head,sizeof head);
	queue&amp;#x3C;int&gt;q;
	q.push(s);
	d[s]=1;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=head[u];~i;i=e[i].nxt){
			int v=e[i].v;
			if(!d[v]&amp;#x26;&amp;#x26;e[i].flow){
				d[v]=d[u]+1;
				if(v==t)return true;
				q.push(v);
			}
		}
	}
	return false;
}
ll dfs(int u,ll flow){
	if(u==t||!flow)return flow;
	ll rest=flow;
	for(int &amp;#x26;i=cur[u];~i;i=e[i].nxt){
		int v=e[i].v;
		if(d[v]==d[u]+1&amp;#x26;&amp;#x26;e[i].flow){
			ll k=dfs(v,min(rest,e[i].flow));
			if(!k)d[v]=0;
			e[i].flow-=k,e[i^1].flow+=k;
			if(!(rest-=k))break;
		}
	}
	return flow-rest;
}
ll dinic(){
	ll maxflow=0;
	while(bfs())maxflow+=dfs(s,INT_MAX);
	return maxflow;
}
int main(){
	memset(head, -1, sizeof(head));
	cin&gt;&gt;n&gt;&gt;m&gt;&gt;s&gt;&gt;t;
	for(int i=1;i&amp;#x3C;=m;++i){
		int u,v,w;
		cin&gt;&gt;u&gt;&gt;v&gt;&gt;w;
		add(u,v,w),add(v,u,0);
	}
	cout&amp;#x3C;&amp;#x3C;dinic();
	return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://oi-wiki.org/graph/flow/&quot;&gt;OI wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/list?tag=79&quot;&gt;problems 1&lt;/a&gt; &amp;#x26; &lt;a href=&quot;https://www.luogu.com.cn/problem/list?tag=332&quot;&gt;problems 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;:::warning[请注意]{open}
本文章使用了 AI 辅助编写，请谨慎鉴别。
:::&lt;/p&gt;
&lt;h2&gt;Part. 1 网络流的定义&lt;/h2&gt;
&lt;h3&gt;1.1 流网络&lt;/h3&gt;
&lt;p&gt;一个流网络是一个四元组 $N=(G,c,s,t)$，其中：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$G=(V,E)$ 是一个无自环有向图。&lt;/li&gt;
&lt;li&gt;$c:E\mapsto[0,+\infty)$ 是容量函数，$c(u,v)\geqslant0$。&lt;/li&gt;
&lt;li&gt;$s\in V$ 是源点，$t\in V$ 是汇点，$s\ne t$。&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;1.2 流&lt;/h3&gt;
&lt;p&gt;一个流是函数 $f:E\to\mathbb{R}_{\geqslant0}$，满足：&lt;/p&gt;
&lt;p&gt;(1) 容量约束：对每条边 $(u,v)\in E$，
$$0\leqslant f(u,v)\leqslant c(u,v)$$&lt;/p&gt;
&lt;p&gt;(2) 流量守恒：对每个节点 $u\in V\setminus{s,t}$，
$$\sum_{v:(v,u)\in E} f(v,u) = \sum_{v:(u,v)\in E} f(u,v)$$
即，流入量等于流出量。&lt;/p&gt;
&lt;h3&gt;1.4 净流量函数与流的值&lt;/h3&gt;
&lt;p&gt;对任意节点 $u\in V$，定义净流量：
$$\text{net}&lt;em&gt;f(u) = \sum&lt;/em&gt;{v:(u,v)\in E} f(u,v) - \sum_{v:(v,u)\in E} f(v,u)$$&lt;/p&gt;
&lt;p&gt;于是：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;对 $u\in V\setminus{s,t}$：$\text{net}_f(u)=0$（流量守恒）。&lt;/li&gt;
&lt;li&gt;对源点：$\text{net}_f(s)=\left\lvert f\right\rvert$。&lt;/li&gt;
&lt;li&gt;对汇点：$\text{net}_f(t)=-\left\lvert f\right\rvert$。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;注：在标准建模中，通常没有边指向源点，此时第二项为 $0$。&lt;/p&gt;
&lt;h2&gt;Part. 2 割的定义&lt;/h2&gt;
&lt;p&gt;设 $S\sub V$ 满足 $s\in S$ 且 $t\notin S$。令 $T=V\setminus S$。&lt;/p&gt;
&lt;p&gt;割是指集合对 $(S,T)$。&lt;/p&gt;
&lt;p&gt;割的容量定义为：
$$c(S,T) = \sum_{\substack{(u,v)\in E \ u\in S,,v\in T}} c(u,v)$$&lt;/p&gt;
&lt;p&gt;即从 $S$ 指向 $T$ 的边的容量之和。&lt;/p&gt;
&lt;p&gt;最小割是指容量最小的割。&lt;/p&gt;
&lt;h2&gt;Part.3 最大流最小割定理&lt;/h2&gt;
&lt;p&gt;定理：对任意流网络，最大流的值等于最小割的容量：
$$\max\left\lvert f\right\rvert = \min_{S: s\in S,,t\notin S} c(S,T)$$&lt;/p&gt;
&lt;p&gt;::::info[证明]&lt;/p&gt;
&lt;h4&gt;$1\degree$ 弱对偶性（流 $\leqslant$ 割）&lt;/h4&gt;
&lt;p&gt;引理 1：对任意可行流 $f$ 和任意 $s{-}t$ 割 $(S,T)$，有 $\left\lvert f\right\rvert \leqslant c(S,T)$。&lt;/p&gt;
&lt;p&gt;:::info[证明]&lt;/p&gt;
&lt;p&gt;首先，可将 $\left\lvert f\right\rvert$ 写成 $S$ 中所有节点的净流量之和：
$$\left\lvert f\right\rvert = \sum_{u\in S} \text{net}_f(u)$$&lt;/p&gt;
&lt;p&gt;将净流量展开：
$$\begin{aligned}
\left\lvert f\right\rvert &amp;#x26;= \sum_{u\in S} \left( \sum_{v:(u,v)\in E} f(u,v) - \sum_{v:(v,u)\in E} f(v,u) \right) \
&amp;#x26;= \sum_{u\in S}\sum_{v:(u,v)\in E} f(u,v) - \sum_{u\in S}\sum_{v:(v,u)\in E} f(v,u)
\end{aligned}$$&lt;/p&gt;
&lt;p&gt;交换求和顺序。第一项中，$(u,v)$ 的起点 $u$ 在 $S$ 中；第二项中，$(v,u)$ 的终点 $u$ 在 $S$ 中，等价于起点 $v$ 可以属于 $S$ 或 $T$。将第二项按起点分类：&lt;/p&gt;
&lt;p&gt;$$
\left\lvert f\right\rvert = \sum_{u\in S,,v\in V} f(u,v) - \sum_{v\in V,,u\in S} f(v,u)
$$&lt;/p&gt;
&lt;p&gt;将 $V$ 拆成 $S$ 和 $T$：&lt;/p&gt;
&lt;p&gt;$$\left\lvert f\right\rvert = \cancel{\sum_{u\in S,,v\in S} f(u,v)} + \sum_{u\in S,,v\in T} f(u,v) - \cancel{\sum_{v\in S,,u\in S} f(v,u)} - \sum_{v\in T,,u\in S} f(v,u) = \sum_{u\in S,,v\in T} f(u,v) - \sum_{v\in T,,u\in S} f(v,u)$$&lt;/p&gt;
&lt;p&gt;第一项是从 $S$ 到 $T$ 的边的流量之和，第二项是从 $T$ 到 $S$ 的边的流量之和。由于流量非负，第二项 $\geqslant 0$，因此：&lt;/p&gt;
&lt;p&gt;$$\left\lvert f\right\rvert \leqslant \sum_{u\in S,,v\in T} f(u,v)$$&lt;/p&gt;
&lt;p&gt;再由容量约束 $f(u,v) \leqslant c(u,v)$，得：&lt;/p&gt;
&lt;p&gt;$$\left\lvert f\right\rvert \leqslant \sum_{u\in S,,v\in T} c(u,v) = c(S,T)$$&lt;/p&gt;
&lt;p&gt;证毕！
:::&lt;/p&gt;
&lt;p&gt;故，推论：最大流 $\leqslant$ 最小割。&lt;/p&gt;
&lt;h4&gt;$2\degree$ 强对偶性（$\exist$ 流 $=$ 某个割）&lt;/h4&gt;
&lt;p&gt;引理2：设 $f$ 是最大流，定义 $S$ 为残量网络中从 $s$ 出发可达的节点集合。则 $(S,T)$ 是一个割，且 $\left\lvert f\right\rvert = c(S,T)$。&lt;/p&gt;
&lt;p&gt;:::info[残量网络定义]{open}
对原图每条边 $(u,v)$，在残量网络中保留两条有向边：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;正向残量边：容量为 $c(u,v)-f(u,v)$（还可增加流量）&lt;/li&gt;
&lt;li&gt;反向残量边：容量为 $f(u,v)$（还可减少流量）
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;:::info[证明]&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;先证明&lt;/strong&gt; $t\notin S$。&lt;/p&gt;
&lt;p&gt;反证法。假设 $t\in S$，则 $\exist$ 一条从 $s$ 到 $t$ 的残量路径。沿着这条路径，我们可以增加一个正数 $\delta$ 的流量（取路径上 $\min$ 残量），从而得到更大的流，与 $f$ 是最大流矛盾。因此 $t\notin S$，故 $(S,T)$ 是 $s{-}t$ 割。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;再证明&lt;/strong&gt; $\forall,u\in S,\ v\in T$，原边 $(u,v)$ 必然饱和。&lt;/p&gt;
&lt;p&gt;依旧反证法。若 $\exist,u\in S$，$v\in T$ 使得 $f(u,v) &amp;#x3C; c(u,v)$，则正向残量 $c(u,v)-f(u,v) &gt; 0$，意味着残量网络中有一条从 $u$ 到 $v$ 的边。由于 $u\in S$（从 $s$ 可达），那么 $v$ 也可达，从而 $v\in S$，与 $v\in T$ 矛盾。因此 $f(u,v)=c(u,v)$。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;接着证明&lt;/strong&gt; $\forall,u\in T$，$v\in S$，原边 $(u,v)$ 必然无流量。&lt;/p&gt;
&lt;p&gt;还是反证法。若存在 $u\in T$，$v\in S$ 使得 $f(u,v) &gt; 0$，则反向残量 $f(u,v) &gt; 0$，意味着残量网络中有一条从 $v$ 到 $u$ 的边。由于 $v\in S$（从 $s$ 可达），那么 $u$ 也可达，从而 $u\in S$，与 $u\in T$ 矛盾。因此 $f(u,v)=0$。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;最后计算&lt;/strong&gt; $\left\lvert f\right\rvert$。&lt;/p&gt;
&lt;p&gt;由弱对偶性证明中的等式：
$$\left\lvert f\right\rvert = \sum_{u\in S,,v\in T} f(u,v) - \sum_{v\in T,,u\in S} f(v,u)$$&lt;/p&gt;
&lt;p&gt;由“再证明”的结论，第一项中 $f(u,v)=c(u,v)$；由“接着证明”的结论，第二项中 $f(v,u)=0$。因此：
$$\left\lvert f\right\rvert = \sum_{u\in S,,v\in T} c(u,v) = c(S,T)$$&lt;/p&gt;
&lt;p&gt;这就找到了一个割，其容量等于 $\left\lvert f\right\rvert$。证毕！
:::&lt;/p&gt;
&lt;p&gt;综上，证毕！
::::&lt;/p&gt;
&lt;h2&gt;Part. 4 增广路定理&lt;/h2&gt;
&lt;p&gt;定理：一个可行流 $f$ 是最大流当且仅当残量网络 $G_f$ 中不存在 $s$ 到 $t$ 的路径（称为增广路）。&lt;/p&gt;
&lt;p&gt;:::info[证明]
（$\Rightarrow$）若存在增广路 $P$，设 $\delta = \min{r(u,v): (u,v)\in P} &gt; 0$。沿 $P$ 增加 $\delta$ 流量：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;对正向残量边：$f(u,v) \leftarrow f(u,v) + \delta$&lt;/li&gt;
&lt;li&gt;对反向残量边：$f(v,u) \leftarrow f(v,u) - \delta$&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;得到的新流仍满足容量约束，且 $|f&apos;| = \left\lvert f\right\rvert + \delta &gt; \left\lvert f\right\rvert$，故 $f$ 不是最大流。逆否命题成立。&lt;/p&gt;
&lt;p&gt;（$\Leftarrow$）若无增广路，定义 $S$ 为 $s$ 在 $G_f$ 中可达的节点集，则 $t\notin S$。由 Part.3 “再证明”的证明过程，$\left\lvert f\right\rvert = c(S,T)$，再由弱对偶性知 $f$ 是最大流。证毕！
:::&lt;/p&gt;
&lt;h2&gt;Part.5 Dinic 算法的分层图引理&lt;/h2&gt;
&lt;p&gt;定义：在残量网络中，定义 $d(u)$ 为从 $s$ 到 $u$ 的最短边数（BFS 距离）。边 $(u,v)$ 称为允许边若 $d(v) = d(u) + 1$ 且残量 $&gt;0$。所有允许边构成分层图 $L_f$。阻塞流是指在 $L_f$ 中无法再找到增广路的流。&lt;/p&gt;
&lt;p&gt;引理：记 $d_k(t)$ 为第 $k$ 次阻塞流增广后 $t$ 的距离。则 $d_{k+1}(t) &gt; d_k(t)$。&lt;/p&gt;
&lt;p&gt;:::info[证明]
设 $f$ 是当前流，$f&apos;$ 是增广一次阻塞流后得到的新流。考虑 $G_{f&apos;}$ 中 $s$ 到 $t$ 的最短路径 $P$。若 $P$ 中存在一条边 $(u,v)$ 在 $G_f$ 中不存在（即由增广操作新产生的反向边），则 $f(v,u) &gt; 0$，这意味着在 $G_f$ 中 $u$ 到 $v$ 有容量 $&gt;0$ 的边。由 $P$ 的最短性可推出矛盾。因此 $P$ 中的所有边都在 $G_f$ 中存在，但阻塞流增广后，至少有一条 $G_f$ 中的最短路径上的边被饱和，故 $P$ 的长度必然大于 $d_k(t)$。证毕！
:::&lt;/p&gt;
&lt;p&gt;推论：Dinic 算法中 BFS 的次数不超过 $\lvert V\rvert$，故总复杂度 $O(\lvert V\rvert^2\lvert E\rvert)$。&lt;/p&gt;
&lt;h2&gt;Part.6 Dinic 算法实践&lt;/h2&gt;
&lt;h3&gt;当前弧优化&lt;/h3&gt;
&lt;p&gt;代码中的 &lt;code&gt;cur[]&lt;/code&gt; 实现了当前弧优化。其原理是：在 DFS 过程中，若某条边已被尝试且无法推送更多流量，则同一轮 BFS 分层中无需再次尝试，直接从下一条边开始。&lt;/p&gt;
&lt;h3&gt;代码&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;struct Edge { int to, weight, nxt; } edges[MAXM &amp;#x3C;&amp;#x3C; 1];
int head[MAXN], ecnt = 2, n, m;
void addedge(int u, int v, int weight) {
    edges[ecnt] = Edge{v, weight, head[u]};
    head[u] = ecnt++;
}

int dep[MAXN], cur[MAXN], s, t;
bool bfs() {
    clean(dep);
    queue &amp;#x3C; int &gt; q;
    dep[s] = 1;
    q.psh(s);
    while (q.size()) {
        int u = q.front(); q.pop();
        for (int i = head[u]; i; i = edges[i].nxt) {
            int v = edges[i].to;
            if (!dep[v] &amp;#x26;&amp;#x26; edges[i].weight) {
                dep[v] = dep[u] + 1; q.psh(v);
                if (v == t) return true;
            }
        }
    }
    return false;
}

int dfs(int u, int flow) {
    if (u == t) return flow;
    int used = 0;
    for (int &amp;#x26;i = cur[u]; i; i = edges[i].nxt) {
        int v = edges[i].to;
        if (dep[v] == dep[u] + 1 &amp;#x26;&amp;#x26; edges[i].weight) {
            int res = dfs(v, min(flow - used, edges[i].weight));
            if (res) {
                edges[i].weight -= res;
                edges[i ^ 1].weight += res;
                used += res;
            }
            if (used == flow) break;
        }
    }
    return used;
}

int dinic() {
    int mf = 0;
    while (bfs()) {
        memcpy(cur, head, sizeof cur);
        while (int res = dfs(s, inf)) mf += res;
    }
    return mf;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Part.7 HLPP（最高标号预流推进）算法&lt;/h2&gt;
&lt;h3&gt;7.1 算法思想和基本概念&lt;/h3&gt;
&lt;p&gt;HLPP（Highest-Label Preflow Push）与 Dinic 等增广路算法不同，采用预流推进的思路：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;不保持流量守恒：允许节点暂时存储超额流。&lt;/li&gt;
&lt;li&gt;高度函数：给每个节点一个高度，流只能从高处向低处推送。&lt;/li&gt;
&lt;li&gt;最高标号优先：每次选择高度最高的活跃节点处理。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;定义超额流 $e(u)$：
$$e(u) = \sum_{v} f(v,u) - \sum_{v} f(u,v)$$&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;当 $e(u) &gt; 0$ 时，$u$ 称为&lt;strong&gt;活跃节点&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;源点 $s$ 和汇点 $t$ 除外&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;定义高度函数 $h(u)$：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;流只能从高向低推：$h(u) = h(v) + 1$&lt;/li&gt;
&lt;li&gt;初始高度：从 $t$ 反向 BFS 得到，$h(t)=0$，$h(s)=n$&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;7.2 核心操作&lt;/h3&gt;
&lt;p&gt;推流：当 $e(u) &gt; 0$ 且存在边 $(u,v)$ 满足 $r(u,v) &gt; 0$ 且 $h(u) = h(v) + 1$ 时，推送流量：
$$\delta = \min(e(u), r(u,v))$$&lt;/p&gt;
&lt;p&gt;重贴标签：当 $e(u) &gt; 0$ 但无可推流的邻居时，更新高度：
$$h(u) = \min{h(v) + 1 \mid r(u,v) &gt; 0}$$&lt;/p&gt;
&lt;h3&gt;7.4 核心优化&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;最高标号优先：使用优先队列或桶维护活跃节点，每次取高度最大的处理。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;GAP 优化：若某个高度 $k$ 的节点数为 0，则所有高度 $&gt;k$ 的节点无法到达 $t$，直接将其高度设为 $n+1$。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;当前弧优化：与 Dinic 相同，避免重复遍历已饱和的边。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;7.5 算法流程&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;HLPP(s, t):
    1. 反向 BFS 初始化高度 h，h[s] = n
    2. 从 s 饱和推流，将活跃节点入桶
    3. while mxh &gt;= 0:
         u = 桶中最高高度的节点
         for 当前弧遍历出边:
             if 边有残量 and h[u] == h[v] + 1:
                 push(u, v)
                 if e[u] == 0: break
         if e[u] &gt; 0:
             relabel(u)
    4. return e[t]
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;7.6 代码实现&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;struct Edge { int to, nxt, cap; } edges[MAXM];
int head[MAXN], ecnt = 2, n, m;
void addedge(int u, int v, int cap) {
    edges[ecnt] = {v, head[u], cap}, head[u] = ecnt++;
    edges[ecnt] = {u, head[v], 0}, head[v] = ecnt++;
}

int h[MAXN], eflow[MAXN], cur[MAXN], gap[MAXN &amp;#x3C;&amp;#x3C; 1], mxh, s, t;
vi bucket[MAXN &amp;#x3C;&amp;#x3C; 1];
bool inq[MAXN];

void bfs() {
    memset(h, 0x3f, sizeof h);
    static int q[MAXN], qh, qt;
    h[t] = 0, q[qt = 0] = t, qh = 0, ++qt;
    while (qh &amp;#x3C; qt) {
        int u = q[qh++];
        for (int i = head[u]; i; i = edges[i].nxt) {
            int v = edges[i].to;
            if (edges[i ^ 1].cap &amp;#x26;&amp;#x26; h[v] &gt; h[u] + 1)
                h[v] = h[u] + 1,
                q[qt++] = v;
        }
    }
    h[s] = n;
}

void push(int u) {
    for (int &amp;#x26;i = cur[u]; i; i = edges[i].nxt) {
        int v = edges[i].to;
        if (edges[i].cap &amp;#x26;&amp;#x26; h[u] == h[v] + 1) {
            int delta = min(eflow[u], edges[i].cap);
            if (!delta) continue;
            edges[i].cap -= delta, edges[i ^ 1].cap += delta;
            eflow[u] -= delta, eflow[v] += delta;
            if (v != s &amp;#x26;&amp;#x26; v != t &amp;#x26;&amp;#x26; !inq[v] &amp;#x26;&amp;#x26; eflow[v])
                inq[v] = true,
                bucket[h[v]].pb(v),
                mxh = max(mxh, h[v]);
            if (!eflow[u]) break;
        }
    }
}

void relabel(int u) {
    int mnh = inf;
    for (int i = head[u]; i; i = edges[i].nxt)
        if (edges[i].cap) mnh = min(mnh, h[edges[i].to]);
    int nwh = mnh + 1;
    if (!(--gap[h[u]]) &amp;#x26;&amp;#x26; h[u] &amp;#x3C; n) {
        up(i, 1, n) if (i != s &amp;#x26;&amp;#x26; i != t &amp;#x26;&amp;#x26; h[i] &gt; h[u] &amp;#x26;&amp;#x26; h[i] &amp;#x3C;= n) h[i] = n + 1;
        up(i, h[u] + 1, n) {
            for (int v : bucket[i]) inq[v] = false;
            bucket[i].clear();
            gap[n] += gap[i], gap[i] = 0;
        }
    }
    h[u] = nwh;
    if (nwh &amp;#x3C;= n)
        ++gap[nwh],
        bucket[nwh].pb(u),
        inq[u] = true,
        mxh = max(mxh, nwh);
    cur[u] = head[u];
}

int hlpp() {
    if (s == t) return 0;
    bfs(); clean(gap), clean(eflow), clean(inq);
    up(i, 1, n) {
        if (h[i] &amp;#x3C; n) ++gap[h[i]];
        else ++gap[n];
    }
    for (int i = head[s]; i; i = edges[i].nxt) {
        int v = edges[i].to, cap = edges[i].cap;
        if (cap) {
            edges[i].cap -= cap, edges[i ^ 1].cap += cap;
            eflow[s] -= cap, eflow[v] += cap;
            if (v != t &amp;#x26;&amp;#x26; eflow[v] &amp;#x26;&amp;#x26; !inq[v] &amp;#x26;&amp;#x26; h[v] &amp;#x3C; n)
                inq[v] = true,
                bucket[h[v]].pb(v),
                mxh = max(mxh, h[v]);
        }
    }
    while (mxh &gt;= 0) {
        while (mxh &gt;= 0 &amp;#x26;&amp;#x26; bucket[mxh].empty()) --mxh;
        if (mxh &amp;#x3C; 0) break;
        int u = bucket[mxh].back(); bucket[mxh].ppb(); inq[u] = false;
        if (!eflow[u]) continue;
        if (!cur[u]) cur[u] = head[u];
        push(u);
        if (eflow[u]) relabel(u);
    }
    return eflow[t];
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Part.8 题目选讲 A&lt;/h2&gt;
&lt;h3&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P3376&quot;&gt;P3376 【模板】网络最大流&lt;/a&gt; &amp;#x26; &lt;a href=&quot;https://www.luogu.com.cn/problem/P4722&quot;&gt;P4722 【模板】最大流 加强版 / 预流推进&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;模板题，代码见上。&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P2740&quot;&gt;P2740 [USACO4.2] 草地排水 Drainage Ditches&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;$$s=1,\ t=n$$&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P2936&quot;&gt;P2936 [USACO09JAN] Total Flow S&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;换成字符。&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P1343&quot;&gt;P1343 地震逃生&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;$ans=0$ 特判。&lt;/p&gt;
&lt;h3&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P3386&quot;&gt;P3386 【模板】二分图最大匹配&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;构造：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;虚拟一个 $s$，与左部所有点建边。&lt;/li&gt;
&lt;li&gt;左右部建边。&lt;/li&gt;
&lt;li&gt;虚拟一个 $t$，与右部所有点建边。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如图：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/u9ov9vcs.png&quot; alt=&quot;1&quot;&gt;&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>JC 提高班期末测试题解</title><link>https://blog.rusin7.com/article/jc-the-end-of-class-test-solution</link><guid isPermaLink="true">https://blog.rusin7.com/article/jc-the-end-of-class-test-solution</guid><description>题目描述雪花图是由两个整数x和y均大于1生成的，生成方式如下</description><pubDate>Sat, 06 Jun 2026 18:52:35 GMT</pubDate><content:encoded>&lt;h1&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/CF1829F&quot;&gt;T1 雪花图&lt;/a&gt;&lt;/h1&gt;
&lt;h2&gt;题目描述&lt;/h2&gt;
&lt;p&gt;雪花图是由两个整数 $x$ 和 $y$（均大于 $1$）生成的，生成方式如下：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;以一个中心顶点开始。&lt;/li&gt;
&lt;li&gt;将 $x$ 个新顶点与该中心顶点相连。&lt;/li&gt;
&lt;li&gt;对每一个这 $x$ 个顶点，各自连接 $y$ 个新顶点。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;例如，下图是 $x=5$，$y=3$ 的雪花图。
&lt;img src=&quot;https://cdn.luogu.com.cn/upload/vjudge_pic/CF1829F/8093abf53ab9afd4293f2937f4849e3ca604a47a.png&quot; alt=&quot;1&quot;&gt;
上图中的雪花图有一个中心顶点 $15$，然后有 $x=5$ 个顶点与其相连（$3$、$6$、$7$、$8$ 和 $20$），每个顶点又分别连接 $y=3$ 个顶点。&lt;/p&gt;
&lt;p&gt;给定一个雪花图，请你求出 $x$ 和 $y$ 的值。&lt;/p&gt;
&lt;h2&gt;输入格式&lt;/h2&gt;
&lt;p&gt;第一行包含一个整数 $t$（$1 \leq t \leq 1000$），表示测试用例的数量。&lt;/p&gt;
&lt;p&gt;每个测试用例的第一行包含两个整数 $n$ 和 $m$（$2 \leq n \leq 200$；$1 \leq m \leq \min\left(1000, \frac{n(n-1)}{2}\right)$），分别表示图中的顶点数和边数。&lt;/p&gt;
&lt;p&gt;接下来的 $m$ 行，每行包含两个整数 $u$ 和 $v$（$1 \leq u, v \leq n$，$u \neq v$），表示一条连接顶点 $u$ 和 $v$ 的边。图中没有重边和自环。&lt;/p&gt;
&lt;p&gt;保证给定的图一定是某组大于 $1$ 的整数 $x$ 和 $y$ 所对应的雪花图。&lt;/p&gt;
&lt;h2&gt;输出格式&lt;/h2&gt;
&lt;p&gt;对于每个测试用例，输出一行，包含两个整数 $x$ 和 $y$，用空格分隔，顺序不能颠倒。&lt;/p&gt;
&lt;h2&gt;输入输出样例 #1&lt;/h2&gt;
&lt;h3&gt;输入 #1&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;3
21 20
21 20
5 20
13 20
1 3
11 3
10 3
4 8
19 8
14 8
9 7
12 7
17 7
18 6
16 6
2 6
6 15
7 15
8 15
20 15
3 15
7 6
1 2
1 3
2 4
2 5
3 6
3 7
9 8
9 3
3 6
6 2
2 1
5 2
2 7
4 3
3 8
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;输出 #1&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;5 3
2 2
2 3
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;说明/提示&lt;/h2&gt;
&lt;p&gt;第一个测试用例如题面所示。注意输出 $3\ 5$ 是错误的，因为 $x$ 应该在 $y$ 之前输出。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int t,n,m,cnt[205],mx,ends1[205],u[1005],v[1005];
int check(int x){
	for(int i=1;i&amp;#x3C;=m;++i){
		if((u[i]==x&amp;#x26;&amp;#x26;ends1[v[i]]==1)||(v[i]==x&amp;#x26;&amp;#x26;ends1[u[i]]==1)){
			return 0;
		}
	}
	return 1;
}
int main(){
	cin&gt;&gt;t;
	while(t--){
		int x=0,y=0;
		cin&gt;&gt;n&gt;&gt;m;
		memset(ends1,0,sizeof ends1),memset(cnt,0,sizeof cnt),mx=0;
		for(int i=1;i&amp;#x3C;=m;++i){
			cin&gt;&gt;u[i]&gt;&gt;v[i];
			cnt[u[i]]++,cnt[v[i]]++;
			mx=max({u[i],v[i],mx});
		}
		for(int i=1;i&amp;#x3C;=mx;++i){
			if(cnt[i]==1){
				ends1[i]=1;
				y++;
			}
		}
		for(int j=1;j&amp;#x3C;=n;++j){
			if(ends1[j]!=1&amp;#x26;&amp;#x26;check(j)){
				x=cnt[j];
			}else if(ends1[j]!=1&amp;#x26;&amp;#x26;check(j)){
				x=cnt[j];
			}
		}
		cout&amp;#x3C;&amp;#x3C;x&amp;#x3C;&amp;#x3C;&quot; &quot;&amp;#x3C;&amp;#x3C;y/x&amp;#x3C;&amp;#x3C;endl;
	}
	return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P1341&quot;&gt;T2 字母对拼接谜题&lt;/a&gt;&lt;/h1&gt;
&lt;h2&gt;故事背景&lt;/h2&gt;
&lt;p&gt;字母王国里流传着一个古老的拼接谜题：传说有一组散落的字母伙伴，每一对伙伴都有着密不可分的羁绊，它们必须紧紧相邻才能发挥魔力。现在，你作为字母王国的解谜者，需要将这些字母伙伴重新组合成一条完整的字母链，让每一对羁绊深厚的字母都能在链中相邻出现。这条字母链的长度恰好比字母对的数量多1，并且如果存在多种组合方式，请给出字典序最小的那一条——这是字母王国传承已久的规则，字典序越小，魔力越纯净。若是无法完成拼接，就只能遗憾地告知王国：无解。&lt;/p&gt;
&lt;h2&gt;题目描述&lt;/h2&gt;
&lt;p&gt;给定 n 个各不相同的无序字母对（区分大小写，无序意味着字母对中的两个字母可以交换位置相邻，例如“aZ”与“Za”视为满足相邻要求）。请你构造一个包含 (n+1) 个字母的字符串，使得每个给定的字母对都能在这个字符串中相邻出现。&lt;/p&gt;
&lt;h2&gt;输入格式&lt;/h2&gt;
&lt;p&gt;第一行输入一个正整数 n，代表无序字母对的数量。&lt;/p&gt;
&lt;p&gt;第二行到第 (n+1) 行，每行输入两个字母，代表一对需要相邻的字母。&lt;/p&gt;
&lt;h2&gt;输出格式&lt;/h2&gt;
&lt;p&gt;输出满足要求的字符串。&lt;/p&gt;
&lt;p&gt;如果不存在满足要求的字符串，请输出 &lt;code&gt;No Solution&lt;/code&gt;。&lt;/p&gt;
&lt;p&gt;如果存在多种满足要求的方案，请输出字典序最小的方案（即字符串中前面的字母，其 ASCII 编码尽可能小）。&lt;/p&gt;
&lt;h2&gt;输入输出样例 #1&lt;/h2&gt;
&lt;h3&gt;输入 #1&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;4
aZ
tZ
Xt
aX
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;输出 #1&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;XaZtX
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;说明/提示&lt;/h2&gt;
&lt;p&gt;n 的规模限制如下：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$25%$ 的测试数据中，$n = 2$；&lt;/li&gt;
&lt;li&gt;$50%$ 的测试数据中，$n ≤ 10$；&lt;/li&gt;
&lt;li&gt;$75%$ 的测试数据中，$n ≤ 100$；&lt;/li&gt;
&lt;li&gt;$100%$ 的测试数据中，$n ≤ 600$。&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/CF2176D&quot;&gt;T3 广义斐波那契图&lt;/a&gt;&lt;/h1&gt;
&lt;h2&gt;题目描述&lt;/h2&gt;
&lt;p&gt;给定一个包含 $n$ 个顶点和 $m$ 条边的有向图。每个顶点 $v$ 上对应一个正整数 $a_v$。请你统计所有由至少两个顶点组成的不同简单路径，使得沿路径经过顶点的数字序列构成一个广义斐波那契数列。&lt;/p&gt;
&lt;p&gt;在本题中，若数列 $x_0, x_1, \ldots, x_k$ 满足以下条件，则称其为广义斐波那契数列：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$x_0, x_1$ 为任意自然数。&lt;/li&gt;
&lt;li&gt;对所有 $2 \le i \le k$，都有 $x_i = x_{i-2} + x_{i-1}$。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;注意，广义斐波那契数列至少包含两个数字。&lt;/p&gt;
&lt;p&gt;由于答案可能很大，输出其对 $998,244,353$ 取模的结果。&lt;/p&gt;
&lt;p&gt;一个简单路径指在有向图中按顺序经过顶点 $v_1, v_2, \ldots, v_k$，且所有顶点至多出现一次，并且对于所有 $i &amp;#x3C; k$，存在从 $v_i$ 到 $v_{i+1}$ 的有向边。&lt;/p&gt;
&lt;h2&gt;输入格式&lt;/h2&gt;
&lt;p&gt;每个测试点包含若干组测试数据。第一行为测试数据组数 $t$（$1 \le t \le 10^4$）。每组测试数据包括：&lt;/p&gt;
&lt;p&gt;第一行，两个整数 $n$ 和 $m$（$2 \le n \le 2 \cdot 10^5$，$1 \le m \le 2 \cdot 10^5$）——图中顶点数和边数。&lt;/p&gt;
&lt;p&gt;第二行为 $n$ 个正整数 $a_1, a_2, \ldots, a_n$（$1 \le a_i \le 10^{18}$）——每个顶点上的数字。&lt;/p&gt;
&lt;p&gt;接下来 $m$ 行，每行两个正整数 $v, u$（$1 \le v, u \le n$，$u \ne v$），表示一条从 $v$ 到 $u$ 的有向边。保证不存在重边。&lt;/p&gt;
&lt;p&gt;保证所有测试数据中 $n$ 的总和与 $m$ 的总和不超过 $2 \times 10^5$。&lt;/p&gt;
&lt;h2&gt;输出格式&lt;/h2&gt;
&lt;p&gt;对于每组测试数据，输出广义斐波那契路径的数量，对 $998,244,353$ 取模。&lt;/p&gt;
&lt;h2&gt;输入输出样例 #1&lt;/h2&gt;
&lt;h3&gt;输入 #1&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;4
4 4
3 4 3 6
1 2
1 3
2 4
3 4
4 6
1 1 1 2
1 2
2 3
3 1
1 4
2 4
3 4
8 11
2 4 2 6 8 10 18 26
1 2
2 3
3 1
4 3
2 4
3 5
5 6
4 6
6 7
7 5
5 8
2 2
10 10
1 2
2 1
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;输出 #1&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;5
9
24
2
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;说明/提示&lt;/h2&gt;
&lt;p&gt;第一个样例的解释（顶点编号在括号外，顶点上的数字在括号内）：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/vjudge_pic/CF2176D/08a36bd25194bfe2a6b3cff05123bcbef288fa7e15461f59eaa9b70bf8283240.png&quot; alt=&quot;1&quot;&gt;&lt;/p&gt;
&lt;p&gt;本例中共有 5 条广义斐波那契路径：(1, 2), (1, 3), (2, 4), (3, 4), (1, 3, 4)。例如，路径 (1, 3, 4) 沿途顶点上的数字序列为：[3, 3, 6]，可以看到第三个数字等于前两个数字之和。&lt;/p&gt;
&lt;p&gt;第二个样例的解释：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://cdn.luogu.com.cn/upload/vjudge_pic/CF2176D/3d6ae42c81941d0c88d6fab78b53e70455364bccfff538a925d5ee91dc0f8e9a.png&quot; alt=&quot;1&quot;&gt;&lt;/p&gt;
&lt;p&gt;本例中共有 9 条广义斐波那契路径：(1, 2), (1, 4), (2, 3), (2, 4), (3, 1), (3, 4), (1, 2, 4), (2, 3, 4), (3, 1, 4)。注意，路径 (1, 2, 3) 上的数字序列为：[1, 1, 1]，这不是广义斐波那契数列。&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>题解：P8506 标题计数</title><link>https://blog.rusin7.com/article/p8506-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/p8506-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 P8506 标题计数，思路清晰、排版精美</description><pubDate>Sat, 06 Jun 2026 16:08:22 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2&gt;前言&lt;/h2&gt;
&lt;p&gt;本篇题解适合&lt;strong&gt;刚学&lt;a href=&quot;https://www.luogu.com.cn/problem/list?type=luogu&amp;#x26;page=1&amp;#x26;tag=357&quot;&gt;字符串&lt;/a&gt;和&lt;a href=&quot;https://www.luogu.com.cn/problem/list?type=luogu&amp;#x26;difficulty=1&amp;#x26;page=1&amp;#x26;tag=1&quot;&gt;模拟&lt;/a&gt;的同学&lt;/strong&gt;阅读，语言浅显易懂。~~谁让作者是个蒟蒻呢。~~&lt;/p&gt;
&lt;h2&gt;题目分析&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;核心条件&lt;/strong&gt;：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;第一个非空格字符&lt;strong&gt;必须&lt;/strong&gt;是井号 &lt;code&gt;#&lt;/code&gt;。&lt;/li&gt;
&lt;li&gt;井号后面&lt;strong&gt;必须&lt;/strong&gt;紧跟着&lt;strong&gt;至少一个&lt;/strong&gt;空格且&lt;strong&gt;不能&lt;/strong&gt;有多个井号相连（如 &lt;code&gt;##&lt;/code&gt;）。&lt;/li&gt;
&lt;li&gt;在井号后面的空格后&lt;strong&gt;必须&lt;/strong&gt;有长度不为 $0$ 的句子。&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;思路引导&lt;/h2&gt;
&lt;p&gt;:::warning[提问]
如何输入一行&lt;strong&gt;含空格&lt;/strong&gt;的字符串？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
使用 string 类型自带的 &lt;code&gt;getline()&lt;/code&gt; 。
:::
:::success[提问]
如何判断字符串是否为一级标题？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
联系我们刚分析完的核心条件，可以进行&lt;strong&gt;模拟&lt;/strong&gt;。具体如下：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;首先，假设读入的字符串 $s$ 不是一级标题，$flag$ 为 false 。再将 $s$ 从头到尾扫一遍。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果 $s_i$ 是空格，直接跳过。&lt;/li&gt;
&lt;li&gt;否则如果 $flag$ 为 true ，说明已经满足核心条件中的 1、2 点，且现在 $s_i$ 不为空格，也满足第 3 点，计数器 $+1$。&lt;/li&gt;
&lt;li&gt;否则如果 $s_i$ 是非 &lt;code&gt;#&lt;/code&gt; 字符，$s$ 必定不是一级标题，跳出循环。&lt;/li&gt;
&lt;li&gt;否则如果 $s_i$ 是 &lt;code&gt;#&lt;/code&gt; 字符且满足核心条件中的 1、2 点，$flag$ 为 true 。&lt;/li&gt;
&lt;li&gt;否则 $s$ 必定不是一级标题，跳出循环。
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;完整代码&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int n,pos,cnt;  // cnt用于计数符合条件的标题
bool flag;      // 标记是否满足标题的前置条件
string s;
int main() {
	cin&gt;&gt;n;
	cin.ignore();  // 忽略n后面的换行符
	while(n--) {
		getline(cin,s);  // 读取一整行文本
		flag=false;      // 初始化标记
		for(int i=0; i&amp;#x3C;s.size(); ++i) {
			if(s[i]!=&apos; &apos;) {  // 遇到非空格字符
				if(flag){  // 如果已标记为满足前置条件
					cnt++;  // 计数加1
					break;  // 跳出循环，无需继续检查
				}
				if(s[i]!=&apos;#&apos;) {  // 非#字符，不是标题
					break;
				}
				// 检查是否为单个#且后面跟着空格
				if(s[i]==&apos;#&apos;&amp;#x26;&amp;#x26;(i==0||s[i-1]!=&apos;#&apos;)&amp;#x26;&amp;#x26;s[i+1]==&apos; &apos;&amp;#x26;&amp;#x26;i+1&amp;#x3C;s.size()) {
					pos=i+1;
					flag=true;  // 标记为满足前置条件
				}
				if(!flag){  // 如果不满足前置条件
					break;    // 跳出循环
				}
			}
		}
	}
	cout&amp;#x3C;&amp;#x3C;cnt;  // 输出结果
	return 0;
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>拯救谷歌和 Github！你的新“自行车”</title><link>https://blog.rusin7.com/article/devsidecar</link><guid isPermaLink="true">https://blog.rusin7.com/article/devsidecar</guid><description>快速安装，找到最新版本，安装包选择方式：Windows：De</description><pubDate>Thu, 14 May 2026 19:02:20 GMT</pubDate><content:encoded>&lt;p&gt;还在为谷歌无法访问而发愁吗？&lt;a href=&quot;https://github.com/docmirror/dev-sidecar&quot;&gt;这个宝藏项目&lt;/a&gt;一定要收藏好😍！顺便还能秒开 Github！&lt;/p&gt;
&lt;h2&gt;快速安装&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/docmirror/dev-sidecar/releases&quot;&gt;打开 Release&lt;/a&gt;，找到最新版本，安装包选择方式：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Windows&lt;/strong&gt;：DevSidecar-x.x.x-windows-universal.exe&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mac&lt;/strong&gt;: DevSidecar-x.x.x-macos-universal.dmg&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linux&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Debian 系等支持 Deb 的：DevSidecar-x.x.x-linux-&amp;#x3C;架构&gt;.deb&lt;/li&gt;
&lt;li&gt;其他：DevSidecar-x.x.x-linux-&amp;#x3C;架构&gt;.AppImage&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;安装可能有点慢，建议以下 4 选 1 加速安装（我的是 2.0.2 Windows 版本，具体链接为 https://gh-proxy.org/+Github 原始链接）：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://gh-proxy.org/https://github.com/docmirror/dev-sidecar/releases/download/v2.0.2/DevSidecar-2.0.2-windows-universal.exe&quot;&gt;主站，全球加速！&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://hk.gh-proxy.org/https://github.com/docmirror/dev-sidecar/releases/download/v2.0.2/DevSidecar-2.0.2-windows-universal.exe&quot;&gt;香港国内线路优化&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://cdn.gh-proxy.org/https://github.com/docmirror/dev-sidecar/releases/download/v2.0.2/DevSidecar-2.0.2-windows-universal.exe&quot;&gt;Fastly CDN&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://edgeone.gh-proxy.org/https://github.com/docmirror/dev-sidecar/releases/download/v2.0.2/DevSidecar-2.0.2-windows-universal.exe&quot;&gt;Edgeone 全球加速&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>Vercel 仅部署指定分支的方法</title><link>https://blog.rusin7.com/article/vercel-deploying-only-1-branch</link><guid isPermaLink="true">https://blog.rusin7.com/article/vercel-deploying-only-1-branch</guid><description>如何指定特殊分支？ 从中选择的项目，在侧边栏中打开Settings</description><pubDate>Tue, 12 May 2026 20:55:55 GMT</pubDate><content:encoded>&lt;h2&gt;如何指定特殊分支&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;从&lt;a href=&quot;https://vercel.com/dashboard&quot;&gt;仪表板&lt;/a&gt;中选择的项目&lt;/li&gt;
&lt;li&gt;在侧边栏中打开 Settings。&lt;/li&gt;
&lt;li&gt;点击 Environments。&lt;/li&gt;
&lt;li&gt;点击 Production 环境（/settings/environments/production）。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;{% tip cogs %}这样配置之后，Vercel 仍然会在任一分支更改时自动构建，结果当然是 {% label Error red %} 了！怎么办呢？{% endtip %}&lt;/p&gt;
&lt;h2&gt;使用分支跟踪（推荐）&lt;/h2&gt;
&lt;p&gt;最直接的方法是在项目设置中配置分支跟踪。默认情况下，Vercel 会在所有分支上触发部署，但可以指定 {% label main red %} red %} 分支作为生产环境分支，这样只有 {% label main red %} 分支的变更才会触发生产部署。&lt;/p&gt;
&lt;p&gt;开启分支跟踪非常简单，按照以下步骤操作：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;从&lt;a href=&quot;https://vercel.com/dashboard&quot;&gt;仪表板&lt;/a&gt;中选择的项目&lt;/li&gt;
&lt;li&gt;在侧边栏中打开 Settings。&lt;/li&gt;
&lt;li&gt;点击 Environments。&lt;/li&gt;
&lt;li&gt;点击 Production 环境（/settings/environments/production）。&lt;/li&gt;
&lt;li&gt;在 Branch Tracking 中，输入想要追踪的分支名称，例如 {% label main red %}。&lt;/li&gt;
&lt;li&gt;点击 &lt;code&gt;Save&lt;/code&gt;。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;还可以在 Preview 环境（/settings/environments/preview）中关闭 Branch Tracking。这样就可以确保只有 {% label main red %} 分支的变更才会触发任何构建。&lt;/p&gt;
&lt;h2&gt;使用 git 配置&lt;/h2&gt;
&lt;p&gt;在项目根目录的 &lt;code&gt;vercel.json&lt;/code&gt; 文件中添加 &lt;code&gt;git.deploymentEnabled&lt;/code&gt; 配置，精确控制哪些分支可以触发部署：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;git&quot;: {
    &quot;deploymentEnabled&quot;: {
      &quot;main&quot;: true
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;使用忽略构建步骤&lt;/h2&gt;
&lt;p&gt;如果需要更灵活的控制，可以在项目设置的“忽略构建步骤”部分使用自定义 Bash 脚本：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;#!/bin/bash
if [[ &quot;$VERCEL_GIT_COMMIT_REF&quot; == &quot;main&quot; ]]; then
  exit 1  # 继续构建
else
  exit 0  # 跳过构建
fi
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>对单一仓库配置小号以远程管理小号仓库</title><link>https://blog.rusin7.com/article/configure-a-single-warehouse</link><guid isPermaLink="true">https://blog.rusin7.com/article/configure-a-single-warehouse</guid><description>命令行操作给这个仓库单独设置小号仅本地生效把远程地址绑定到小</description><pubDate>Mon, 20 Apr 2026 21:16:59 GMT</pubDate><content:encoded>&lt;h2&gt;命令行操作&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;给这个仓库单独设置小号（仅本地生效）&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git config --local user.name &quot;用户名&quot;
git config --local user.email &quot;邮箱&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;把远程地址绑定到小号仓库&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git remote set-url origin https://github.com/用户名/仓库名.git
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;推送（第一次会让你登录小号）&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git push -f origin main
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;登录时怎么填？&lt;/h2&gt;
&lt;p&gt;弹出窗口时：
&lt;strong&gt;使用 SSH 登录&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;在输入框中填入在 &lt;a href=&quot;https://github.com/settings/tokens/new&quot;&gt;这里&lt;/a&gt; 创建的 SSH 密钥（权限建议仅 Repo）。&lt;/p&gt;
&lt;hr&gt;
&lt;blockquote&gt;
&lt;h2&gt;最终效果（最舒服的状态）&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;全局 Git = 大号&lt;/li&gt;
&lt;li&gt;其他所有仓库 = 大号&lt;/li&gt;
&lt;li&gt;只有特定文件夹 = 小号&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;{% note blue &apos;anzhiyufont anzhiyu-icon-bullhorn&apos; modern %}永远不用再切换账号{% endnote %}&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>在 VS code 上远程管理 Github 仓库并自动化部署项目</title><link>https://blog.rusin7.com/article/remote-github-repo-on-vs-code</link><guid isPermaLink="true">https://blog.rusin7.com/article/remote-github-repo-on-vs-code</guid><description>如果GitHub远程是没有提交的空仓库然后再绑定哦。</description><pubDate>Sun, 19 Apr 2026 19:47:17 GMT</pubDate><content:encoded>&lt;h2&gt;如果 GitHub 远程是没有提交的空仓库&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git init
git add -A
git commit -m &quot;🔄️ init:初始化 main 源码分支&quot;
git checkout -b main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后再绑定哦。&lt;/p&gt;
&lt;h2&gt;绑定本地仓库到你已有的 GitHub 远程仓库&lt;/h2&gt;
&lt;p&gt;先把本地和远程仓库建立连接，Ctrl+Shift+`调出 VS code 终端直接执行：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git remote add origin https://github.com/你的用户名/仓库名.git
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;验证绑定成功&lt;/strong&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git remote -v
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;终端输出下面这样，就代表绑定成功：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;origin  git@github.com:xxx/xxx.git (fetch)
origin  git@github.com:xxx/xxx.git (push)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% note info flat %}
报错 &lt;code&gt;fatal: remote origin already exists&lt;/code&gt;：说明之前绑过别的，先执行 &lt;code&gt;git remote remove origin&lt;/code&gt; 解除绑定，再重新执行上面绑定命令即可。
{% endnote %}&lt;/p&gt;
&lt;h2&gt;拉取远程旧 main 分支内容，做安全备份（如果你的仓库原来有 main 分支，可选）&lt;/h2&gt;
&lt;p&gt;远程 {% label main red %} 全是旧的 {% label dist red %} 文件，我们先把它拉到本地，备份成一个旧分支，绝对不覆盖本地源码，全程安全兜底。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git fetch origin
git branch old-main origin/main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;执行完，你本地就多了一个 {% emp old-main %} 备份分支，以前手动上传的所有文件全部永久保留，后续操作完全不会动它。&lt;/p&gt;
&lt;h2&gt;重置本地 main 分支为纯净源码分支&lt;/h2&gt;
&lt;p&gt;你的 &lt;code&gt;.gitignore&lt;/code&gt; 已经写好了 &lt;code&gt;dist&lt;/code&gt;，会自动忽略打包文件夹，不会把 &lt;code&gt;dist&lt;/code&gt; 提交到 {% label main red %} 分支。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git checkout main
git add .
git commit -m &quot;🔄️ init:初始化 main 源码分支&quot; 
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;推送全新源码 main 分支&lt;/h2&gt;
&lt;p&gt;如果 {% label main red %} 分支已经有冲突文件：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git push -f origin main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;否则：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% tip success %}GitHub 远程 {% label main red %} 分支：已经全部是你的项目源码，&lt;code&gt;dist&lt;/code&gt; 文件夹被 .gitignore 自动忽略，完全不会上传到 {% label main red %}！{% endtip %}&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;新建 gh-pages 分支，只存放静态文件&lt;/h2&gt;
&lt;p&gt;这一步专门创建部署分支，全程独立，和 {% label main red %} 分支完全隔离，只存放打包后的 &lt;code&gt;dist&lt;/code&gt; 静态文件。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;pnpm build
cd dist &amp;#x26;&amp;#x26; git init &amp;#x26;&amp;#x26; git add . &amp;#x26;&amp;#x26; git commit -m &quot;init gh-pages&quot; &amp;#x26;&amp;#x26; git push -f git@github.com:你的用户名/仓库名.git HEAD:gh-pages &amp;#x26;&amp;#x26; cd ..
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% tip success %}GitHub 远程 {% label gh-pages red %} 分支：里面只有 &lt;code&gt;dist&lt;/code&gt; 静态网页文件，无任何源码，专门用于 GitHub Pages 网站部署。{% endtip %}&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;日常开发&lt;/h2&gt;
&lt;p&gt;你以后每次修改完代码，更新网页，只需要严格按这个顺序走，再也不用手动上传文件：&lt;/p&gt;
&lt;h3&gt;Vite 项目&lt;/h3&gt;
&lt;h4&gt;1. 开发修改源码（全程在 main 分支）&lt;/h4&gt;
&lt;p&gt;你改完源码后，更新到 GitHub 源码仓库：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git add .
git commit -m &quot;✨ UppubDatetime: 更新源码&quot;
git push origin main
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;2. 打包生成最新的 dist 文件&lt;/h4&gt;
&lt;p&gt;在 main 分支终端执行打包命令（根据你的项目，你的是 vite 项目）&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm run build
# 或 pnpm build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;执行完，本地 &lt;code&gt;dist&lt;/code&gt; 文件夹就会更新为最新打包文件。&lt;/p&gt;
&lt;p&gt;{% note primary flat %}
回到主项目根目录，执行这 2 条全局 git 配置，永久关闭这个烦人的换行符警告：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git config core.autocrlf true
git config core.safecrlf false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% endnote %}&lt;/p&gt;
&lt;h4&gt;3. 一键更新 gh-pages 部署网页&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm run build
# 或 pnpm build
cd dist &amp;#x26;&amp;#x26; git init &amp;#x26;&amp;#x26; git add . &amp;#x26;&amp;#x26; git commit -m &quot;uppubDatetime site&quot; &amp;#x26;&amp;#x26; git push -f git@github.com:你的用户名/你的仓库名.git HEAD:gh-pages &amp;#x26;&amp;#x26; cd ..
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;打包最新静态文件&lt;/li&gt;
&lt;li&gt;一键纯净推送 gh-pages，无任何多余文件&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;NextJs 项目&lt;/h3&gt;
&lt;h4&gt;每次写完代码 $\to$ 推源码（main）&lt;/h4&gt;
&lt;p&gt;Ctrl+Shift+` 打开终端，直接运行：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;git add .
git commit -m &quot;更新项目源码&quot;
git push origin main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% folding green, ✅ 作用 %}
把你的代码推送到小号 {% hideInline 看什么看,查******,#FF7242,#fff %} 的 {% label main red %} 分支（你已经配置好锁死小号，直接推就行）&lt;/p&gt;
&lt;p&gt;{% endfolding %}&lt;/p&gt;
&lt;h3&gt;要发布网页 $\to$ 推静态文件（gh-pages）&lt;/h3&gt;
&lt;p&gt;还是在根目录，直接复制这一条完整命令运行：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm run build &amp;#x26;&amp;#x26; cd out &amp;#x26;&amp;#x26; git add . &amp;#x26;&amp;#x26; git commit -m &quot;更新网页&quot; &amp;#x26;&amp;#x26; git push -f https://ru-sin@github.com/ru-sin/用户名.git HEAD:gh-pages &amp;#x26;&amp;#x26; cd ..
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% note success flat %}
这条命令会自动&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;打包生成最新 &lt;code&gt;out&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;提交网页文件&lt;/li&gt;
&lt;li&gt;强制推送到小号 {% label gh-pages red %} 分支&lt;/li&gt;
&lt;li&gt;退回根目录
{% endnote %}&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2&gt;高级做法（2 选 1）&lt;/h2&gt;
&lt;h3&gt;推送 main 源码后自动推送 gh-pages 分支&lt;/h3&gt;
&lt;p&gt;访问 /settings/actions，下滑找到 &lt;code&gt;Workflow permissions&lt;/code&gt;，勾选 Read and write permissions，点击 &lt;code&gt;Save&lt;/code&gt; 就好了。&lt;/p&gt;
&lt;p&gt;{% label main red %} 分支新建 &lt;code&gt;.github/workflows/deploy.yml&lt;/code&gt;，直接复制代码如下：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yml&quot;&gt;name: 自动部署到 gh-pages

on:
  push:
    branches:
      - main  # 推送到 main 分支就自动触发

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: 拉取代码
        uses: actions/checkout@v4
        with:
          persist-credentials: false

      - name: 安装依赖
        run: npm install

      - name: 编译生成 out 文件夹
        run: npm run build

      - name: 部署到 gh-pages
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./out
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这样就不需要推静态文件（{% label gh-pages red %}）分支了，直接推 {% label main red %} 即可。&lt;/p&gt;
&lt;h3&gt;build 后一行命令部署 dist&lt;/h3&gt;
&lt;p&gt;安装工具。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm install gh-pages --save-dev
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;在 &lt;code&gt;package.json&lt;/code&gt; 里添加部署脚本。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;scripts&quot;: {
    &quot;deploy&quot;: &quot;gh-pages -d dist&quot;
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;部署命令，可以自动部署到 gh-pages 分支。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm run build
npm run deploy
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% tip success %}成功！{% endtip %}&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>侧边栏添加个性定位欢迎信息</title><link>https://blog.rusin7.com/article/location-welcome-information</link><guid isPermaLink="true">https://blog.rusin7.com/article/location-welcome-information</guid><description>前景介绍使用方法创建JS文件</description><pubDate>Mon, 06 Apr 2026 20:58:53 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/z7qOAkod.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;h2&gt;前景介绍&lt;/h2&gt;
&lt;p&gt;:::info[背景]{open}
基于{% btn &apos;https://blog.bsgun.cn/posts/ef58a648/&apos;,梦爱吃鱼的教程 %}进行修改，主要改进是&lt;strong&gt;更换 API 地址&lt;/strong&gt;，因为&lt;a href=&quot;https://api.nsmao.net/&quot;&gt;原 API&lt;/a&gt; 已经失效。
:::&lt;/p&gt;
&lt;h2&gt;使用方法&lt;/h2&gt;
&lt;h3&gt;创建 JS 文件&lt;/h3&gt;
&lt;p&gt;在博客主题目录的 js 文件夹（~\themes\anzhiyu\source\js）下创建 welcome.js 文件(也可以在source文件夹下另外新建文件夹)。&lt;/p&gt;
&lt;h3&gt;配置经纬度&lt;/h3&gt;
&lt;p&gt;{% btn &apos;https://uapis.cn/api/v1/network/myip?source=commercial&apos;,点击这里 %}，找到&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;latitude&quot;: xxx,&quot;longitude&quot;: xxx,
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;复制对应的经度(lng)和纬度(lat)值。&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;将以下内容复制到 &lt;code&gt;welcome.js&lt;/code&gt; 中,并修改文件顶部配置信息&lt;/p&gt;
&lt;p&gt;:::success[代码]&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;window.IP_CONFIG = {
    BLOG_LOCATION: {
        lng: 121.4, // 博主经度
        lat: 29.9,  // 博主纬度
    },
    CACHE_DURATION: 1000 * 60 * 60, // 缓存1小时
    HOME_PAGE_ONLY: true, // 是否只在首页显示
};

// 添加样式
const addStyles = () =&gt; {
    const style = document.createElement(&apos;style&apos;);
    style.textContent = `
        #welcome-info {
            user-select: none;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 212px;
            padding: 10px;
            margin-top: 5px;
            border-radius: 12px;
            background-color: var(--anzhiyu-background);
            outline: 1px solid var(--anzhiyu-card-border);
        }
        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 3px solid rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            border-top: 3px solid var(--anzhiyu-main);
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        .ip-address {
            filter: blur(5px);
            transition: filter 0.3s ease;
        }
        .ip-address:hover {
            filter: blur(0);
        }
        .error-message {
            color: #ff6565;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        .error-message p,
        .permission-dialog p {
            margin: 0;
        }
        .error-icon {
            font-size: 3rem;
        }
        #retry-button {
            margin: 0 5px;
            color: var(--anzhiyu-main);
            transition: transform 0.3s ease;
            cursor: pointer;
        }
        #retry-button:hover {
            transform: rotate(180deg);
        }
    `;
    document.head.appendChild(style);
};

// 获取欢迎信息元素
const getWelcomeInfoElement = () =&gt; document.querySelector(&apos;#welcome-info&apos;);

// 显示加载动画
const showLoadingSpinner = () =&gt; {
    const welcomeInfoElement = getWelcomeInfoElement();
    if (!welcomeInfoElement) return;
    welcomeInfoElement.innerHTML = &apos;&amp;#x3C;div class=&quot;loading-spinner&quot;&gt;&amp;#x3C;/div&gt;&apos;;
};

// 显示错误信息
const showErrorMessage = (message = &apos;抱歉，无法获取信息&apos;) =&gt; {
    const welcomeInfoElement = getWelcomeInfoElement();
    if (!welcomeInfoElement) return;
  
    welcomeInfoElement.innerHTML = `
        &amp;#x3C;div class=&quot;error-message&quot;&gt;
            &amp;#x3C;div class=&quot;error-icon&quot;&gt;😕&amp;#x3C;/div&gt;
            &amp;#x3C;p&gt;${message}&amp;#x3C;/p&gt;
            &amp;#x3C;p&gt;请&amp;#x3C;i id=&quot;retry-button&quot; class=&quot;fa-solid fa-arrows-rotate&quot;&gt;&amp;#x3C;/i&gt;重试或检查网络连接&amp;#x3C;/p&gt;
        &amp;#x3C;/div&gt;
    `;
    document.getElementById(&apos;retry-button&apos;).addEventListener(&apos;click&apos;, fetchIpInfo);
};

// 缓存相关
const IP_CACHE_KEY = &apos;ip_info_cache&apos;;
const getIpInfoFromCache = () =&gt; {
    const cached = localStorage.getItem(IP_CACHE_KEY);
    if (!cached) return null;
  
    const { data, timestamp } = JSON.parse(cached);
    if (publishDate.now() - timestamp &gt; IP_CONFIG.CACHE_DURATION) {
        localStorage.removeItem(IP_CACHE_KEY);
        return null;
    }
    return data;
};

const setIpInfoCache = (data) =&gt; {
    localStorage.setItem(IP_CACHE_KEY, JSON.stringify({
        data,
        timestamp: publishDate.now()
    }));
};

// 计算距离
const calculateDistance = (lng, lat) =&gt; {
    const R = 6371; // 地球半径(km)
    const rad = Math.PI / 180;
    const dLat = (lat - IP_CONFIG.BLOG_LOCATION.lat) * rad;
    const dLon = (lng - IP_CONFIG.BLOG_LOCATION.lng) * rad;
    const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
        Math.cos(IP_CONFIG.BLOG_LOCATION.lat * rad) * Math.cos(lat * rad) *
        Math.sin(dLon / 2) * Math.sin(dLon / 2);
    return Math.round(R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
};

// 格式化IP显示
const formatIpDisplay = (ip) =&gt; {
    if (!ip) return &quot;未知IP&quot;;
    return ip.includes(&quot;:&quot;) ? &quot;IPv6地址&quot; : ip;
};

// 格式化位置
const formatLocation = (region) =&gt; {
    if (!region) return &apos;神秘地区&apos;;
    return region.replace(/\s+/g, &quot; &quot;);
};

// 时段问候
const getTimeGreeting = () =&gt; {
    const hour = new publishDate().getHours();
    if (hour &amp;#x3C; 11) return &quot;早上好🌤️，一日之计在于晨&quot;;
    if (hour &amp;#x3C; 13) return &quot;中午好☀️，记得午休喔~&quot;;
    if (hour &amp;#x3C; 17) return &quot;下午好🕞，饮茶先啦！&quot;;
    if (hour &amp;#x3C; 19) return &quot;即将下班🚶‍♂️，记得按时吃饭~&quot;;
    return &quot;晚上好🌙，夜生活嗨起来！&quot;;
};

// ====================== 终极修复：适配 浙江、江苏 这种简写 ======================
const getGreeting = (region) =&gt; {
    if (!region) return &quot;带我去你的城市逛逛吧！&quot;;

    const parts = region.trim().split(/\s+/).filter(Boolean);
    const province = parts[1] || &quot;&quot;;
    const city = parts[2] || &quot;&quot;;

    if (city === &quot;南京&quot;) return &quot;六朝古都，风华依旧&quot;;
    if (city === &quot;苏州&quot;) return &quot;上有天堂，下有苏杭&quot;;
    if (city === &quot;杭州&quot;) return &quot;东风渐绿西湖柳，雁已还人未南归&quot;;
    if (city === &quot;郑州&quot;) return &quot;豫州之域，天地之中&quot;;
    if (city === &quot;洛阳&quot;) return &quot;洛阳城里见秋风，欲作家书意万重&quot;;
    if (city === &quot;开封&quot;) return &quot;包公那叫一个铁面无私，严惩贪官污吏&quot;;
    if (city === &quot;宁波&quot;) return &quot;海上丝路的起点，和我一个城市。&quot;;
    if (city === &quot;西安&quot;) return &quot;十三朝古都，长治久安！&quot;;

    // 省份匹配（简写版）
    if (province === &quot;北京&quot;) return &quot;北京欢迎你~~~&quot;;
    if (province === &quot;天津&quot;) return &quot;讲段相声吧&quot;;
    if (province === &quot;河北&quot;) return &quot;山势巍巍成壁垒，天下雄关&quot;;
    if (province === &quot;山西&quot;) return &quot;展开坐具长三尺，已占山河五百余&quot;;
    if (province === &quot;内蒙古&quot;) return &quot;天苍苍，野茫茫，风吹草低见牛羊&quot;;
    if (province === &quot;辽宁&quot;) return &quot;我想吃烤鸡架！&quot;;
    if (province === &quot;吉林&quot;) return &quot;状元阁就是东北烧烤之王&quot;;
    if (province === &quot;黑龙江&quot;) return &quot;很喜欢哈尔滨大剧院&quot;;
    if (province === &quot;上海&quot;) return &quot;众所周知，中国只有两个城市&quot;;
    if (province === &quot;江苏&quot;) return &quot;散装是必须要散装的&quot;;
    if (province === &quot;浙江&quot;) return &quot;望海楼明照曙霞，闲塘十里尽梅花&quot;;
    if (province === &quot;河南&quot;) return &quot;可否带我品尝河南烩面啦？&quot;;

    return &quot;欢迎来到我的博客！&quot;;
};
// ==============================================================================

// 生成欢迎信息
const generateWelcomeMessage = (region, dist, ipDisplay) =&gt; {
    const location = formatLocation(region);
    const timeGreet = getTimeGreeting();
    const cityGreet = getGreeting(region);
  
    return `
        欢迎来自 &amp;#x3C;b&gt;${location}&amp;#x3C;/b&gt; 的小友💖&amp;#x3C;br&gt;
        你当前距博主约 &amp;#x3C;b&gt;${dist}&amp;#x3C;/b&gt; 公里！&amp;#x3C;br&gt;
        你的IP地址：&amp;#x3C;b class=&quot;ip-address&quot;&gt;${ipDisplay}&amp;#x3C;/b&gt;&amp;#x3C;br&gt;
        ${timeGreet}&amp;#x3C;br&gt;
        Tip：&amp;#x3C;b&gt;${cityGreet}🍂&amp;#x3C;/b&gt;
    `;
};

const showWelcome = (data) =&gt; {
    if (!data || !data.ip) return showErrorMessage();
  
    const welcomeInfo = getWelcomeInfoElement();
    if (!welcomeInfo) return;
  
    const dist = calculateDistance(data.longitude, data.latitude);
    const ipDisplay = formatIpDisplay(data.ip);
  
    welcomeInfo.style.display = &apos;block&apos;;
    welcomeInfo.style.height = &apos;auto&apos;;
    welcomeInfo.innerHTML = generateWelcomeMessage(data.region, dist, ipDisplay);
};

// 从uapis.cn获取IP信息
const fetchIpData = async () =&gt; {
    const response = await fetch(&apos;https://uapis.cn/api/v1/network/myip?source=commercial&apos;);
    if (!response.ok) throw new Error(&apos;API请求失败&apos;);
    const result = await response.json();
    return result;
};

// 获取IP信息主函数
const fetchIpInfo = async () =&gt; {
    showLoadingSpinner();
  
    const cachedData = getIpInfoFromCache();
    if (cachedData) {
        showWelcome(cachedData);
        return;
    }
  
    try {
        const data = await fetchIpData();
        setIpInfoCache(data);
        showWelcome(data);
    } catch (error) {
        console.error(&apos;获取IP信息失败:&apos;, error);
        showErrorMessage(&apos;获取IP信息失败，请重试&apos;);
    }
};

const isHomePage = () =&gt; {
    return window.location.pathname === &apos;/&apos; || window.location.pathname === &apos;/index.html&apos;;
};

// 插入组件
const insertAnnouncementComponent = () =&gt; {
    const announcementCards = document.querySelectorAll(&apos;.card-widget.card-announcement&apos;);
    if (!announcementCards.length) return;
  
    if (IP_CONFIG.HOME_PAGE_ONLY &amp;#x26;&amp;#x26; !isHomePage()) {
        announcementCards.forEach(card =&gt; card.remove());
        return;
    }
  
    if (!document.querySelector(&apos;#welcome-info&apos;)) return;
    fetchIpInfo();
};

document.addEventListener(&apos;DOMContentLoaded&apos;, () =&gt; {
    addStyles();
    insertAnnouncementComponent();
    document.addEventListener(&apos;pjax:complete&apos;, insertAnnouncementComponent);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;:::&lt;/p&gt;
&lt;h2&gt;插入 JS 文件&lt;/h2&gt;
&lt;p&gt;在 &lt;code&gt;_config.anzhiyu.yml&lt;/code&gt; （或其他主题）主题配置文件下 &lt;code&gt;inject&lt;/code&gt; 配置项中的 &lt;code&gt;bottom&lt;/code&gt; 引入 &lt;code&gt;welcome.js&lt;/code&gt;。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;- &amp;#x3C;script src=&quot;/js/welcome.js&quot;&gt;&amp;#x3C;/script&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;{% tip info %}图片内容仅供参考，具体根据实际情况修改。{% endtip %}&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/img/2026/2780309151/1.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;h2&gt;配置内容&lt;/h2&gt;
&lt;p&gt;确认 &lt;code&gt;_config.anzhiyu.yml&lt;/code&gt; （或其他主题）主题配置文件下 &lt;code&gt;aside&lt;/code&gt; 配置项中的 &lt;code&gt;card_announcement&lt;/code&gt; 是否开启，配置参考：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;card_announcement:
  enable: true # 必须开启
  content: ···（省略）
           &amp;#x3C;div id=&quot;welcome-info&quot;&gt;&amp;#x3C;/div&gt; # 必须项
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;/img/2026/2780309151/2.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;{% folding yellow, 注意事项 %}&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;确保API密钥正确填写,正确设置白名单&lt;/li&gt;
&lt;li&gt;经纬度没必要填写详细,为了自身隐私安全&lt;/li&gt;
&lt;li&gt;选择器可以根据你的主题实际情况修改&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;{% endfolding %}&lt;/p&gt;
&lt;h2&gt;常见问题&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Q&lt;/strong&gt;: 为什么显示&quot;无法获取信息&quot;?
&lt;strong&gt;A&lt;/strong&gt;: 可能是 API 炸了，检查配置并重试。实在不行联系我更新文章。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q&lt;/strong&gt;: 距离显示不准确?
&lt;strong&gt;A&lt;/strong&gt;: 正常现象，计算有无法避免的误差，大概就行了。&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>图论之欧拉回路、差分约束——算法笔记</title><link>https://blog.rusin7.com/article/euro-circuit-notes</link><guid isPermaLink="true">https://blog.rusin7.com/article/euro-circuit-notes</guid><description>本文讲述了图论之欧拉回路、差分约束的 C++ 代码，并推荐了比赛和题目以便练习。</description><pubDate>Fri, 03 Apr 2026 21:17:47 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://blog.rusin7.com/img/top_cover/2472048401.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;h1&gt;图论之欧拉回路、差分约束——算法笔记&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;https://vjudge.net/contest/767358&quot;&gt;比赛&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;欧拉回路&lt;/h2&gt;
&lt;p&gt;无向代码1：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void dfs(int x){
	while(f[x]&amp;#x3C;to[x].size()){
		int y=to[x][f[x]].first,idx=to[x][f[x]].second;
		f[x]++;
		if(!vis[idx]){
			vis[idx]=vis[idx^1]=1;
			dfs(y);
			c[++l]=y;
		}
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;无向代码2：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;int x=0,y=0,z=0;
for(int i=1;i&amp;#x3C;=n;++i){
	if(d[i]&amp;#x26;1)x=i,++y;
}
if(y&amp;#x26;&amp;#x26;y!=2){
	cout&amp;#x3C;&amp;#x3C;&quot;Impossible&quot;&amp;#x3C;&amp;#x3C;endl;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;有向&lt;a href=&quot;https://www.luogu.com.cn/problem/P7771&quot;&gt;题目&lt;/a&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int n,m,d[100005],c[100005],f[100005]/*表示遍历到第几个点*/;
vector&amp;#x3C;int&gt;a[100005];
stack&amp;#x3C;int&gt;st;
void dfs(int x){
	int l=0;
	while(f[x]&amp;#x3C;a[x].size()){
		int y=a[x][f[x]];
		f[x]++;
		dfs(y);
		c[++l]=y;
	}
	st.push(x);
}
int main(){
	cin&gt;&gt;n&gt;&gt;m;
	int ind[100005],outd[100005],u,v;
	for(int i=1;i&amp;#x3C;=m;++i){
		cin&gt;&gt;u&gt;&gt;v;
		a[u].push_back(v);
		ind[v]++,outd[u]++;
	}
	for(int i=1;i&amp;#x3C;=n;++i)sort(a[i].begin(),a[i].end());
	int x=1,y=0,z=0;
	for(int i=1;i&amp;#x3C;=n;++i){
		if(ind[i]+1==outd[i])x=i,++y;
		if(ind[i]!=outd[i])++z;
	}
	if(!((y==1&amp;#x26;&amp;#x26;z==2)||!z)){
		cout&amp;#x3C;&amp;#x3C;&quot;No&quot;&amp;#x3C;&amp;#x3C;endl;
		return 0;
	}
	dfs(x);
	while(!st.empty()){
		cout&amp;#x3C;&amp;#x3C;st.top()&amp;#x3C;&amp;#x3C;&quot; &quot;;
		st.pop();
	}
	return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;差分约束&lt;/h2&gt;
&lt;p&gt;Bellman_Ford：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void Bellman_Ford(int n){
	auto relax=[&amp;#x26;](){
		bool f=0;
		for(int i=1;i&amp;#x3C;=n;++i){
			for(auto k:to[i]){
				if(ans[i]&gt;ans[k.first]+k.second){
					ans[i]=min(ans[i],ans[k.first]+k.second),f=1;
				}
			}
		}
		return f;
	};
	for(int i=0;i&amp;#x3C;n-1;++i)relax();
	if(relax())cout&amp;#x3C;&amp;#x3C;&quot;NO&quot;;
	else for(int i=1;i&amp;#x3C;=n;++i)cout&amp;#x3C;&amp;#x3C;ans[i]&amp;#x3C;&amp;#x3C;&quot; &quot;;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;完整&lt;a href=&quot;https://www.luogu.com.cn/problem/P7771&quot;&gt;题目&lt;/a&gt;：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int ans[5005];
vector&amp;#x3C;pair&amp;#x3C;int,int&gt;&gt;to[5005];
void Bellman_Ford(int n){
	auto relax=[&amp;#x26;](){
		bool f=0;
		for(int i=1;i&amp;#x3C;=n;++i){
			for(auto k:to[i]){
				if(ans[i]&gt;ans[k.first]+k.second){
					ans[i]=min(ans[i],ans[k.first]+k.second),f=1;
				}
			}
		}
		return f;
	};
	for(int i=0;i&amp;#x3C;n-1;++i)relax();
	if(relax())cout&amp;#x3C;&amp;#x3C;&quot;NO&quot;;
	else for(int i=1;i&amp;#x3C;=n;++i)cout&amp;#x3C;&amp;#x3C;ans[i]&amp;#x3C;&amp;#x3C;&quot; &quot;;
}
int n,m,c1,c2,y;
int main() {
	cin&gt;&gt;n&gt;&gt;m;
	fill(ans,ans+n+1,0);
	for(int i=1;i&amp;#x3C;=m;++i){
		cin&gt;&gt;c1&gt;&gt;c2&gt;&gt;y;
		to[c1].push_back({c2,y});
	}
	Bellman_Ford(n);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>第22届浙大宁波理工学院程序设计大赛题解</title><link>https://blog.rusin7.com/article/22nd-zhejiang-competition-solution</link><guid isPermaLink="true">https://blog.rusin7.com/article/22nd-zhejiang-competition-solution</guid><description>本文讲述了第22届浙大宁波理工学院程序设计大赛的 C++ 代码。</description><pubDate>Fri, 03 Apr 2026 21:00:28 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://blog.rusin7.com/img/top_cover/74289.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;h2&gt;A. 字符串&lt;/h2&gt;
&lt;p&gt;按照题意模拟即可，如果想要省掉代码量可以开个 &lt;code&gt;std::vector&amp;#x3C;std::pair&amp;#x3C;char, int&gt;&gt; ve(n)&lt;/code&gt; 前一个记录字符，后一个记录当前的下标，直接进行升序排序，然后直接从k+1个开始输出。 提供排序的代码。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void clearlove13(void){
    int n, k;
    std::cin &gt;&gt; n &gt;&gt; k;
    std::string s;
    std::cin &gt;&gt; s;
    std::vector&amp;#x3C;std::pair&amp;#x3C;char, int&gt;&gt; ve(n);
    for (int i = 0; i &amp;#x3C; n; i++) {
        ve[i] = std::make_pair(s[i], i);
    }
    std::sort(ve.begin(), ve.end());
    std::vector&amp;#x3C;std::pair&amp;#x3C;char, int&gt;&gt; ans;
    ans.reserve(n);
    for (int i = k; i &amp;#x3C; n; i++) {
        ans.push_back({ve[i].first, ve[i].second});
    }
    std::sort(ans.begin(), ans.end(), [&amp;#x26;](auto &amp;#x26; a, auto &amp;#x26; b) {
        return a.second &amp;#x3C; b.second;
    });
    for (auto &amp;#x26;[x, y] : ans) {
        std::cout &amp;#x3C;&amp;#x3C; x;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;B. 价格跨度&lt;/h2&gt;
&lt;p&gt;题意大概就是求该 $a_i$ 前面第一个大于该 $a_i$ 的位置，从题目数据可得知，此题我们需要使用 $\mathcal{O(n)}$ 复杂度来写这道题，思考一下可以使用单调栈来实现，只需要等效思想来写即可。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void clearlove13(void)
{
    int n;
    std::cin &gt;&gt; n;
    std::vector&amp;#x3C;int&gt; a(n + 1);
    for (int i = 1; i &amp;#x3C;= n; i++) {
        std::cin &gt;&gt; a[i];
    }
    std::vector&amp;#x3C;int&gt;st;
    std::vector&amp;#x3C;int&gt; ans(n + 1);
    st.reserve(n + 1);
 
    for (int i = 1; i &amp;#x3C;= n; i++) {
        while (!st.empty() &amp;#x26;&amp;#x26; a[st.back()] &amp;#x3C;= a[i]) {
            st.pop_back();
        }
        if (st.empty()) {
            ans[i] = i;
        } else {
            ans[i] = i - st.back();
        }
        st.push_back(i);
    }
 
    for (int i = 1; i &amp;#x3C;= n; i++) {
        std::cout &amp;#x3C;&amp;#x3C; ans[i];
        if (i != n) std::cout &amp;#x3C;&amp;#x3C; &apos; &apos;;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;C. 斐波那契数&lt;/h2&gt;
&lt;p&gt;事实上题目已经告诉你了做法直接模拟即可。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;i64 a[51];
void clearlove13(void)
{
    int n;
    std::cin &gt;&gt; n;
    std::cout &amp;#x3C;&amp;#x3C; a[n] &amp;#x3C;&amp;#x3C; &apos;\n&apos;;
}
int main(void)
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    a[1] = 1;
    a[0] = 1;
    for (int i = 2; i &amp;#x3C;= 50; i++) {
        a[i] = a[i - 1] + a[i - 2];
    }
 
    int cas = 1;
    std::cin &gt;&gt; cas;
    while (cas--) clearlove13();
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;D. 回收礼物&lt;/h2&gt;
&lt;p&gt;设 $f(x\to y)$ 是以 $1$ 为根 ，求x到y的树上最小路径 我们先了解题意，就可以明白是需要求形如 $f(1\to 2)+f(2\to 3)+f(3\to &lt;em&gt;{\dots})+f(&lt;/em&gt;{\dots}\to 2)$ 这么一个式子，那么我们应该怎么快速去求树上最短路径呢？引入lca求最近公共祖先，有一个小trick就是我们 所以我们就先求出到两个点的深度之和再减去公共祖先的深度就可以写出这道题了。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;struct LCA {
    int n, lg;
    std::vector&amp;#x3C;std::vector&amp;#x3C;int&gt;&gt; up;
    std::vector&amp;#x3C;int&gt; depth, tin, tout;
    int timer = 0;
 
    LCA(std::vector&amp;#x3C;std::vector&amp;#x3C;int&gt;&gt;&amp;#x26; ed, int root = 0) {
        n = int(ed.size());
        lg = std::__lg(n) + 1;
        up.assign(n, std::vector&amp;#x3C;int&gt;(lg));
        depth.assign(n, 0);
        tin.resize(n), tout.resize(n);
        auto dfs = [&amp;#x26;](auto self, int u, int p) -&gt; void {
            tin[u] = timer++;
            up[u][0] = p;
            for (int i = 1; i &amp;#x3C; lg; ++i) up[u][i] = up[up[u][i - 1]][i - 1];
            for (int v : ed[u]) {
                if (v == p) continue;
                depth[v] = depth[u] + 1;
                self(self, v, u);
            }
            tout[u] = timer++;
        };
        dfs(dfs, root, root);
    }
 
    bool is_ancestor(int u, int v) {
        return tin[u] &amp;#x3C;= tin[v] &amp;#x26;&amp;#x26; tout[v] &amp;#x3C;= tout[u];
    }
 
    int get_lca(int u, int v) {
        if (is_ancestor(u, v)) return u;
        if (is_ancestor(v, u)) return v;
        for (int i = lg - 1; i &gt;= 0; --i)
            if (!is_ancestor(up[u][i], v)) u = up[u][i];
        return up[u][0];
    }
 
    std::vector&amp;#x3C;int&gt; get_path(int u, int v) {
        int w = get_lca(u, v);
        std::vector&amp;#x3C;int&gt; up_path, down_path;
        while (u != w) {
            up_path.push_back(u);
            u = up[u][0];
        }
        up_path.push_back(w);
        while (v != w) {
            down_path.push_back(v);
            v = up[v][0];
        }
        std::reverse(down_path.begin(), down_path.end());
        up_path.insert(up_path.end(), down_path.begin(), down_path.end());
        return up_path;
    }
};
 
void clearlove13() {
    constexpr int lg = 20;
    int n, q, rt;
    std::cin &gt;&gt; n &gt;&gt; q ;
    rt = 1;
    std::vector&amp;#x3C;std::vector&amp;#x3C;int&gt;&gt; g(n + 1);
    std::vector&amp;#x3C;int&gt;ch(q);
    for (int i = 2; i &amp;#x3C;= n; i++) {
        int u;
        std::cin &gt;&gt; u;
        g[u].push_back(i);
        g[i].push_back(u);
    }
 
    std::vector&amp;#x3C;int&gt; dep(n + 1);
    std::vector&amp;#x3C;std::array&amp;#x3C;int, lg&gt;&gt; up(n + 1);
    for (int i = 1; i &amp;#x3C;= n; i++) {
        std::fill(up[i].begin(), up[i].end(), -1);
    }
 
    auto dfs = [&amp;#x26;](auto self, int u, int fa) -&gt; void {
        up[u][0] = fa;
        for (int i = 1; i &amp;#x3C; lg; i++) {
            if (up[u][i - 1] != -1) {
                up[u][i] = up[up[u][i - 1]][i - 1];
            }
        }
        for (int v : g[u]) {
            if (v != fa) {
                dep[v] = dep[u] + 1;
                self(self, v, u);
            }
        }
    };
 
    dfs(dfs, rt, -1);
 
    auto lca = [&amp;#x26;](i64 u, i64 v) -&gt; int {
        if (dep[u] &amp;#x3C; dep[v]) std::swap(u, v);
        i64 d = dep[u] - dep[v];
        for (int i = 0; i &amp;#x3C; lg; i++) {
            if (d &gt;&gt; i &amp;#x26; 1) u = up[u][i];
        }
        if (u == v) return u;
        for (int i = lg - 1; i &gt;= 0; i--) {
            if (up[u][i] != up[v][i]) {
                u = up[u][i];
                v = up[v][i];
            }
        }
        return up[u][0];
    };
 
    auto dist = [&amp;#x26;](i64 u, i64 v) -&gt; int {
        i64 l = lca(u, v);
        return dep[u] + dep[v] - 2 * dep[l];
    };
 
    for (auto &amp;#x26;i : ch) {
        std::cin &gt;&gt; i;
    }
    i64 ans = dist(1, ch[0]);
    for (int i = 1; i &amp;#x3C; q; i++) {
        ans += dist(ch[i - 1], ch[i]);
    }
    std::cout &amp;#x3C;&amp;#x3C; ans &amp;#x3C;&amp;#x3C; &apos;\n&apos;;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;E. 我们都是小怪兽 (Rescue Qfish)&lt;/h2&gt;
&lt;p&gt;推导公式发现边权每 $4$ 步循环。利用分层图思想，将每个点按时刻拆为 $4$ 层，层间连边，跑 Dijkstra 最短路即可。提供建图的代码。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;for (ll i = 1; i &amp;#x3C;= m; i++) {
    cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
    
    ll w0 = w; //第一层是L
    ll w1 = (w - 1) * quickpow(w + 1, md - 2, md) % md; //第二层是(L-1)/(L+1)
    ll w2 = -quickpow(w, md - 2, md) % md;   //第三层是(-1)/L
    ll w3 = (w + 1) * quickpow((1 - w + md) % md, md - 2, md) % md;//第四层是(L+1)/(1-L) 每四次循环

    if (w1 &amp;#x3C; 0) w1 += md;
    if (w2 &amp;#x3C; 0) w2 += md;
    if (w3 &amp;#x3C; 0) w3 += md;

    g[u].push_back({w0, v + n});
    g[v].push_back({w0, u + n});

    g[u + n].push_back({w1, v + 2 * n});
    g[v + n].push_back({w1, u + 2 * n});

    g[u + 2 * n].push_back({w2, v + 3 * n});
    g[v + 2 * n].push_back({w2, u + 3 * n});

    g[u + 3 * n].push_back({w3, v});
    g[v + 3 * n].push_back({w3, u});
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;F. 爱的魔力转圈圈——终极幸存者挑战赛&lt;/h2&gt;
&lt;p&gt;这是一道约瑟夫环问题，但是数据开小了遍历也能过，递推公式： $\mathcal{f(n, k)=f(n-1, k)+k}$&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include &amp;#x3C;iostream&gt;
using namespace std;

int main() {
    int n;
    long long k;  
    cin &gt;&gt; n &gt;&gt; k;
    
    long long res = 0;  // f(1)=0（1个人时位置为0）
    for (int i = 2; i &amp;#x3C;= n; ++i) {
        res = (res + k) % i;  // 递推计算f(i)
    }
    
    cout &amp;#x3C;&amp;#x3C; res + 1 &amp;#x3C;&amp;#x3C; endl;  // 转换为1-based编号
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;G. 探险者的补给路线&lt;/h2&gt;
&lt;p&gt;直接根据题目意思写就行，$x, y$ 分别是 $a, b$ 的倍数。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void clearlove13(void)
{
    i64 a, b, x, y;
    std::cin &gt;&gt; a &gt;&gt; b &gt;&gt; x &gt;&gt; y;
    if (x % a == 0 &amp;#x26;&amp;#x26; y % b == 0 &amp;#x26;&amp;#x26; x &gt;= 0 &amp;#x26;&amp;#x26; y &gt;= 0) {
        std::cout &amp;#x3C;&amp;#x3C; &quot;YES\n&quot;;
    } else {
        std::cout &amp;#x3C;&amp;#x3C; &quot;NO\n&quot;;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;H. Qfish的法术&lt;/h2&gt;
&lt;p&gt;首先我们根据题意每次加2，可以知道区间和无论怎么操作奇偶性永远不会改变，由此延申我们进行分类讨论，如果区间长度是奇数的话，经过操作后的区间和直接贪心成偶数的目标去，因没有要求对操作后的值有具体要求，所以区间长度是奇数就一定可以，如果区间长度为偶数，但区间和为奇数，每次+2并不会改变奇偶性，所以无解。&lt;/p&gt;
&lt;p&gt;值得注意的是，我们需要对长度为2的区间进行一个简单的特判，区间和直接用前缀和维护就行。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void clearlove13(void)
{
    int n, t;
    std::cin &gt;&gt; n &gt;&gt; t;
    std::vector&amp;#x3C;i64&gt;a(n + 1);
    for (int i = 1; i &amp;#x3C;= n; i++) {
        std::cin &gt;&gt; a[i];
        a[i] += a[i - 1];
    }
    while (t--) {
        int l, r;
        std::cin &gt;&gt; l &gt;&gt; r;
        if (r - l + 1 == 2 &amp;#x26;&amp;#x26; (a[r] != a[l - 1])) {
            std::cout &amp;#x3C;&amp;#x3C; &quot;NO\n&quot;;
            continue;
        }
        if (((r - l + 1LL) % 2 == 0) &amp;#x26;&amp;#x26; ((a[r] - a[l - 1]) % 2 == 1)) {
            std::cout &amp;#x3C;&amp;#x3C; &quot;NO\n&quot;;
        } else {
            std::cout &amp;#x3C;&amp;#x3C; &quot;YES\n&quot;;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;I. 字母混淆&lt;/h2&gt;
&lt;p&gt;直接根据题目来模拟就行。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;void solve(){
    string s;
    int n;
    cin &gt;&gt; n &gt;&gt; s;
    s = &quot; &quot; + s;
    for (int i = 1; i &amp;#x3C;= n; ++i)
        cout &amp;#x3C;&amp;#x3C; (char)((s[i] + 32 - &apos;a&apos; - 2 + 26) % 26 + &apos;a&apos;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;J. 小s的杀戮尖塔&lt;/h2&gt;
&lt;p&gt;超级大模拟， 首先我们可以观察到，观者的血量不会超过1000，并且大鄂虫每行动3轮攻击力就会永久增加，而观者每轮理想情况下只能有15点格挡。所以计算可知游戏轮数一定不会超过60轮。因此可以使用三维 $dp$ 求解。$dp_{i, j, q}$，$i$ 代表第 $i$ 轮，$j$ 代表大鄂虫剩余 $j$ 滴血，$q$ 代表观者处于的姿态。记录的是观者剩余的血量。每次抽取 $5$ 张牌，用 dfs 记录所有会到达的状态。后面就是漫长的调试代码时间，总复杂度是 $\mathcal{O(60\times b \times  3 \times 5)}$。而且题目的伤害与大鄂虫的格挡实际上都是3的倍数，因此可以把伤害与血量 $\div 3$ 进行计算。实际上由于状态数远不会到达最高复杂度，因此代码可以通过。std 的耗时约 $150ms$。 一些容易导致 WA 的细节：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;第一轮的行动 $1$ 与后面轮次的行动 $1$ 不同。后面轮次的行动 $1$ 是有 $9$ 点护甲的，第一轮没有。&lt;/li&gt;
&lt;li&gt;最后 $1$ 轮观者战胜大鄂虫时，游戏立即结算，此时观者不会再受到伤害。&lt;/li&gt;
&lt;li&gt;把费用用完并不是最优解，例如手里是 $5$ 张暴怒，此时可能会选择一张都不打。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;由于出题人的 std 过于臃肿，因此在这里放上能够通过对拍的 AI 代码。&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;typedef long long ll;

ll dp[2][40400][3]; 
ll num[505050];

struct MoveResult {
    ll dmg;        // 造成的伤害
    ll self_blk;   // 获得的格挡
    ll end_stance; // 结束姿态
};
vector&amp;#x3C;MoveResult&gt; moves_cache[3]; // [起始姿态] -&gt; 结果列表

int main(){
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    ll t, a, b, n;
    if(!(cin &gt;&gt; t)) return 0;
    
    while(t--){
        cin &gt;&gt; a &gt;&gt; b &gt;&gt; n;
        for(int i=1; i&amp;#x3C;=n; i++) cin &gt;&gt; num[i];
        
        // 压缩敌方血量
        ll max_b = (b - 1) / 3 + 1;
        
        for(int x=0; x&amp;#x3C;=max_b; x++) 
            for(int s=0; s&amp;#x3C;3; s++) dp[0][x][s] = -1;
            
        vector&amp;#x3C;pair&amp;#x3C;ll, ll&gt;&gt; q; // 队列: {敌方血量, 姿态}
        q.push_back({max_b, 0});
        dp[0][max_b][0] = a;
        
        ll ans = -1;
        ll turn = 0;
        ll gong = 0; // 力量
        
        while(!q.empty() &amp;#x26;&amp;#x26; turn &amp;#x3C; 60) {
            ll cur = turn % 2;
            ll nxt = (turn + 1) % 2;
            turn++;
            
            // 重置下一轮DP状态
            for(int x=0; x&amp;#x3C;=max_b; x++)
                for(int s=0; s&amp;#x3C;3; s++) dp[nxt][x][s] = -1;
            
            // 1. 确定手牌
            vector&amp;#x3C;ll&gt; hand;
            for(int i=0; i&amp;#x3C;5; i++) {
                ll idx = ((turn - 1) * 5 + i) % n + 1;
                hand.push_back(num[idx]);
            }
            sort(hand.begin(), hand.end());
            
            // 2. 预计算所有出牌结果
            for(int s=0; s&amp;#x3C;3; s++) moves_cache[s].clear();
            
            do {
                for(int start_s=0; start_s&amp;#x3C;3; start_s++) {
                    ll c = 3, cur_s = start_s;
                    ll raw_dmg = 0, self_blk = 0;
                    
                    // 记录&quot;一张牌都不出&quot;也是一种可能
                    moves_cache[start_s].push_back({0, 0, start_s});
                    
                    for(ll card : hand) {
                        ll cost = (card &gt;= 4) ? 2 : 1;
                        if(c &amp;#x3C; cost) break;
                        c -= cost;
                        
                        // 伤害计算
                        ll d = 0;
                        if(card == 1) d = 6;
                        else if(card == 3 || card == 4) d = 9;
                        if(cur_s == 1) d *= 2; // 愤怒翻倍
                        raw_dmg += d;
                        
                        // 格挡计算
                        if(card == 2) self_blk += 5;
                        else if(card == 5) self_blk += 8;
                        
                        // 姿态变更
                        ll old_s = cur_s;
                        if(card == 3) cur_s = 0;
                        else if(card == 4) cur_s = 1;
                        else if(card == 5) cur_s = 2;
                        if(old_s == 2 &amp;#x26;&amp;#x26; (card == 3 || card == 4)) c += 2;
                        
                        // 存入结果 (伤害/3, 格挡, 姿态)
                        moves_cache[start_s].push_back({raw_dmg / 3, self_blk, cur_s});
                    }
                }
            } while(next_permutation(hand.begin(), hand.end()));
            
            // 3. 大鄂虫属性计算
            ll chong = (turn - 1) % 3 + 1;
            if(turn &gt; 1 &amp;#x26;&amp;#x26; (turn - 1) % 3 == 0) gong += 5; // 每3回合加一次力量
            
            ll enemy_dmg = 0;
            if(chong == 1) enemy_dmg = 12 + gong;
            else if(chong == 2) enemy_dmg = 7 + gong;
            
            ll enemy_blk_reduce = 0;
            if(turn &gt; 1) {
                ll prev_act = (turn - 2) % 3 + 1;
                if(prev_act == 2) enemy_blk_reduce = 2; // 6/3
                else if(prev_act == 3) enemy_blk_reduce = 3; // 9/3
            }
            
            vector&amp;#x3C;pair&amp;#x3C;ll, ll&gt;&gt; next_q;
            
            // 4. 状态转移
            for(auto &amp;#x26;st : q) {
                ll e_hp = st.first;
                ll p_stance = st.second;
                ll p_hp = dp[cur][e_hp][p_stance];
                
                for(auto &amp;#x26;res : moves_cache[p_stance]) {
                    // 计算实际对敌伤害
                    ll dmg_dealt = max(0LL, res.dmg - enemy_blk_reduce);
                    ll next_e_hp = e_hp - dmg_dealt;
                    
                    // 击杀判定
                    if(next_e_hp &amp;#x3C;= 0) {
                        ans = max(ans, p_hp);
                        continue; // 敌死，不入队
                    }
                    
                    // 玩家承伤计算
                    ll incoming = enemy_dmg;
                    if(res.end_stance == 1) incoming *= 2; // 愤怒易伤
                    ll take = max(0LL, incoming - res.self_blk);
                    ll next_p_hp = p_hp - take;
                    
                    if(next_p_hp &gt; 0) {
                        if(dp[nxt][next_e_hp][res.end_stance] == -1) {
                            next_q.push_back({next_e_hp, res.end_stance});
                            dp[nxt][next_e_hp][res.end_stance] = next_p_hp;
                        } else {
                            dp[nxt][next_e_hp][res.end_stance] = max(dp[nxt][next_e_hp][res.end_stance], next_p_hp);
                        }
                    }
                }
            }
            q = next_q;
        }
        cout &amp;#x3C;&amp;#x3C; ans &amp;#x3C;&amp;#x3C; &quot;\n&quot;;
    }
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>题解：P14702 [ICPC 2024 Tehran R] Boat</title><link>https://blog.rusin7.com/article/p14702-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/p14702-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 题解：P14702 [ICPC 2024 Tehran R] Boat，思路清晰、排版精美</description><pubDate>Fri, 03 Apr 2026 20:38:22 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P14702&quot;&gt;题目传送门&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;贪心，细节较多。&lt;/p&gt;
&lt;h2&gt;思路分析&lt;/h2&gt;
&lt;p&gt;先特判无解情况。&lt;/p&gt;
&lt;p&gt;:::info[提示]{open}&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果某个重量大于最大载重量 $w$，输出 &lt;code&gt;−1&lt;/code&gt;，结束。&lt;/li&gt;
&lt;li&gt;如果最轻的两个人重量之和超过了 $w$，即&lt;strong&gt;无人&lt;/strong&gt;可以当船夫，输出 &lt;code&gt;−1&lt;/code&gt;，结束。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;:::
否则&lt;strong&gt;一定&lt;/strong&gt;有解，尽量让&lt;strong&gt;两人配对上船&lt;/strong&gt;，为了用最少次数，先 sort 从小到大排序，再让最轻的人作为船夫，分为两种情况：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果 $a_i+a_1 \leq w$，可以和最轻的人一起上船，可载两人。这样运送要 $2$ 次，$ans \leftarrow ans+2$。&lt;/li&gt;
&lt;li&gt;否则，不可以和最轻的人一起上船，只载一人。这样运送要 $4$ 次，$ans \leftarrow ans+4$。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;最后船夫不回来，所以输出 $ans-1$。&lt;/p&gt;
&lt;h2&gt;代码&lt;/h2&gt;
&lt;p&gt;按思路写即可，注意细节，这里不放了。&lt;/p&gt;
&lt;h2&gt;结语&lt;/h2&gt;
&lt;p&gt;感谢您的阅读！&lt;/p&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>题解：P14731 [ICPC 2022 Seoul R] Parentheses Tree</title><link>https://blog.rusin7.com/article/p14731-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/p14731-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 P14731 [ICPC 2022 Seoul R] Parentheses Tree，思路清晰、排版精美</description><pubDate>Fri, 03 Apr 2026 20:36:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/P14731&quot; title=&quot;P14731 [ICPC 2022 Seoul R] Parentheses Tree&quot;&gt;题目传送门&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;前置知识&lt;/h2&gt;
&lt;p&gt;STL 中的 stack 容器提供了一众成员函数以供调用，其中较为常用的有：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;定义
&lt;ul&gt;
&lt;li&gt;头文件 $\color{green}\textbf{}$。&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;元素访问
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;st.top()&lt;/code&gt; 返回栈顶。&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;修改
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;st.push()&lt;/code&gt; 插入传入的参数到栈顶。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;st.pop()&lt;/code&gt; 弹出栈顶。&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;容量
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;st.empty()&lt;/code&gt; 返回是否为空。&lt;/li&gt;
&lt;li&gt;&lt;code&gt;st.size()&lt;/code&gt; 返回元素数量。&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;部分内容来自 &lt;a href=&quot;https://oi-wiki.org/ds/stack/&quot; title=&quot;栈 - OI Wiki&quot;&gt;栈 - OI Wiki&lt;/a&gt;。&lt;/p&gt;
&lt;h2&gt;总体分析&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;核心&lt;/strong&gt;：用栈匹配括号并在叶节点累加距离。&lt;/p&gt;
&lt;h2&gt;思路引导&lt;/h2&gt;
&lt;p&gt;:::warning[提问]
如何对左括号进行判断是否为叶节点？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
当 $s_i$ 为 &lt;code&gt;(&lt;/code&gt; 时，如果栈非空，将栈顶替换为 false，再将 true 入栈。
:::&lt;/p&gt;
&lt;p&gt;:::warning[提问]
如何将答案进行累加？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
当 $s_i$ 为 &lt;code&gt;)&lt;/code&gt; 时，如果栈顶 &lt;code&gt;(&lt;/code&gt; 是叶子节点，先累加栈内元素数量，再弹出栈顶。
:::&lt;/p&gt;
&lt;p&gt;:::error[警告]
不开 long long 见祖宗。
:::&lt;/p&gt;
&lt;h2&gt;核心代码&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;cin&gt;&gt;s;
for(char c:s){
	if(c==&apos;(&apos;){
		if(st.size()){
			st.pop();
			st.push(false);
		}//替换操作
		st.push(true);
	}else{
		if(st.top()){
			ans+=st.size()-1;
		}//累加栈内元素数量
		st.pop();//弹出栈顶
	}
}
cout&amp;#x3C;&amp;#x3C;ans;
return 0;
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>我常常追忆过去</title><link>https://blog.rusin7.com/article/remember-the-past</link><guid isPermaLink="true">https://blog.rusin7.com/article/remember-the-past</guid><description>我将背后的时间裁剪、折叠、蜷曲，揉捻成天上朵朵白云。</description><pubDate>Fri, 03 Apr 2026 20:03:24 GMT</pubDate><content:encoded>&lt;p&gt;:::align{center}
居中内容。
:::&lt;/p&gt;
&lt;h2&gt;追忆&lt;/h2&gt;
&lt;p&gt;我常常追忆过去。&lt;/p&gt;
&lt;p&gt;生命瞬间定格在脑海。我将背后的时间裁剪、折叠、蜷曲，揉捻成天上朵朵白云。&lt;/p&gt;
&lt;p&gt;云朵之间亦有分别：积云厚重，而卷云飘渺。生命里震撼的场景掠过我的思绪便一生无法忘怀，而更为普通平常的记忆在时间的冲刷下只留下些许残骸。追忆宛如入梦，太过清楚则无法愉悦自己的幻想，过分模糊却又坠入虚无。只有薄雾间的山水，面纱下的女子，那恰到好处的朦胧，才能满足我对美的苛求。&lt;/p&gt;
&lt;p&gt;追忆总在不经意间将我裹进泛黄的纸页里。分别又重聚的朋友，推倒又重建的街道，种种线索协助着我从一个具体的时刻出发沿时间的河逆流而上。曾经的日子无法重来，我只不过是一个过客。但我仍然渴望在每一次追忆之旅中留下闲暇时间，在一个场景前驻足，在岁月的朦胧里瞭望过去的自己，感受尽可能多的甜蜜。美好的时光曾流过我的身体，我便心满意足。&lt;/p&gt;
&lt;p&gt;过去已经凝固，我带着回忆向前，只是时常疏于保管，回忆也在改变着各自的形态。这给我的追忆旅程带来些许挑战。&lt;/p&gt;
&lt;p&gt;我该在哪里停留？我问我自己。&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item><item><title>题解：P14730 [ICPC 2022 Seoul R] Palindrome Type</title><link>https://blog.rusin7.com/article/p14730-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/p14730-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 P14730 [ICPC 2022 Seoul R] Palindrome Type，思路清晰、排版精美</description><pubDate>Mon, 30 Mar 2026 21:35:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/article/twhfrn73&quot; title=&quot;纯享阅读区&quot;&gt;&lt;strong&gt;纯享阅读区&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;https://www.luogu.com.cn/problem/P14730&quot; title=&quot;P14730 [ICPC 2022 Seoul R] Palindrome Type&quot;&gt;题目传送门&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;总体分析&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;核心&lt;/strong&gt;：修改字符串 $s$ 使其成为回文串，记最小次数为 $k$，如果 $k\leq3$，输出 $k$，否则输出 &lt;code&gt;-1&lt;/code&gt; 。&lt;/p&gt;
&lt;p&gt;因此，可以从 $k=0\sim3$ 依次进行 DFS 搜索，只要有一次成功，输出 $k$，结束。&lt;/p&gt;
&lt;h2&gt;思路引导&lt;/h2&gt;
&lt;p&gt;{% note warning flat %}
&lt;strong&gt;提问&lt;/strong&gt;
如何 DFS &lt;strong&gt;搜索&lt;/strong&gt;修改过程算出 $k$？
{% endnote %}&lt;/p&gt;
&lt;p&gt;{% note success flat %}
&lt;strong&gt;DFS 函数&lt;/strong&gt;
使用 &lt;a href=&quot;https://oi-wiki.org/misc/two-pointer/&quot;&gt;双指针&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;当 $l&amp;#x3C;r$ 时：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;如果左指针 $l$ 和右指针 $r$ 对应的 $s_l=s_r$，那么这部分已经是回文的，$l$ 向右移，$r$ 向左移。&lt;/li&gt;
&lt;li&gt;否则：
&lt;ul&gt;
&lt;li&gt;如果剩余次数 $step=0$，无法继续修改，返回无法完成。&lt;/li&gt;
&lt;li&gt;如果删除 $l+1$ 或 $r+1$ 可完成，返回可以完成。&lt;/li&gt;
&lt;li&gt;否则返回无法完成。&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;返回无法完成。
{% endnote %}&lt;/p&gt;
&lt;p&gt;{% note error flat %}
&lt;strong&gt;警告&lt;/strong&gt;
如果 $k\leq 3$ 都不可以，最后输出 &lt;code&gt;-1&lt;/code&gt; 。
{% endnote %}&lt;/p&gt;
&lt;h2&gt;核心代码&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;bool dfs(int l, int r, int step){

    while(l&amp;#x3C;r){
        if(s[l]==s[r])l++,r--;
        else{
            if(!step)return 0;
            if(dfs(l+1,r,step-1)||dfs(l,r-1,step-1))return 1;
            return 0;
        }
    }
    return 1;

}
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>题解：AT_joi2024_yo1c_b 桁 (Digit)</title><link>https://blog.rusin7.com/article/at-joi2024-yo1c-b-%E6%A1%81-digit-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/at-joi2024-yo1c-b-%E6%A1%81-digit-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 AT_joi2024_yo1c_b 桁 (Digit)，思路清晰、排版精美</description><pubDate>Mon, 30 Mar 2026 19:21:06 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blog.rusin7.com&quot; title=&quot;博客&quot;&gt;&lt;strong&gt;安利一下自己的博客&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/AT_joi2024_yo1c_b&quot; title=&quot;题目传送门&quot;&gt;题目传送门&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;题目大意&lt;/h2&gt;
&lt;p&gt;给出 $a,b$，求 $a+b$ 的位数。&lt;/p&gt;
&lt;h2&gt;思路引导&lt;/h2&gt;
&lt;p&gt;:::warning[提问]
如何统计 $a+b$ 的位数？
:::&lt;/p&gt;
&lt;p&gt;:::success[成功]
我们将 $a+b$ 转化为字符串~~函数大法好~~，输出 $a+b$ 的长度即可。
:::&lt;/p&gt;
&lt;h2&gt;核心代码&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
int a,b;
int main() {
	cin&gt;&gt;a&gt;&gt;b;
	cout&amp;#x3C;&amp;#x3C;to_string(a+b).size();//需使用洛谷IDE中C++14 (GCC 9)及以上版本，蓝C++会CE
	return 0;
}
//By _ruyingsuixing_(UID:1620655)
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>题解：CF2139B Cake Collection</title><link>https://blog.rusin7.com/article/cf2139b-cake-collection-sol</link><guid isPermaLink="true">https://blog.rusin7.com/article/cf2139b-cake-collection-sol</guid><description>本文讲述了如何使用 C++ 完成洛谷的 CF2139B Cake Collection，思路清晰、排版精美</description><pubDate>Mon, 23 Mar 2026 21:33:21 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp&quot; alt=&quot;111&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/problem/CF2139B&quot; title=&quot;CF2139B Cake Collection&quot;&gt;CF2139B Cake Collection&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;https://blog.rusin7.com/&quot; title=&quot;博客 🥳🎆🎉祝大家 2026 新年快乐&quot;&gt;&lt;strong&gt;安利一下&lt;em&gt;博客&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;🥳🎆🎉祝大家 2026 新年快乐！&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.luogu.com.cn/article/odez28v6&quot; title=&quot;纯享阅读区&quot;&gt;纯享阅读区&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;题意分析&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;核心&lt;/strong&gt;：用 $m$ 秒去拿 $n$ 个烤好的蛋糕，要拿的尽量多。用 &lt;a href=&quot;https://oi-wiki.org/basic/greedy/&quot; title=&quot;贪心&quot;&gt;贪心&lt;/a&gt; 算法。&lt;/p&gt;
&lt;h2&gt;思路引导&lt;/h2&gt;
&lt;p&gt;:::warning[提问]
如何保证能选到最好的方案？
:::&lt;/p&gt;
&lt;p&gt;::::success[成功]
对数组 $a$ 从大到小进行排序，如果 $n \le m$，则可以把所有烤箱中的蛋糕都拿一遍，生产蛋糕越多的&lt;strong&gt;越晚拿&lt;/strong&gt;，且后面会给出证明：早拿一次再晚拿一次和直接晚拿一次一样，不如直接晚拿一次简单。否则 $n&gt;m$，就直接拿排序后&lt;strong&gt;最好&lt;/strong&gt;（$a_i$ 较大）的烤箱中的蛋糕，同样，生产蛋糕越多的&lt;strong&gt;越晚拿&lt;/strong&gt;。&lt;/p&gt;
&lt;p&gt;综上，取个 $\min {n,m}$ 即可。
:::info[Tip]{open}
从大到小进行排序不用手写 &lt;code&gt;cmp&lt;/code&gt; 了！使用 &lt;code&gt;greater&amp;#x3C;int&gt;()&lt;/code&gt; 可以直接大到小进行排序。
示例代码：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;sort(a+1,a+n+1,greater&amp;#x3C;int&gt;());//对数组 a 从大到小进行排序
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;:::
::::
:::warning[提问]
如何证明早拿一次再晚拿一次同一个烤箱，和直接晚拿一次一样？
:::
:::success[成功]
&lt;strong&gt;证明&lt;/strong&gt;：&lt;br&gt;
设早拿的时间为 $p_1$，晚拿的时间为 $p_2$，烤箱每秒生成 $a_i$ 个蛋糕，早拿一次再晚拿一次可以拿走 $p_1 \times a_i+(p_2-p_1) \times a_i=p_2 \times a_i$，晚拿一次可以拿走 $p_2 \times a_i$，两式相等，故结论成立。
:::
:::warning[提问]
每拿一次可以获得多少蛋糕？
:::
:::success[成功]
由于生产蛋糕越多的&lt;strong&gt;越晚拿&lt;/strong&gt;，但我们已经从大到小排序了，循环的时间却是从小到大，应该用 $m-i+1$ 才能让下标 $i$ 越小，生产蛋糕 $a_i$ 越多，时间 $m-i+1$ 越大。&lt;/p&gt;
&lt;p&gt;因此得出 $a_i$ 的价值为 $(m-i+1)\times a_i$。
:::
:::error[警告]{open}
不开 &lt;code&gt;long long&lt;/code&gt; 见祖宗，不用 &lt;code&gt;1LL&lt;/code&gt; 乘见祖宗。
:::&lt;/p&gt;
&lt;h2&gt;完整代码&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;#include&amp;#x3C;bits/stdc++.h&gt;
using namespace std;
long long t,n,m,a[200005],s;
int main(){
	cin&gt;&gt;t;
	while(t--){
		s=0;
		cin&gt;&gt;n&gt;&gt;m;
		for(int i=1;i&amp;#x3C;=n;i++)cin&gt;&gt;a[i];
		sort(a+1,a+n+1,greater&amp;#x3C;int&gt;());
		for(int i=1;i&amp;#x3C;=min(n,m);i++)s+=1LL*(m-i+1)*a[i];
		cout&amp;#x3C;&amp;#x3C;s&amp;#x3C;&amp;#x3C;endl;
	}
  return 0;
}
//code by _ruyingsuixing_(UID:1620655)
&lt;/code&gt;&lt;/pre&gt;</content:encoded><h:img src="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/><enclosure url="https://image.rusin7.com/file/hexo/cover/kuKbfhkc.webp"/></item><item><title>免费获取二级域名并部署 github 仓库</title><link>https://blog.rusin7.com/article/free-domain</link><guid isPermaLink="true">https://blog.rusin7.com/article/free-domain</guid><description>本教程介绍了如何免费给博客获取域名，并提供了注册、获取、托管详细步骤及技术支持方式。教程的内容针对新 UI 进行更新，配图丰富。</description><pubDate>Mon, 23 Mar 2026 21:14:10 GMT</pubDate><content:encoded>&lt;h2&gt;前提&lt;/h2&gt;
&lt;p&gt;拥有一个 &lt;a href=&quot;https://github.com&quot;&gt;Github&lt;/a&gt; 的账号和博客仓库。&lt;/p&gt;
&lt;h2&gt;领取域名&lt;/h2&gt;
&lt;h3&gt;注册&lt;/h3&gt;
&lt;h4&gt;Github&lt;/h4&gt;
&lt;p&gt;前往 {% btn &apos;https://github.com/signup&apos;,Github,anzhiyufont anzhiyu-icon-circle-arrow-right,purple larger %} 注册账号。&lt;/p&gt;
&lt;h4&gt;DigitalPlat Domains&lt;/h4&gt;
&lt;p&gt;前往 {% btn &apos;https://dash.domain.digitalplat.org/signup?ref=uGQR48cE9B&apos;,Digitalplat,anzhiyufont anzhiyu-icon-circle-arrow-right,purple larger %}  注册账号，完整人名、电话号码、完整地址等信息不用填写真实的，可以在 &lt;a href=&quot;https://www.meiguodizhi.com/&quot;&gt;美国身份生成器&lt;/a&gt; 生成。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/2.png&quot; alt=&quot;截屏&quot;&gt;
注册完成后会发一封验证到邮箱。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/3.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/4.png&quot; alt=&quot;截屏&quot;&gt;
登录后需要 KYC 验证（使用 Github 账号即可）。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/5.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/6.png&quot; alt=&quot;截屏&quot;&gt;
验证成功后会显示这个页面。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/7.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;h3&gt;获取&lt;/h3&gt;
&lt;p&gt;书接上回，点击左侧 注册。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/8.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;p&gt;{% tip error %}~Digitalplat 于 2026/3/20（文章发布约一周后） 左右更新 UI 和页面交互，文章中获取部分截图为旧版，可能无法对应位置，但操作基本相同。~{% endtip %}
{% tip fa-atom, sync %}UppubDatetime: 本文章已更新至最新。{% endtip %}&lt;/p&gt;
&lt;p&gt;{% link 旧版存档,点击查看旧版,https://life.rusin7.com/post/dpdns-org/ %}&lt;/p&gt;
&lt;p&gt;{% link DigitalPlat Domains 仪表盘,下滑找到我的域名统计-最大允许域名数,https://dash.domain.digitalplat.org/dashboard %}&lt;/p&gt;
&lt;p&gt;下滑找到我的域名统计-最大允许域名数，正常是 $2$ 个，如果你开始没按我的教程注册是 $1$ 个。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/9.png&quot; alt=&quot;截屏&quot;&gt;
{% note info flat %}
每个账户理论上可以注册 $3$ 个免费的 dpdns.org 域名。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;第 $2$ 个需要在注册时， Referral code 填 &lt;code&gt;uGQR48cE9b&lt;/code&gt; 或 &lt;code&gt;QFFXW3uiRm&lt;/code&gt;，如果按前面我的教程一步步注册，可以默认拥有 $2$ 个，再 star 一下获得第 $3$ 个。&lt;/li&gt;
&lt;li&gt;第 $3$ 个需要给他们的 Github 项目 star，点击验证通过后就可以，验证不难。
{% endnote %}&lt;/li&gt;
&lt;li&gt;登录 Github。&lt;/li&gt;
&lt;li&gt;{% btn &apos;https://github.com/DigitalPlatDev/FreeDomain&apos;,访问仓库,anzhiyufont anzhiyu-icon-circle-arrow-right %}。&lt;/li&gt;
&lt;li&gt;点击右上角 ⭐“Star”。&lt;/li&gt;
&lt;li&gt;点击 {% btn &apos;https://dash.domain.digitalplat.org/auth/kyc/github&apos;,这里,anzhiyufont anzhiyu-icon-circle-arrow-right %}。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/10.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/11.png&quot; alt=&quot;截屏&quot;&gt;
https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/sourcehttps://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/12.png&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/12.png&quot; alt=&quot;截屏&quot;&gt;
如果被占用，可以换个域名试试，被占用图片：
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/13.png&quot; alt=&quot;截屏&quot;&gt;
红框中的 *Name Server1，*Name Server2先填 &lt;code&gt;1.com&lt;/code&gt; 和 &lt;code&gt;2.com&lt;/code&gt;，等会儿可以修改。未被占用图片：&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/14.png&quot; alt=&quot;截屏&quot;&gt;
域名注册成功后会显示这个页面。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/15.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;h2&gt;托管到 CF&lt;/h2&gt;
&lt;h3&gt;登录&lt;/h3&gt;
&lt;p&gt;用 Github &lt;a href=&quot;https://dash.cloudflare.com/login&quot;&gt;登录 Cloudflare&lt;/a&gt;。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772802324633.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772802412422.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;h3&gt;添加&lt;/h3&gt;
&lt;p&gt;点击添加站点（Onboard a domain）。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772802648682.png&quot; alt=&quot;截屏&quot;&gt;
选择免费版继续。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772804243558.png&quot; alt=&quot;截屏&quot;&gt;
类型选择 CHAME，名称填写 &lt;code&gt;@&lt;/code&gt; ，目标填写 Github page 地址（username.github.io，将 username 替换为你的 Github 用户名），点击保存（Save）。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772804929713.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772804934072.png&quot; alt=&quot;截屏&quot;&gt;
保存后效果如下图。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772805054433.png&quot; alt=&quot;截屏&quot;&gt;
点击底部蓝色 继续激活 按钮。&lt;/p&gt;
&lt;h3&gt;修改 Name Server&lt;/h3&gt;
&lt;p&gt;回到&lt;a href=&quot;https://dash.domain.digitalplat.org/domains&quot;&gt;注册域名的网站&lt;/a&gt;，点击刚刚的域名，下滑页面，找到原来是 1.com 和 2.com 的 Name server。在 Cloudflare 页面点击 显示名称服务器指令 （ &lt;code&gt;Show nameserver instructions&lt;/code&gt; ） 依次点击 Click to copy 按钮并依次复制到刚刚的域名的 Name server 1 和 Name server 2，修改后继续在注册域名的网站点击 &lt;code&gt;更新名称服务器&lt;/code&gt; （ &lt;code&gt;UppubDatetime nameservers&lt;/code&gt; ），成功后效果如下图。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/16.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;h3&gt;检查&lt;/h3&gt;
&lt;p&gt;回到 Cloudflare，点击 &lt;code&gt;现在就检查名称服务器&lt;/code&gt; （ &lt;code&gt;Check nameservers now&lt;/code&gt; ）。
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772848750931.png&quot; alt=&quot;截屏&quot;&gt;
域名注册商可能需要 $3$ 分钟 $\sim 24$ 小时来处理 Nameserver 的更新，当你的网站在 Cloudflare 上激活后，你会收到一封邮件通知。
你也可以保留 Cloudflare 页面，当显示如下两图时，说明检查成功了。&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772851053998.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772851718121.png&quot; alt=&quot;截屏&quot;&gt;
&lt;img src=&quot;https://jsd.liiiu.cn/gh/ruying-suixing/blog/themes/hexo-theme-anzhiyu-1.7.1/source/img/2026/46209/1772851759034.png&quot; alt=&quot;截屏&quot;&gt;&lt;/p&gt;
&lt;h2&gt;结语&lt;/h2&gt;
&lt;p&gt;可以愉快地享用Cloudflare的服务了！
祝大家打造出品牌化的个人博客，为平凡的生活添彩！&lt;/p&gt;</content:encoded><h:img src="undefined"/><enclosure url="undefined"/></item></channel></rss>