<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>皓子的杂站</title>
        <link>https://howiehz.top/misc/</link>
        <description>放不进主站的内容都在这里。</description>
        <lastBuildDate>Wed, 13 May 2026 10:09:38 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-Hans</language>
        <copyright>版权所有 © 2023-至今 HowieHz</copyright>
        <atom:link href="https://howiehz.top/misc/rss.zh-hans.xml" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[docs]]></title>
            <link>https://howiehz.top/misc/CHANGELOG</link>
            <guid isPermaLink="false">https://howiehz.top/misc/CHANGELOG</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[1.0.9
 Patch Changes
- Updated dependencies [`2724af5`]:
  - compat-finder@2.1.0
 1.0.8
 Patch Chang]]></description>
            <content:encoded><![CDATA[<h1 id="docs" tabindex="-1">docs <a class="header-anchor" href="#docs" aria-label="Permalink to “docs”">&#8203;</a></h1>
<h2 id="_1-0-9" tabindex="-1">1.0.9 <a class="header-anchor" href="#_1-0-9" aria-label="Permalink to “1.0.9”">&#8203;</a></h2>
<h3 id="patch-changes" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/2724af508537f6d3dce91d0fe12e768817385e3a" target="_blank" rel="noreferrer"><code>2724af5</code></a>]:
<ul>
<li>compat-finder@2.1.0</li>
</ul>
</li>
</ul>
<h2 id="_1-0-8" tabindex="-1">1.0.8 <a class="header-anchor" href="#_1-0-8" aria-label="Permalink to “1.0.8”">&#8203;</a></h2>
<h3 id="patch-changes-1" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-1" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/6628bf01ca5eb6a00d5bb83c8ad6deb33c21a983" target="_blank" rel="noreferrer"><code>6628bf0</code></a>]:
<ul>
<li>compat-finder@2.0.1</li>
</ul>
</li>
</ul>
<h2 id="_1-0-7" tabindex="-1">1.0.7 <a class="header-anchor" href="#_1-0-7" aria-label="Permalink to “1.0.7”">&#8203;</a></h2>
<h3 id="patch-changes-2" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-2" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/11d4f0b6fe91736567c22cc906a0c829bf4cbe5d" target="_blank" rel="noreferrer"><code>11d4f0b</code></a>, <a href="https://github.com/HowieHz/howiehz-misc/commit/11d4f0b6fe91736567c22cc906a0c829bf4cbe5d" target="_blank" rel="noreferrer"><code>11d4f0b</code></a>]:
<ul>
<li>compat-finder@2.0.0</li>
</ul>
</li>
</ul>
<h2 id="_1-0-6" tabindex="-1">1.0.6 <a class="header-anchor" href="#_1-0-6" aria-label="Permalink to “1.0.6”">&#8203;</a></h2>
<h3 id="patch-changes-3" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-3" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/3d0149739035bd8e8424615b3be7f72e44dd925f" target="_blank" rel="noreferrer"><code>3d01497</code></a>, <a href="https://github.com/HowieHz/howiehz-misc/commit/3d0149739035bd8e8424615b3be7f72e44dd925f" target="_blank" rel="noreferrer"><code>3d01497</code></a>]:
<ul>
<li>compat-finder@1.3.0</li>
</ul>
</li>
</ul>
<h2 id="_1-0-5" tabindex="-1">1.0.5 <a class="header-anchor" href="#_1-0-5" aria-label="Permalink to “1.0.5”">&#8203;</a></h2>
<h3 id="patch-changes-4" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-4" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/625f51e4ba829f8a8698662e6dc4e167164b0c74" target="_blank" rel="noreferrer"><code>625f51e</code></a>]:
<ul>
<li>compat-finder@1.2.0</li>
</ul>
</li>
</ul>
<h2 id="_1-0-4" tabindex="-1">1.0.4 <a class="header-anchor" href="#_1-0-4" aria-label="Permalink to “1.0.4”">&#8203;</a></h2>
<h3 id="patch-changes-5" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-5" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/640710dd5ed892abfbb798cb422a1ca4646979ed" target="_blank" rel="noreferrer"><code>640710d</code></a>, <a href="https://github.com/HowieHz/howiehz-misc/commit/605294bf8db9f7b372616b92165f86e70ca491e8" target="_blank" rel="noreferrer"><code>605294b</code></a>, <a href="https://github.com/HowieHz/howiehz-misc/commit/640710dd5ed892abfbb798cb422a1ca4646979ed" target="_blank" rel="noreferrer"><code>640710d</code></a>]:
<ul>
<li>compat-finder@1.1.1</li>
</ul>
</li>
</ul>
<h2 id="_1-0-3" tabindex="-1">1.0.3 <a class="header-anchor" href="#_1-0-3" aria-label="Permalink to “1.0.3”">&#8203;</a></h2>
<h3 id="patch-changes-6" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-6" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/2806bef2fc947ba6d3febb8e82de6a7e0f9288be" target="_blank" rel="noreferrer"><code>2806bef</code></a>]:
<ul>
<li>compat-finder@1.1.0</li>
</ul>
</li>
</ul>
<h2 id="_1-0-2" tabindex="-1">1.0.2 <a class="header-anchor" href="#_1-0-2" aria-label="Permalink to “1.0.2”">&#8203;</a></h2>
<h3 id="patch-changes-7" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-7" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/149d6d5fa3cfaf2aa398a20a25c75830125c1eee" target="_blank" rel="noreferrer"><code>149d6d5</code></a>]:
<ul>
<li>compat-finder@1.0.1</li>
</ul>
</li>
</ul>
<h2 id="_1-0-1" tabindex="-1">1.0.1 <a class="header-anchor" href="#_1-0-1" aria-label="Permalink to “1.0.1”">&#8203;</a></h2>
<h3 id="patch-changes-8" tabindex="-1">Patch Changes <a class="header-anchor" href="#patch-changes-8" aria-label="Permalink to “Patch Changes”">&#8203;</a></h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/HowieHz/howiehz-misc/commit/067a2f852186c63e9a34811e973a263b60fe53ea" target="_blank" rel="noreferrer"><code>067a2f8</code></a>]:
<ul>
<li>compat-finder@1.0.0</li>
</ul>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[与 AI 协作]]></title>
            <link>https://howiehz.top/misc/compat-finder/ai</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/ai</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[如果你想让 AI 帮你推进 `compat-finder` 的排查或集成流程，可以为你的 AI 智能体安装 `compat-finder` 智能体技能（Agent Skill）。
安装后，AI 会更清]]></description>
            <content:encoded><![CDATA[<h1 id="与-ai-协作" tabindex="-1">与 AI 协作 <a class="header-anchor" href="#与-ai-协作" aria-label="Permalink to “与 AI 协作”">&#8203;</a></h1>
<p>如果你想让 AI 帮你推进 <code>compat-finder</code> 的排查或集成流程，可以为你的 AI 智能体安装 <code>compat-finder</code> <a href="https://agentskills.io/" target="_blank" rel="noreferrer">智能体技能（Agent Skill）</a>。</p>
<p>安装后，AI 会更清楚 <code>compat-finder</code> 的 CLI 用法、库 API 和常见排查流程。</p>
<h2 id="ai-能帮你做什么" tabindex="-1">AI 能帮你做什么 <a class="header-anchor" href="#ai-能帮你做什么" aria-label="Permalink to “AI 能帮你做什么”">&#8203;</a></h2>
<ul>
<li>根据你的目标列表和测试结果，持续推进兼容性排查</li>
<li>帮你判断更适合先用 CLI，还是把 <code>compat-finder</code> 集成进自己的项目</li>
<li>帮你写或调整 <code>compat-finder</code> 的 CLI 命令</li>
<li>帮你把 <code>compat-finder</code> 接进自己的应用、脚本或自定义 UI</li>
<li>帮你设计会话保存、恢复和持久化方案</li>
</ul>
<h2 id="安装" tabindex="-1">安装 <a class="header-anchor" href="#安装" aria-label="Permalink to “安装”">&#8203;</a></h2>
<p>为你的 AI 智能体安装 <code>compat-finder</code> 智能体技能：</p>
<div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre><!--::markdown-it-async::j4l1b1b897kfw9ilmiwbc::--><code>npx skills add HowieHz/howiehz-misc --skill compat-finder</code></pre>
</div><p>智能体技能源码位于 <a href="https://github.com/HowieHz/howiehz-misc/tree/main/packages/compat-finder/skills/compat-finder" target="_blank" rel="noreferrer">skills/compat-finder</a>。</p>
<h2 id="怎么提问更有效" tabindex="-1">怎么提问更有效 <a class="header-anchor" href="#怎么提问更有效" aria-label="Permalink to “怎么提问更有效”">&#8203;</a></h2>
<p>如果你希望 AI 更快给出可执行的建议，尽量在提示里说明：</p>
<ul>
<li>你的目标列表，例如插件、mods、版本、功能开关或配置项</li>
<li>你怎么判断一次测试是“有兼容性问题”还是“没有兼容性问题”</li>
<li>你已经做过哪些测试，以及每一步的结果</li>
<li>你是想直接用 CLI，还是接入自己的应用或脚本</li>
</ul>
<h2 id="示例提示词" tabindex="-1">示例提示词 <a class="header-anchor" href="#示例提示词" aria-label="Permalink to “示例提示词”">&#8203;</a></h2>
<p>安装后，你可以让 AI 帮你处理这类任务：</p>
<div class="language-text"><button title="Copy Code" class="copy"></button><span class="lang">text</span><pre><!--::markdown-it-async::jrsw6g3atndpxca6s0xn8::--><code>我需要排查插件 1、插件 2、插件 3、插件 4 的兼容性问题。你告诉我下一步测什么，我把结果给你，你继续帮我缩小范围。</code></pre>
</div><div class="language-text"><button title="Copy Code" class="copy"></button><span class="lang">text</span><pre><!--::markdown-it-async::tc3uzn4mizorub4wvly4::--><code>用 compat-finder 扫一遍我游戏 mods 文件夹，直接找出哪些插件会导致游戏启动不了。</code></pre>
</div><div class="language-text"><button title="Copy Code" class="copy"></button><span class="lang">text</span><pre><!--::markdown-it-async::kzzlceco7zah9hjx5fjsx6::--><code>帮我把 compat-finder 接进我的软件，做一个让用户自己排查插件冲突的功能。</code></pre>
</div><div class="language-text"><button title="Copy Code" class="copy"></button><span class="lang">text</span><pre><!--::markdown-it-async::aiesgnxt76hunj1o34jyv::--><code>我的 compat-finder UI 需要把排查会话保存下来，并且在刷新页面后继续。应该用哪个 API，需要持久化哪些状态？</code></pre>
</div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[算法性能]]></title>
            <link>https://howiehz.top/misc/compat-finder/algorithm-performance</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/algorithm-performance</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[# 算法性能

`compat-finder` 目前内置两种算法：`binary-split` 和 `leave-one-out`。

这里的“性能”主要指排查过程中需要多少测试轮次。

## **太长不看**

- `leave-one-out` 在绝大多数情况下的询问次数都是 `n`；只有当最终结果覆盖全部目标时，会变成 `n + 1`。
- `binary-split` 的询问次数会随着最终结果的数量和分布位置变化，通常介于 `max(1, ceil(log2(n)))` 到 `2n - 1` 之间。

| 观察维度     | 条件                                          | 更占优的算法    |
| ]]></description>
            <content:encoded><![CDATA[<h1 id="算法性能" tabindex="-1">算法性能 <a class="header-anchor" href="#算法性能" aria-label="Permalink to “算法性能”">&#8203;</a></h1>
<p><code>compat-finder</code> 目前内置两种算法：<code>binary-split</code> 和 <code>leave-one-out</code>。</p>
<p>这里的“性能”主要指排查过程中需要多少测试轮次。</p>
<h2 id="太长不看" tabindex="-1"><strong>太长不看</strong> <a class="header-anchor" href="#太长不看" aria-label="Permalink to “太长不看”">&#8203;</a></h2>
<ul>
<li><code>leave-one-out</code> 在绝大多数情况下的询问次数都是 <code>n</code>；只有当最终结果覆盖全部目标时，会变成 <code>n + 1</code>。</li>
<li><code>binary-split</code> 的询问次数会随着最终结果的数量和分布位置变化，通常介于 <code>max(1, ceil(log2(n)))</code> 到 <code>2n - 1</code> 之间。</li>
</ul>
<table tabindex="0">
<thead>
<tr>
<th>观察维度</th>
<th>条件</th>
<th>更占优的算法</th>
</tr>
</thead>
<tbody>
<tr>
<td>平均询问次数</td>
<td>最终不兼容目标约占总目标数 <code>22.84%</code> 到 <code>100%</code></td>
<td><code>leave-one-out</code></td>
</tr>
<tr>
<td>平均询问次数</td>
<td>最终不兼容目标占比低于 <code>22.83%</code></td>
<td><code>binary-split</code></td>
</tr>
</tbody>
</table>
<p>分界点大约在 <code>13.77%</code> 左右；再往下，在大多数情况下，<code>binary-split</code> 的最坏情况也优于 <code>leave-one-out</code>。</p>
<p><strong>结论：</strong><code>binary-split</code> 仍然作为默认算法，因为真实排查里，更常见的是“有问题的占少数”。</p>
<h2 id="怎么选" tabindex="-1">怎么选 <a class="header-anchor" href="#怎么选" aria-label="Permalink to “怎么选”">&#8203;</a></h2>
<ul>
<li>你怀疑最终只会找到少数几个不兼容目标：优先用 <code>binary-split</code></li>
<li>你怀疑会找到很多不兼容目标：可以考虑 <code>leave-one-out</code></li>
<li>你不确定：先用默认的 <code>binary-split</code></li>
<li>你想看 CLI 或 API 里怎么切换算法：继续阅读 <a href="./cli#算法">命令行工具</a> 和 <a href="./api#算法选择">API 参考</a></li>
</ul>
<h2 id="整体趋势" tabindex="-1">整体趋势 <a class="header-anchor" href="#整体趋势" aria-label="Permalink to “整体趋势”">&#8203;</a></h2>
<p>下图汇总了所有非空结果集的整体表现。</p>
<p><img src="/compat-finder/overall-non-empty-subsets.svg" alt="所有非空结果集的整体轮次对比" loading="lazy"></p>
<h2 id="当最终只会找到-1-个目标时" tabindex="-1">当最终只会找到 1 个目标时 <a class="header-anchor" href="#当最终只会找到-1-个目标时" aria-label="Permalink to “当最终只会找到 1 个目标时”">&#8203;</a></h2>
<p>单目标场景是 <code>binary-split</code> 最明显占优的情况之一。</p>
<p><img src="/compat-finder/pick-1.svg" alt="最终结果只包含 1 个目标时的轮次对比" loading="lazy"></p>
<h2 id="结果很少时" tabindex="-1">结果很少时 <a class="header-anchor" href="#结果很少时" aria-label="Permalink to “结果很少时”">&#8203;</a></h2>
<p>当最终不兼容目标只占总目标数的 <code>12.5%</code> 时，<code>binary-split</code> 的优势很明显。</p>
<p><img src="/compat-finder/pick-eighth.svg" alt="最终结果占总目标数 12.5% 时的轮次对比" loading="lazy"></p>
<h2 id="最坏情况的分界附近" tabindex="-1">最坏情况的分界附近 <a class="header-anchor" href="#最坏情况的分界附近" aria-label="Permalink to “最坏情况的分界附近”">&#8203;</a></h2>
<p>当最终不兼容目标占比接近 <code>13.77%</code> 时，两种算法在最坏情况上的差距开始变得接近。</p>
<p><img src="/compat-finder/pick-13-77-percent.svg" alt="最终结果占总目标数约 13.77% 时的轮次对比" loading="lazy"></p>
<h2 id="平均轮次的分界附近" tabindex="-1">平均轮次的分界附近 <a class="header-anchor" href="#平均轮次的分界附近" aria-label="Permalink to “平均轮次的分界附近”">&#8203;</a></h2>
<p>当最终不兼容目标占比接近 <code>22.83%</code> 时，两种算法在平均轮次上的优劣开始反转。</p>
<p><img src="/compat-finder/pick-22-83-percent.svg" alt="最终结果占总目标数约 22.83% 时的轮次对比" loading="lazy"></p>
<h2 id="当不兼容目标很多时" tabindex="-1">当不兼容目标很多时 <a class="header-anchor" href="#当不兼容目标很多时" aria-label="Permalink to “当不兼容目标很多时”">&#8203;</a></h2>
<p>当最终结果接近“全部目标都有问题”时，<code>leave-one-out</code> 的轮次更稳定，也往往更少。</p>
<p><img src="/compat-finder/pick-all.svg" alt="最终结果覆盖全部目标时的轮次对比" loading="lazy"></p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API 参考]]></title>
            <link>https://howiehz.top/misc/compat-finder/api</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/api</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[多数集成场景都应该优先使用简单会话 API。
 简单会话 API
- `createCompatibilitySession&lt;Target
 返回对象：`CompatibilitySession]]></description>
            <content:encoded><![CDATA[<h1 id="api-参考" tabindex="-1">API 参考 <a class="header-anchor" href="#api-参考" aria-label="Permalink to “API 参考”">&#8203;</a></h1>
<p>多数集成场景都应该优先使用<a href="#简单会话-api">简单会话 API</a>。</p>
<h2 id="简单会话-api" tabindex="-1">简单会话 API <a class="header-anchor" href="#简单会话-api" aria-label="Permalink to “简单会话 API”">&#8203;</a></h2>
<ul>
<li><code>createCompatibilitySession&lt;Target&gt;(targets: readonly Target[], options?: CompatibilityTestOptions): CompatibilitySession&lt;Target&gt;</code>：根据目标列表创建兼容性排查会话</li>
</ul>
<h3 id="返回对象-compatibilitysession-target" tabindex="-1">返回对象：<code>CompatibilitySession&lt;Target&gt;</code> <a class="header-anchor" href="#返回对象-compatibilitysession-target" aria-label="Permalink to “返回对象：CompatibilitySession&lt;Target&gt;”">&#8203;</a></h3>
<ul>
<li><code>current(): CompatibilitySessionStep&lt;Target&gt;</code>：读取当前步骤或最终结果</li>
<li><code>answer(hasIssue: boolean): CompatibilitySessionStep&lt;Target&gt;</code>：提交一次测试结果，并进入下一步</li>
<li><code>undo(): CompatibilitySessionStep&lt;Target&gt;</code>：撤销最新一次测试结果，并回到上一步</li>
</ul>
<h3 id="current-answer-undo-返回值" tabindex="-1"><code>current()</code> / <code>answer()</code> / <code>undo()</code> 返回值 <a class="header-anchor" href="#current-answer-undo-返回值" aria-label="Permalink to “current() / answer() / undo() 返回值”">&#8203;</a></h3>
<p>形如：</p>
<div class="language-js"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre><!--::markdown-it-async::p4sl2gvdskbap5lw5vp0jn::--><code>// status === &quot;testing&quot;
{
  status: &quot;testing&quot;,
  targets: [&quot;B&quot;, &quot;C&quot;],
  targetNumbers: [2, 3],
}

// status === &quot;complete&quot;
{
  status: &quot;complete&quot;,
  targets: [&quot;C&quot;],
  targetNumbers: [3],
}</code></pre>
</div><ul>
<li>当 <code>status: &quot;testing&quot;</code>：<br>
<code>targets</code> 是本轮需要测试的目标值列表<br>
<code>targetNumbers</code> 是这些目标在原始 <code>targets</code> 输入列表中的 1-based 编号</li>
<li>当 <code>status: &quot;complete&quot;</code>：<br>
<code>targets</code> 是最终排查出的不兼容目标值列表<br>
<code>targetNumbers</code> 是这些目标在原始 <code>targets</code> 输入列表中的 1-based 编号</li>
</ul>
<h3 id="调用约定" tabindex="-1">调用约定 <a class="header-anchor" href="#调用约定" aria-label="Permalink to “调用约定”">&#8203;</a></h3>
<ul>
<li><code>answer(true)</code>：表示当前这组目标会复现问题</li>
<li><code>answer(false)</code>：表示当前这组目标不会复现问题</li>
<li><code>undo()</code>：撤销最新一次测试结果</li>
<li><code>createCompatibilitySession(targets)</code>：<code>targets</code> 列表至少包含 1 个元素</li>
</ul>
<h3 id="算法选择" tabindex="-1">算法选择 <a class="header-anchor" href="#算法选择" aria-label="Permalink to “算法选择”">&#8203;</a></h3>
<p>只有在你想切换排查策略时，才需要传入 <code>algorithm</code>。</p>
<ul>
<li>不传 <code>algorithm</code>：使用默认算法 <code>binary-split</code></li>
<li>传入 <code>algorithm: &quot;leave-one-out&quot;</code>：改用每轮排除 1 个目标的方式</li>
<li>默认用法：<code>createCompatibilitySession(targets)</code></li>
<li>切换示例：<code>createCompatibilitySession(targets, { algorithm: &quot;leave-one-out&quot; })</code></li>
</ul>
<p>想了解更多关于这两个算法的区别，请阅读 <a href="./algorithm-performance">算法性能</a>。</p>
<h2 id="高级-api" tabindex="-1">高级 API <a class="header-anchor" href="#高级-api" aria-label="Permalink to “高级 API”">&#8203;</a></h2>
<p>底层 API 暴露了基于范围的可变状态机，适合自定义 UI、持久化和诊断场景。</p>
<p>如果你只需要一个可直接驱动交互流程的封装，通常不必从这一层开始。</p>
<h3 id="状态工厂" tabindex="-1">状态工厂 <a class="header-anchor" href="#状态工厂" aria-label="Permalink to “状态工厂”">&#8203;</a></h3>
<ul>
<li><code>createCompatibilityTestState(targetCount: number, options?: CompatibilityTestOptions): CompatibilityTestState</code>：创建新的排查状态</li>
</ul>
<h3 id="状态对象-compatibilityteststate" tabindex="-1">状态对象：<code>CompatibilityTestState</code> <a class="header-anchor" href="#状态对象-compatibilityteststate" aria-label="Permalink to “状态对象：CompatibilityTestState”">&#8203;</a></h3>
<ul>
<li>这是一个可变状态对象，下面几个底层函数都会直接读取或修改它</li>
</ul>
<h3 id="状态操作" tabindex="-1">状态操作 <a class="header-anchor" href="#状态操作" aria-label="Permalink to “状态操作”">&#8203;</a></h3>
<ul>
<li><code>getNextAnswerableCompatibilityTestStep(state: CompatibilityTestState): CompatibilityTestStep | undefined</code>：读取下一个真正需要回答的步骤，并自动跳过缓存步骤</li>
<li><code>getCurrentCompatibilityTestStep(state: CompatibilityTestState): CompatibilityTestStep | undefined</code>：读取当前步骤；排查结束时返回 <code>undefined</code></li>
<li><code>applyCompatibilityTestAnswer(state: CompatibilityTestState, hasIssue: boolean): CompatibilityTestStep | undefined</code>：提交一个测试结果并推进状态</li>
<li><code>skipCachedCompatibilityTestSteps(state: CompatibilityTestState): CompatibilityTestStep | undefined</code>：跳过已经命中的缓存步骤</li>
</ul>
<h3 id="步骤返回值-compatibilityteststep" tabindex="-1">步骤返回值：<code>CompatibilityTestStep</code> <a class="header-anchor" href="#步骤返回值-compatibilityteststep" aria-label="Permalink to “步骤返回值：CompatibilityTestStep”">&#8203;</a></h3>
<ul>
<li><code>promptTargetRanges</code>：当前这一步要测试的目标范围列表</li>
<li><code>promptTargetCount</code>：当前这一步覆盖的目标数量</li>
<li><code>debug</code>：内部搜索状态，适合调试或自定义 UI</li>
<li><code>requiresAnswer</code>：是否需要调用方在这一步提供新的测试结果</li>
</ul>
<p>形如：</p>
<div class="language-js"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre><!--::markdown-it-async::61nb3v45sivx2fzezvtwas::--><code>{
  promptTargetRanges: [{ start: 2, end: 3 }],
  promptTargetCount: 2,
  debug: {
    activeTargetRange: { start: 1, end: 4 },
    pendingTargetRanges: [],
    confirmedTargetRanges: [],
  },
  requiresAnswer: true,
}</code></pre>
</div><h3 id="调用约定-1" tabindex="-1">调用约定 <a class="header-anchor" href="#调用约定-1" aria-label="Permalink to “调用约定”">&#8203;</a></h3>
<ul>
<li><code>createCompatibilityTestState(targetCount)</code>：<code>targetCount</code> 必须是大于等于 <code>1</code> 的整数</li>
<li><code>applyCompatibilityTestAnswer(state, true)</code>：表示当前这一步会复现问题</li>
<li><code>applyCompatibilityTestAnswer(state, false)</code>：表示当前这一步不会复现问题</li>
<li>这些底层函数会直接修改同一个 <code>state</code> 对象</li>
<li>返回 <code>undefined</code>：表示排查已经结束</li>
</ul>
<h3 id="范围工具" tabindex="-1">范围工具 <a class="header-anchor" href="#范围工具" aria-label="Permalink to “范围工具”">&#8203;</a></h3>
<ul>
<li><code>takeTargetsFromRanges(ranges: readonly TargetRange[], limit: number): number[]</code>：把范围展开成目标编号列表</li>
<li><code>countTargetsInRanges(ranges: readonly TargetRange[]): number</code>：统计范围内包含的目标数量</li>
<li><code>intersectTargetRanges(leftRanges: readonly TargetRange[], rightRanges: readonly TargetRange[]): TargetRange[]</code>：求两个范围列表的交集</li>
<li><code>subtractTargetRanges(sourceRanges: readonly TargetRange[], excludedRanges: readonly TargetRange[]): TargetRange[]</code>：从一个范围列表中剔除另一个范围列表</li>
</ul>
<h3 id="核心类型" tabindex="-1">核心类型 <a class="header-anchor" href="#核心类型" aria-label="Permalink to “核心类型”">&#8203;</a></h3>
<ul>
<li><code>CompatibilityTestState</code>：可变的排查会话状态</li>
<li><code>CompatibilityTestStep</code>：当前要展示给调用方的步骤</li>
<li><code>CompatibilityTestDebugStep</code>：以范围形式表示的内部搜索状态</li>
<li><code>CompatibilityTestAlgorithm</code>：内置算法名称</li>
<li><code>CompatibilityTestOptions</code>：会话和状态创建共用的选项对象</li>
<li><code>TargetRange</code>：闭区间目标编号范围</li>
</ul>
<p>参数细节和行为约束，请直接参考 <a href="https://github.com/HowieHz/howiehz-misc/tree/main/packages/compat-finder/src/compatibility-test" target="_blank" rel="noreferrer">src/compatibility-test</a> 下的内联 JSDoc 注释。</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[命令行工具]]></title>
            <link>https://howiehz.top/misc/compat-finder/cli</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/cli</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[`compat-finder` 提供两个 CLI 子命令：`interactive` 用于引导式排查，`next` 用于根据已有回答做单步推导。
 帮助
```sh
compat-finder --h]]></description>
            <content:encoded><![CDATA[<h1 id="命令行工具" tabindex="-1">命令行工具 <a class="header-anchor" href="#命令行工具" aria-label="Permalink to “命令行工具”">&#8203;</a></h1>
<p><code>compat-finder</code> 提供两个 CLI 子命令：<code>interactive</code> 用于引导式排查，<code>next</code> 用于根据已有回答做单步推导。</p>
<h2 id="帮助" tabindex="-1">帮助 <a class="header-anchor" href="#帮助" aria-label="Permalink to “帮助”">&#8203;</a></h2>
<div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::guk1ka90snjnwmdugh22::--><code>compat-finder --help</code></pre>
</div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::u6hidq68g8ikgtmzu6jhub::--><code>compat-finder --help interactive</code></pre>
</div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::ljnldcuvwypyr4h04k2db::--><code>compat-finder --help next</code></pre>
</div><h2 id="子命令" tabindex="-1">子命令 <a class="header-anchor" href="#子命令" aria-label="Permalink to “子命令”">&#8203;</a></h2>
<h3 id="interactive" tabindex="-1"><code>interactive</code> <a class="header-anchor" href="#interactive" aria-label="Permalink to “interactive”">&#8203;</a></h3>
<p>启动一轮完整的交互式排查流程：</p>
<div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::zww9rz31tfm8bhy84np4i3::--><code>compat-finder interactive --count 4</code></pre>
</div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::pfl712wzmuinki746im8q::--><code>compat-finder i -c 4 -n &quot;A,B,C,D&quot;</code></pre>
</div><p>支持以下输入：</p>
<ul>
<li><code>y</code> / <code>yes</code> / <code>issue</code> / <code>1</code> / <code>true</code>：表示“有兼容性问题”</li>
<li><code>n</code> / <code>no</code> / <code>pass</code> / <code>0</code> / <code>false</code>：表示“没有兼容性问题”</li>
<li><code>u</code> / <code>undo</code>：撤回上一步</li>
<li><code>q</code> / <code>quit</code>：退出</li>
</ul>
<h3 id="next" tabindex="-1"><code>next</code> <a class="header-anchor" href="#next" aria-label="Permalink to “next”">&#8203;</a></h3>
<p>根据已有回答，计算下一步应测试的目标，或直接返回最终结果：</p>
<div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::jiq6bdosrfgru65olzcd5k::--><code>compat-finder next -c 3</code></pre>
</div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::s49vkrvg5crk3nub2xadt::--><code>compat-finder n -c 3 -a &quot;y,n&quot;</code></pre>
</div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::0svzabq2viscjh6pqud6lj::--><code>compat-finder next -c 4 -a &quot;issue,pass,1,0&quot; -n &quot;A,B,C,D&quot;</code></pre>
</div><p>返回字段说明：</p>
<ul>
<li><code>status</code>：<code>testing</code> 表示当前需要按 <code>targets</code> 列表进行测试；<code>complete</code> 表示已经得到最终结果</li>
<li><code>targetCount</code>：本轮排查的测试目标总数</li>
<li><code>targets</code>：<code>testing</code> 时表示当前需要测试的目标列表；<code>complete</code> 时表示最终结果列表</li>
<li><code>extraAnswerCount</code>：可选；仅在结果为 <code>complete</code> 且传入了多余 <code>answers</code> 值时返回</li>
</ul>
<p><code>answers</code> 支持以下取值：</p>
<ul>
<li><code>y</code> / <code>yes</code> / <code>issue</code> / <code>1</code> / <code>true</code>：表示“有兼容性问题”</li>
<li><code>n</code> / <code>no</code> / <code>pass</code> / <code>0</code> / <code>false</code>：表示“没有兼容性问题”</li>
</ul>
<p>如果传入的 <code>answers</code> 在会话结束后还有多余值，CLI 仍会返回最终结果，并在 JSON 输出中附带 <code>extraAnswerCount</code>。</p>
<p>示例 1：</p>
<div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::t1jbqpwpohfgyj5m3f33::--><code>compat-finder next -c 3 -a &quot;y&quot;</code></pre>
</div><p>预期输出为以下 JSON：</p>
<div class="language-json"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre><!--::markdown-it-async::tzj3h046kwr81z9pzsa9::--><code>{
  &quot;status&quot;: &quot;testing&quot;,
  &quot;targetCount&quot;: 3,
  &quot;targets&quot;: [&quot;目标 1&quot;]
}</code></pre>
</div><p>示例 2：</p>
<div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::mmxz60x13h8z2dwqaxkpa::--><code>compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div><p>预期输出为以下 JSON：</p>
<div class="language-json"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre><!--::markdown-it-async::pumqk97vchn8avkf00rzr::--><code>{
  &quot;status&quot;: &quot;testing&quot;,
  &quot;targetCount&quot;: 3,
  &quot;targets&quot;: [&quot;目标 2&quot;]
}</code></pre>
</div><p>示例 3：</p>
<div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::7bsrjorrqlf9zl9vpam35t::--><code>compat-finder next -c 3 -a &quot;y,n,n&quot;</code></pre>
</div><p>预期输出为以下 JSON：</p>
<div class="language-json"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre><!--::markdown-it-async::7yd2uecapbakqlrinktk2m::--><code>{
  &quot;status&quot;: &quot;complete&quot;,
  &quot;targetCount&quot;: 3,
  &quot;targets&quot;: [&quot;目标 1&quot;, &quot;目标 2&quot;]
}</code></pre>
</div><h2 id="输出语言" tabindex="-1">输出语言 <a class="header-anchor" href="#输出语言" aria-label="Permalink to “输出语言”">&#8203;</a></h2>
<p>CLI 文案可以通过命令行参数或环境变量设置输出语言。</p>
<p>优先级：</p>
<ol>
<li>命令行参数：<code>--locale</code> / <code>-l</code></li>
<li>环境变量：<code>COMPAT_FINDER_LOCALE</code></li>
<li>环境变量：<code>LC_ALL</code></li>
<li>环境变量：<code>LC_MESSAGES</code></li>
<li>环境变量：<code>LANG</code></li>
<li>默认值：<code>en</code></li>
</ol>
<p>支持的语言：</p>
<ul>
<li><code>en</code></li>
<li><code>zh-Hans</code></li>
</ul>
<p>兼容旧的简体中文 locale 标签，例如 <code>zh-CN</code> 与 <code>zh-SG</code> 会被归一化为 <code>zh-Hans</code>。<br>
显式传入不支持的值时会直接报错，包括 <code>zh-TW</code>、<code>zh-Hant</code> 等其他中文变体，不会静默切换到英文。<br>
环境变量中的不支持值会被忽略，并继续按优先级查找；如果最终没有匹配到支持语言，则回退到 <code>en</code>。</p>
<h2 id="算法" tabindex="-1">算法 <a class="header-anchor" href="#算法" aria-label="Permalink to “算法”">&#8203;</a></h2>
<p>两个 CLI 子命令都支持 <code>--algorithm &lt;名称&gt;</code> 和 <code>--algo &lt;名称&gt;</code>。</p>
<ul>
<li><code>binary-split</code>：默认排查算法</li>
<li><code>leave-one-out</code>：每轮排除 1 个目标进行测试</li>
</ul>
<p>想了解更多关于这两个算法的区别，请阅读 <a href="./algorithm-performance">算法性能</a>。</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[快速上手]]></title>
            <link>https://howiehz.top/misc/compat-finder/getting-started</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/getting-started</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[本页展示如何安装 `compat-finder`，并用最短路径开始使用库或 CLI。
 环境要求
- 作为库使用：兼容 ESM 的运行时
- 作为 CLI 使用：Node.js `^22 || 
 安]]></description>
            <content:encoded><![CDATA[<h1 id="快速上手" tabindex="-1">快速上手 <a class="header-anchor" href="#快速上手" aria-label="Permalink to “快速上手”">&#8203;</a></h1>
<p>本页展示如何安装 <code>compat-finder</code>，并用最短路径开始使用库或 CLI。</p>
<h2 id="环境要求" tabindex="-1">环境要求 <a class="header-anchor" href="#环境要求" aria-label="Permalink to “环境要求”">&#8203;</a></h2>
<ul>
<li>作为库使用：兼容 ESM 的运行时</li>
<li>作为 CLI 使用：Node.js <code>^22 || &gt;=24</code></li>
</ul>
<h2 id="安装" tabindex="-1">安装 <a class="header-anchor" href="#安装" aria-label="Permalink to “安装”">&#8203;</a></h2>
<p>使用你常用的包管理器安装 <code>compat-finder</code>：</p>
<table><tbody><tr><td>npm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::wrto18x18kh9pkemdaliqe::--><code>npm install compat-finder</code></pre>
</div></td></tr><tr><td>pnpm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::c3u09k9p6j6oxcte6adwu::--><code>pnpm add compat-finder</code></pre>
</div></td></tr><tr><td>yarn</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::vasc6qsugnjekwidsxn6pb::--><code>yarn add compat-finder</code></pre>
</div></td></tr><tr><td>bun</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::zcgemwz4omf6fg61ya178c::--><code>bun add compat-finder</code></pre>
</div></td></tr><tr><td>deno</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::xtaysrdhfcwu9y7hcgngs::--><code>deno add npm:compat-finder</code></pre>
</div></td></tr><tr><td>vlt</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::616ki28ydmik0m3yj5mg9::--><code>vlt install compat-finder</code></pre>
</div></td></tr><tr><td>vp</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::0cq5xqkhzs5me4vz3wg6l::--><code>vp add compat-finder</code></pre>
</div></td></tr></tbody></table>
<p>安装后即可导入并创建会话：</p>
<div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><!--::markdown-it-async::j87c137vwljtedyfhw3nhh::--><code>import { createCompatibilitySession } from &quot;compat-finder&quot;;

const session = createCompatibilitySession([&quot;A&quot;, &quot;B&quot;]);</code></pre>
</div><p>如果你只是想快速试用 CLI，也可以不安装，直接运行：</p>
<table><tbody><tr><td>npm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::vbpwxbzlpogr3cq2aua3m::--><code>npx compat-finder --help</code></pre>
</div></td></tr><tr><td>pnpm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::34yv4vsvtucqc1gv3kz54::--><code>pnpm dlx compat-finder --help</code></pre>
</div></td></tr><tr><td>yarn</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::bmqia0xaqr67ptx35vj24n::--><code>yarn dlx compat-finder --help</code></pre>
</div></td></tr><tr><td>bun</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::3uvppeh5tgl4bwfq3lr2ts::--><code>bunx compat-finder --help</code></pre>
</div></td></tr><tr><td>deno</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::9mwvxzrbqva9d5hn7n3qte::--><code>deno run npm:compat-finder --help</code></pre>
</div></td></tr><tr><td>vlt</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::c5qqx9qtvpr781xjzwqx5x::--><code>vlx compat-finder --help</code></pre>
</div></td></tr><tr><td>vp</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::g7tof0ttm34m8st4jb2v9::--><code>vp exec compat-finder</code></pre>
</div></td></tr></tbody></table>
<h2 id="库使用示例" tabindex="-1">库使用示例 <a class="header-anchor" href="#库使用示例" aria-label="Permalink to “库使用示例”">&#8203;</a></h2>
<p>下面的示例展示了一个最小可用的 <code>compat-finder</code> 会话：</p>
<div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><!--::markdown-it-async::8kjfyrc1o2y1bgqurlgln::--><code>import { createCompatibilitySession } from &quot;compat-finder&quot;;

const session = createCompatibilitySession([&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;]);

let step = session.current();

while (step.status === &quot;testing&quot;) {
  const result = askUser(step.targets);

  if (result === &quot;undo&quot;) {
    step = session.undo();
    continue;
  }

  step = session.answer(result === &quot;issue&quot;);
}

console.log(&quot;最终结果：&quot;, step.targets);

function askUser(targets: readonly string[]): &quot;issue&quot; | &quot;pass&quot; | &quot;undo&quot; {
  console.log(&quot;当前需要测试：&quot;, targets);
  return &quot;issue&quot;;
}</code></pre>
</div><h2 id="cli-使用示例" tabindex="-1">CLI 使用示例 <a class="header-anchor" href="#cli-使用示例" aria-label="Permalink to “CLI 使用示例”">&#8203;</a></h2>
<p>如果你更想直接从命令行开始，可以先试下面几个例子。</p>
<p>运行完整的交互式排查流程：</p>
<table><tbody><tr><td>npm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::nspfcpgbd6mzw6ny9nk34l::--><code>npx compat-finder interactive --count 4</code></pre>
</div></td></tr><tr><td>pnpm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::38ta77nj8fl9cbbxma06aw::--><code>pnpm dlx compat-finder interactive --count 4</code></pre>
</div></td></tr><tr><td>yarn</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::3n1sf2xz464v40uvj3w57a::--><code>yarn dlx compat-finder interactive --count 4</code></pre>
</div></td></tr><tr><td>bun</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::uyaa02pyprfwo6amp8m3aq::--><code>bunx compat-finder interactive --count 4</code></pre>
</div></td></tr><tr><td>deno</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::uk063cwc1nkd86i73h6dr::--><code>deno run npm:compat-finder interactive --count 4</code></pre>
</div></td></tr><tr><td>vlt</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::sghxua97ql9c1fj65fmlc::--><code>vlx compat-finder interactive --count 4</code></pre>
</div></td></tr><tr><td>vp</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::wsnnw5od7xb6t8nl22lvlo::--><code>vp exec compat-finder interactive --count 4</code></pre>
</div></td></tr></tbody></table>
<p>根据已有回答计算下一步要测试的目标：</p>
<table><tbody><tr><td>npm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::eo6m76o76nom4ydhheykk::--><code>npx compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr><tr><td>pnpm</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::19pht5sa1z4vrwgyrt0f29::--><code>pnpm dlx compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr><tr><td>yarn</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::2qgz4v5sps19b2wj9bumk9::--><code>yarn dlx compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr><tr><td>bun</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::c9j3ehqawjcexd5983pyr::--><code>bunx compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr><tr><td>deno</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::nfeay7y2yj9hw2uyy1sv6n::--><code>deno run npm:compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr><tr><td>vlt</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::hxqq12h80q97pqftbzbxe7::--><code>vlx compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr><tr><td>vp</td><td><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre><!--::markdown-it-async::s5xd6pq065k5w79cl0e0xk::--><code>vp exec compat-finder next -c 3 -a &quot;y,n&quot;</code></pre>
</div></td></tr></tbody></table>
<p>预期会输出如下 JSON：</p>
<div class="language-json"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre><!--::markdown-it-async::rtl9hcntftep6qty4dce4::--><code>{
  &quot;status&quot;: &quot;testing&quot;,
  &quot;targetCount&quot;: 3,
  &quot;targets&quot;: [&quot;目标 2&quot;]
}</code></pre>
</div><h2 id="下一步" tabindex="-1">下一步 <a class="header-anchor" href="#下一步" aria-label="Permalink to “下一步”">&#8203;</a></h2>
<ul>
<li>了解如何<a href="./ai">与 AI 协作</a></li>
<li>在线体验 <a href="./online-tool">compat-finder</a></li>
<li>查看<a href="./cli">命令行工具</a>了解完整命令和参数</li>
<li>查看<a href="./api">API 参考</a></li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[兼容性问题排查器]]></title>
            <link>https://howiehz.top/misc/compat-finder/</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[`compat-finder` 是一个用于排查多个目标之间兼容性问题的 TypeScript 库和命令行工具。
它帮助你用更少的测试轮次找出一个或多个不兼容目标。
 功能特点
- 零运行时依赖：安装更]]></description>
            <content:encoded><![CDATA[<h1 id="兼容性问题排查器" tabindex="-1">兼容性问题排查器 <a class="header-anchor" href="#兼容性问题排查器" aria-label="Permalink to “兼容性问题排查器”">&#8203;</a></h1>
<p><code>compat-finder</code> 是一个用于排查多个目标之间兼容性问题的 TypeScript 库和命令行工具。</p>
<p>它帮助你用更少的测试轮次找出一个或多个不兼容目标。</p>
<h2 id="功能特点" tabindex="-1">功能特点 <a class="header-anchor" href="#功能特点" aria-label="Permalink to “功能特点”">&#8203;</a></h2>
<ul>
<li><strong>零运行时依赖</strong>：安装更轻量，也能降低供应链风险。</li>
<li><strong>高效排查算法</strong>：默认算法采用二分法结合分治法的策略，通常只需较少测试轮次即可得出结果。</li>
<li><strong>不只简单二分</strong>：排查结果目标可以是一个或多个。</li>
<li><strong>多种接入形式</strong>：提供引导式 CLI、开箱即用的会话 API，以及适合自定义流程的高级 API。</li>
<li><strong>适合多种运行环境</strong>：发布产物为 ESM，可用于浏览器和其他兼容 ESM 的运行时。</li>
<li><strong>本地化 CLI</strong>：支持英文和简体中文。</li>
</ul>
<h2 id="适用范围" tabindex="-1">适用范围 <a class="header-anchor" href="#适用范围" aria-label="Permalink to “适用范围”">&#8203;</a></h2>
<ul>
<li>作为库使用：发布产物为 ESM，可用于浏览器和其他兼容 ESM 的运行时。</li>
<li>作为命令行工具使用：需要 Node.js <code>^22 || &gt;=24</code>；支持英文和简体中文。</li>
</ul>
<h2 id="阅读路线" tabindex="-1">阅读路线 <a class="header-anchor" href="#阅读路线" aria-label="Permalink to “阅读路线”">&#8203;</a></h2>
<ul>
<li><a href="./getting-started">快速上手</a>：先完成一次排查，快速了解库和 CLI 的基本用法</li>
<li><a href="./ai">与 AI 协作</a>：让 AI 帮你整理目标列表、生成命令或接入排查流程</li>
<li><a href="./online-tool">在线体验</a>：无需安装，直接在网页中发起一次排查</li>
<li><a href="./cli">命令行工具</a>：查看 CLI 的基本用法、常用命令和可选参数</li>
<li><a href="./api">API 参考</a>：把 <code>compat-finder</code> 集成到自己的项目或工具里</li>
<li><a href="./algorithm-performance">算法性能</a>：比较两种算法的轮次表现，判断何时切换</li>
</ul>
<h2 id="相关项目" tabindex="-1">相关项目 <a class="header-anchor" href="#相关项目" aria-label="Permalink to “相关项目”">&#8203;</a></h2>
<p>由 <a href="https://github.com/HowieHz/plugin-compatibility-checking-tool" target="_blank" rel="noreferrer">HowieHz/plugin-compatibility-checking-tool</a> 重构而来。</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在线体验]]></title>
            <link>https://howiehz.top/misc/compat-finder/online-tool</link>
            <guid isPermaLink="false">https://howiehz.top/misc/compat-finder/online-tool</guid>
            <pubDate>Wed, 13 May 2026 10:07:58 GMT</pubDate>
            <description><![CDATA[无需安装，打开即可使用：兼容性问题排查器
页面源码位于 tools/compatibility-test。]]></description>
            <content:encoded><![CDATA[<h1 id="在线体验" tabindex="-1">在线体验 <a class="header-anchor" href="#在线体验" aria-label="Permalink to “在线体验”">&#8203;</a></h1>
<p>无需安装，打开即可使用：<a href="./../tools/compatibility-test/">兼容性问题排查器</a></p>
<p>页面源码位于 <a href="https://github.com/HowieHz/howiehz-misc/tree/main/docs/tools/compatibility-test" target="_blank" rel="noreferrer">tools/compatibility-test</a>。</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HRBUST XCPC 练习 2024 级题解分享]]></title>
            <link>https://howiehz.top/misc/posts/junk/hrbust-2024-solutions</link>
            <guid isPermaLink="false">https://howiehz.top/misc/posts/junk/hrbust-2024-solutions</guid>
            <pubDate>Mon, 02 Sep 2024 14:20:00 GMT</pubDate>
            <description><![CDATA[&lt;!-- markdownlint-disable MD024 --
 HRBUST XCPC 练习 2024 级题解分享
::: details 迁移自主站
- 移动原因：单纯放答案，相较于其]]></description>
            <content:encoded><![CDATA[<!-- markdownlint-disable MD024 -->
<h1 id="hrbust-xcpc-练习-2024-级题解分享" tabindex="-1">HRBUST XCPC 练习 2024 级题解分享 <a class="header-anchor" href="#hrbust-xcpc-练习-2024-级题解分享" aria-label="Permalink to “HRBUST XCPC 练习 2024 级题解分享”">&#8203;</a></h1>
<details  class="details custom-block"><summary>迁移自主站</summary>
<ul>
<li>移动原因：单纯放答案，相较于其他认真写的几篇没啥价值。</li>
<li>Hrbust ACM 练习 2024 级第 1~2 周题单 题解分享
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-1-2-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-02T22:20:00+08:00</li>
<li>访问量：289</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 3 周题单 题解分享
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-3-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-09T22:50:02+08:00</li>
<li>访问量：229</li>
<li>评论量：1</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 4 周题单 题解分享 (A-G,J-O)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-4-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-16T20:59:18+08:00</li>
<li>访问量：229</li>
<li>评论量：1</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 5 周题单 题解分享 (A-C,F-H)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-5-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-24T00:51:42+08:00</li>
<li>访问量：113</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 编程练习 20240922 题解分享
<ul>
<li>链接：<code>/archives/hrbustacm-programming-exercise-20240922</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-09-24T13:54:35+08:00</li>
<li>访问量：175</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 9 周题单 题解分享 (A-B)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-9-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-11-06T00:51:52+08:00</li>
<li>访问量：89</li>
<li>评论量：0</li>
</ul>
</li>
<li>Hrbust ACM 练习 2024 级第 11 周题单 题解分享 (A-B)
<ul>
<li>链接：<code>/archives/hrbustacm-class-of-2024-week-11-questionnaire</code></li>
<li>分类：<code>知识传承 &gt; 竞赛解密 &gt; 题解档案</code></li>
<li>标签：<code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-11-10T02:42:13+08:00</li>
<li>访问量：138</li>
<li>评论量：1</li>
</ul>
</li>
</ul>
</details>
<h2 id="hrbust-acm-练习-2024-级第-1-2-周题单-题解分享" tabindex="-1">Hrbust ACM 练习 2024 级第 1~2 周题单 题解分享 <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-1-2-周题单-题解分享" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 1~2 周题单 题解分享”">&#8203;</a></h2>
<h3 id="前言" tabindex="-1">前言 <a class="header-anchor" href="#前言" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/652737" target="_blank" rel="noreferrer">2024 级第 1~2 周题单 - Virtual Judge (vjudge.net)</a>
熟悉下 oj 的使用。vjudge 感觉没洛谷好用，提交代码的编辑器没语法高亮。
下面的先是 Python3 代码，之后是 C++ 代码。
注意：主要题目数据范围，有些要开 long long。</p>
<h3 id="a-题" tabindex="-1">A 题 <a class="header-anchor" href="#a-题" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::y2kk6rtxqdnpac2p11j8gs::--><code>print(&quot;Hello World!&quot;)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::5orhlajyzlt5xtnho838et::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main(){
    cout &lt;&lt; &quot;Hello World!&quot;;
    return 0;
}</code></pre>
</div><h3 id="b-题" tabindex="-1">B 题 <a class="header-anchor" href="#b-题" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::aoqv1vdp2rtftjwjmgwu0l::--><code>print(chr(int(input())))</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::y99rv4xr1ho7jn3epvkedi::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    int ch;
    cin &gt;&gt; ch;
    cout &lt;&lt; static_cast&lt;char&gt;(ch);
    return 0;
}</code></pre>
</div><h3 id="c-题" tabindex="-1">C 题 <a class="header-anchor" href="#c-题" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::pmpc8ah9ou0lz0toexkf9::--><code>print(sum(map(int,input().split())))</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::k5v2nv08rhqmuxsque67c::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    int a, b;
    cin &gt;&gt; a &gt;&gt; b;
    cout &lt;&lt; a+b;
    return 0;
}</code></pre>
</div><h3 id="d-题" tabindex="-1">D 题 <a class="header-anchor" href="#d-题" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::5j2fe2m5q5a38sh8c1q1ow::--><code>print(int(input())**2)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::iw13rg26s2q44x2130trq::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    long long a;
    cin &gt;&gt; a;
    cout &lt;&lt; a*a;
    return 0;
}</code></pre>
</div><h3 id="e-题" tabindex="-1">E 题 <a class="header-anchor" href="#e-题" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::zwbwsc7iqz8eobbosrvo0r::--><code>x=int(input())
print(x**2+2*x+5)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::d10c4fzog8w5hysdzlj02d::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    int a;
    cin &gt;&gt; a;
    cout &lt;&lt; a*a+a*2+5;
    return 0;
}</code></pre>
</div><h3 id="f-题" tabindex="-1">F 题 <a class="header-anchor" href="#f-题" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::avlvgt1i1rcikd1lsyd9t::--><code>print(f&#039;{(float(input())-32)/9*5:.5f}&#039;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::25cqahcn8hiph0h02ae6li::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main()
{
    double n;
    cin &gt;&gt; n;
    printf(&quot;%.5f\n&quot;, ((n-32)*5/9));
    return 0;
}</code></pre>
</div><h3 id="g-题" tabindex="-1">G 题 <a class="header-anchor" href="#g-题" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>9 月 5 日编写</p>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::pd54dkpuknhqs46tpwnikn::--><code>x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
print(f&quot;{((x1-x2)**2+(y1-y2)**2)**0.5:.3f}&quot;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::dvf8i3lmf5iezg4gviklcw::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int x1, x2, y1, y2;
    cin &gt;&gt; x1 &gt;&gt; y1 &gt;&gt; x2 &gt;&gt; y2;
    cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    return 0;
}</code></pre>
</div><h3 id="h-题" tabindex="-1">H 题 <a class="header-anchor" href="#h-题" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::d70nm4s48osdeiwac1fb1g::--><code>x = float(input())
if 0 &lt;= x &lt; 5:
    y = -x + 2.5
elif 5 &lt;= x &lt; 10:
    y = 2 - 1.5 * (x - 3) * (x - 3)
elif 10 &lt;= x &lt; 20:
    y = x / 2 - 1.5
print(f&quot;{y:.3f}&quot;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::kx1ck13rc3kyru0vzs9dn9::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    double x, y;
    cin &gt;&gt; x;
    if (0 &lt;= x &amp;&amp; x &lt; 5)
    {
        y = -x + 2.5;
    }
    else if (5 &lt;= x &amp;&amp; x &lt; 10)
    {
        y = 2 - 1.5 * (x - 3) * (x - 3);
    }
    else if (10 &lt;= x &amp;&amp; x &lt; 20)
    {
        y = x / 2 - 1.5;
    }
    cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; y;
    return 0;
}</code></pre>
</div><h3 id="i-题" tabindex="-1">I 题 <a class="header-anchor" href="#i-题" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::177916cgi3uh32wqavfl5sg::--><code>n = int(input())
def a():
    for i in range(2, n):
        if n % i == 0:
            print(&quot;No&quot;)
            return
    print(&quot;Yes&quot;)
a()</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::t2r7mz1yiucltjgpv1t2::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    for (int i = 2; i &lt;= n - 1; i++)
    {
        if (n % i == 0)
        {
            cout &lt;&lt; &quot;No&quot;;
            return 0;
        }
    }
    cout &lt;&lt; &quot;Yes&quot;;
    return 0;
}</code></pre>
</div><h3 id="j-题" tabindex="-1">J 题 <a class="header-anchor" href="#j-题" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::wvp9y76f1arjhms8qmyn2n::--><code>w = int(input())
if w &gt; 2 and w % 2 == 0:
    print(&quot;YES&quot;)
else:
    print(&quot;NO&quot;)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::odpmc4y185ayeay11znw5::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int w;
    cin &gt;&gt; w;
    if (w &gt; 2 &amp;&amp; w % 2 == 0)
    {
        cout &lt;&lt; &quot;YES&quot;;
    }
    else
    {
        cout &lt;&lt; &quot;NO&quot;;
    }
    return 0;
}</code></pre>
</div><h3 id="k-题" tabindex="-1">K 题 <a class="header-anchor" href="#k-题" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::19zah28g8h1opav6jru8lb::--><code>n = int(input())
rt = 0
while n &gt; 0:
    n -= 1
    if sum(map(int, input().split())) &gt;= 2:
        rt += 1
print(rt)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::or8bk024x9r110jiwzeqi9r::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int lines, ret;
    ret = 0;
    cin &gt;&gt; lines;
    while (lines &gt; 0)
    {
        lines--;
        int x, y, z;
        cin &gt;&gt; x &gt;&gt; y &gt;&gt; z;
        if (x + y + z &gt;= 2)
        {
            ret++;
        }
    }
    cout &lt;&lt; ret;
    return 0;
}</code></pre>
</div><h3 id="l-题" tabindex="-1">L 题 <a class="header-anchor" href="#l-题" aria-label="Permalink to “L 题”">&#8203;</a></h3>
<p>Python code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::wuz226hgkhcup5yajdnihj::--><code>n = int(input())
while n &gt; 0:
    n -= 1
    word = input()
    if len(word) &gt; 10:
        print(word[0] + str(len(word) - 2) + word[-1])
    else:
        print(word)</code></pre>
</div><p>Cpp code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::zpzepwk38hou1hk864z::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0)
    {
        n--;
        string s;
        cin &gt;&gt; s;
        if (s.size() &gt; 10)
        {
            cout &lt;&lt; s.substr(0, 1) &lt;&lt; s.size() - 2 &lt;&lt; s.substr(s.size() - 1, s.size()) &lt;&lt; endl;
        }
        else
        {
            cout &lt;&lt; s &lt;&lt; endl;
        }
    }
    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-3-周题单-题解分享" tabindex="-1">Hrbust ACM 练习 2024 级第 3 周题单 题解分享 <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-3-周题单-题解分享" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 3 周题单 题解分享”">&#8203;</a></h2>
<h3 id="前言-1" tabindex="-1">前言 <a class="header-anchor" href="#前言-1" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/654371" target="_blank" rel="noreferrer">2024 级第 3 周题单 - Virtual Judge (vjudge.net)</a>
有些题不能提交 Python 代码，所以只有 Cpp 代码。</p>
<p>我尝试找了找这些题的出处，搜索引擎中搜到的题解大多比笔者写得更好，所以建议直接检索对应题目的题解。</p>
<ul>
<li>A 题是 SWUSTOJ 1178</li>
<li>B 题是 零起点学算法 106</li>
<li>C 题是 水仙花数，很多 oj 都有，比较常见。但是这个变体没搜到，可能是原创题。</li>
<li>D 题是 HDU 2016</li>
<li>E 题是 HDU 2017</li>
<li>F 题是 HDU 2043</li>
<li>G 题是 HDU 1062</li>
<li>H 题是 HDU 2020</li>
<li>I 题是 51Nod 3212</li>
<li>J 题是 <a href="https://vjudge.net/problem/%E8%AE%A1%E8%92%9C%E5%AE%A2-T1715/origin" target="_blank" rel="noreferrer">计蒜客-T1715</a></li>
<li>K 题是 <a href="https://vjudge.net/problem/%E8%AE%A1%E8%92%9C%E5%AE%A2-T1232/origin" target="_blank" rel="noreferrer">计蒜客-T1232</a></li>
</ul>
<h3 id="a-题-1" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-1" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::6sh497mbx4br3omiydxhq::--><code>s = input()
for c in s:
    if &quot;a&quot; &lt;= c &lt;= &quot;y&quot; or &quot;A&quot; &lt;= c &lt;= &quot;Y&quot;:
        print(chr(ord(c) + 1), end=&quot;&quot;)
    elif c == &quot;z&quot;:
        print(&quot;a&quot;, end=&quot;&quot;)
    elif c == &quot;Z&quot;:
        print(&quot;A&quot;, end=&quot;&quot;)
    else:
        print(c, end=&quot;&quot;)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::kdvmpyq5hvgw7pl8yijy::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    string s;
    getline(cin, s);
    for (char c : s)
    {
        if (&#039;a&#039; &lt;= c &amp;&amp; c &lt;= &#039;y&#039;)
        {
            cout &lt;&lt; char(c + 1);
        }
        else if (&#039;A&#039; &lt;= c &amp;&amp; c &lt;= &#039;Y&#039;)
        {
            cout &lt;&lt; char(c + 1);
        }
        else if (c == &#039;z&#039;)
        {
            cout &lt;&lt; &#039;a&#039;;
        }
        else if (c == &#039;Z&#039;)
        {
            cout &lt;&lt; &#039;A&#039;;
        }
        else
        {
            cout &lt;&lt; c;
        }
    }
    cout &lt;&lt; &quot; &quot;;
    return 0;
}</code></pre>
</div><h3 id="b-题-1" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-1" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::ad7dnexzltru8ujs474j7::--><code>s = input().split()
rt_s = []
for i in s:
    rt_s.append(i.capitalize())
print(&quot; &quot;.join(rt_s))</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::8vm547593e30fomb4vc3u5o::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    string word;
    while (cin &gt;&gt; word)
    {
        word[0] = toupper(word[0]);
        cout &lt;&lt; word &lt;&lt; &quot; &quot;;
    }
}</code></pre>
</div><h3 id="c-题-1" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-1" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>这题 水仙花数 很常见，很多 oj 都有类似的</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::2ar2e8g2bwfw3kn4l5gdr::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int a, b, yesorno;
    while (cin &gt;&gt; a &gt;&gt; b)
    {
        yesorno = 0;
        for (int i = a; i &lt;= b; i++)
        {
            if (pow((i / 100), 3) + pow((i / 10 % 10), 3) + pow((i % 10), 3) == i)
            {
                cout &lt;&lt; i &lt;&lt; &quot; &quot;;
                yesorno = 1;
            }
        }
        if (yesorno == 0)
        {
            cout &lt;&lt; &quot;no&quot; &lt;&lt; endl;
        } else{
            cout &lt;&lt; endl;
        }
    }
}</code></pre>
</div><h3 id="d-题-1" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-1" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::cvcp16nyhllgzvkr4t8jzb::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n, b;
    while (cin &gt;&gt; n)
    {
        if (n == 0)
        {
            return 0;
        }

        list&lt;int&gt; int_list;
        while (n &gt; 0)
        {
            n--;
            cin &gt;&gt; b;
            int_list.push_back(b);
        }

        list&lt;int&gt; new_int_list = int_list;
        new_int_list.sort();
        int min_number = new_int_list.front();

        list&lt;int&gt;::iterator it = find(int_list.begin(), int_list.end(), min_number);

        int index;
        if (it != int_list.end())
        {
            index = distance(int_list.begin(), it);
        }

        auto it2 = next(int_list.begin(), index);

        *it2 = *int_list.begin();
        *int_list.begin() = min_number;

        while (int_list.size() != 0)
        {
            cout &lt;&lt; int_list.front() &lt;&lt; &quot; &quot;;
            int_list.pop_front();
        }
        cout &lt;&lt; endl;
    }
}</code></pre>
</div><h3 id="e-题-1" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-1" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::qsc0ilqps0pbq1ltxzudh5::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0)
    {
        n--;
        string s;
        int ret = 0;
        cin &gt;&gt; s;
        for (char c : s)
        {
            if (isdigit(c))
            {
                ret++;
            }
        }
        cout &lt;&lt; ret;
    }
}</code></pre>
</div><h3 id="f-题-1" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-1" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::umdv11drx5p3ffm53boezg::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

bool check(string s)
{
    bool upper = false, lower = false, digit = false, special = false;

    for (char c : s)
    {
        if (isupper(c))
        {
            upper = true;
            continue;
        }
        else if (islower(c))
        {
            lower = true;
            continue;
        }
        else if (isdigit(c))
        {
            digit = true;
            continue;
        }
        else if (c == &#039;~&#039; or c == &#039;!&#039; or c == &#039;@&#039; or c == &#039;#&#039; or c == &#039;$&#039; or c == &#039;%&#039; or c == &#039;^&#039;)
        {
            special = true;
            continue;
        }
    }

    if (upper + lower + digit + special &gt;= 3)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0)
    {
        n--;
        string s;
        cin &gt;&gt; s;
        if (s.size() &lt; 8 or s.size() &gt; 16)
        {
            cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
            continue;
        }

        if (check(s))
        {
            cout &lt;&lt; &quot;YES&quot; &lt;&lt; endl;
            continue;
        }
        else
        {
            cout &lt;&lt; &quot;NO&quot; &lt;&lt; endl;
            continue;
        }
    }
    return 0;
}</code></pre>
</div><h3 id="g-题-1" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-1" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::583yqsue6d3skhxz7atylh::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
int main()
{
    int n;
    cin &gt;&gt; n;
    cin.get();
    while (n &gt; 0)
    {
        n--;
        string str;
        list&lt;char&gt; char_list;
        list&lt;char&gt; char_list_r;
        getline(cin, str);
        for (char c : str)
        {
            if (c == &#039; &#039;)
            {
                for (auto const &amp;i : char_list_r)
                {
                    cout &lt;&lt; i;
                }
                char_list_r.clear();
                cout &lt;&lt; &#039; &#039;;
                continue;
            }
            char_list_r.push_front(c);
        }
        for (auto const &amp;i : char_list_r)
        {
            cout &lt;&lt; i;
        }
        char_list_r.clear();
        cout &lt;&lt; endl;
    }
}</code></pre>
</div><h3 id="h-题-1" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-1" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::ggl0bfbfy7khi91t3fckz6::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

bool cmp(const int a, const int b)
{
    return abs(a) &gt; abs(b);
}

int main()
{
    int n, b;
    while (cin &gt;&gt; n)
    {
        if (n == 0)
        {
            return 0;
        }
        list&lt;int&gt; int_list;
        while (n &gt; 0)
        {
            n--;
            cin &gt;&gt; b;
            int_list.push_back(b);
        }
        int_list.sort(cmp);
        for (auto const &amp;i : int_list)
        {
            cout &lt;&lt; i &lt;&lt; &quot; &quot;;
        }
        cout &lt;&lt; endl;
    }
}</code></pre>
</div><h3 id="i-题-1" tabindex="-1">I 题 <a class="header-anchor" href="#i-题-1" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::evfzckj32nnoaed2tjuijf::--><code>n = int(input())
l = []
while True:
    if n == 0:
        break
    l.append(str(n % 10))
    n //= 10
min_n = sorted(l)
if min_n[0] == &quot;0&quot;:
    for index, n in enumerate(min_n):
        if n != &quot;0&quot;:
            min_n[0] = min_n[index]
            min_n[index] = &quot;0&quot;
            break
print(&quot;&quot;.join(sorted(l, reverse=True)), &quot;&quot;.join(min_n))</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::te8uomjnfjixyf35khbg9g::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

int main() {
    long long n;
    cin &gt;&gt; n;
    list&lt;long long&gt; int_list;
    list&lt;long long&gt; int_list_r;
    while (true) {
        if (n == 0) {
            break;
        }
        int_list.push_back(n % 10);
        n /= 10;
    }
    int_list.sort();

    for (long long n : int_list) {
        int_list_r.push_front(n);
    }

    for (auto const &amp;i : int_list_r) {
        cout &lt;&lt; i;
    }
    cout &lt;&lt; &quot; &quot;;

    while (int_list.front() == 0) {
        auto it = int_list.begin();
        while (*(it++) == 0) {
            continue;
        }
        int_list.emplace(it, 0);
        int_list.pop_front();
    }
    for (auto const &amp;i : int_list) {
        cout &lt;&lt; i;
    }
}</code></pre>
</div><h3 id="j-题-1" tabindex="-1">J 题 <a class="header-anchor" href="#j-题-1" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>这题奇怪的是<code>思路一实现一</code>只需要开 99 大小的数组就能过，而<code>思路二实现二</code>需要开 100 大小的数组才能过。</p>
<p>思路一实现一 Cpp Code（关键：用 scanf 写入 char[] 无需取址、用 strcpy 写入结构体 char[])</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::lhns84y7xmljvj3hn4y2nf::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
struct T
{
    char name[21];
    long long order;
} tl[99];

bool cmp(T a, T b)
{
    return a.order &lt; b.order;
}

int main()
{
    int n;
    cin &gt;&gt; n;

    for (int i = 0; i &lt; n; i++)
    {
        char name[21];
        long long y, m, d, input_order;
        scanf(&quot;%s %lld %lld %lld&quot;, name, &amp;y, &amp;m, &amp;d);

        input_order = n - i;

        strcpy(tl[i].name, name);
        tl[i].order = y * 10000000 + m * 100000 + d * 1000 + input_order;
    }

    sort(tl, tl + n, cmp);

    for (int i = 0; i &lt; n; i++)
    {
        cout &lt;&lt; tl[i].name &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>思路一实现二 Cpp Code 另一种实现（关键：结构体用 string、scanf 写入 string 的方法）</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::h06dbl6ighyyu6w1z4wkc::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
struct T {
    string name;
    long long order;
} tl[100];

bool cmp(T a, T b) { return a.order &lt; b.order; }

int main() {
    int n;
    cin &gt;&gt; n;

    for (int i = 0; i &lt; n; i++) {
        string name;
        name.resize(21);
        long long y, m, d, input_order;
        scanf(&quot;%s %lld %lld %lld&quot;, &amp;name[0], &amp;y, &amp;m, &amp;d);

        input_order = n - i;

        // 调用 c_str 方法，清除上面 resize 方法多申请的空间
        name = name.c_str();

        // 另一种方法清除上面 resize 方法多申请的空间，由李晟霄同学提供
        // for (int i = 0; i &lt; name.length(); i++) {
        //     if (int(name[i]) == 0) {
        //         name.resize(i);
        //         break;
        //     }
        // }

        tl[i].name = name;
        tl[i].order = y * 10000000 + m * 100000 + d * 1000 + input_order;
    }

    sort(tl, tl + n, cmp);

    for (int i = 0; i &lt; n; i++) {
        cout &lt;&lt; tl[i].name &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>思路二实现一 Cpp Code 另一种实现（关键：cin 直接写入结构体 string）</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::kh4xiad4kypj34mlqn4ce::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
struct T
{
    long long y, m, d, order;
    string name;
} tl[100];

bool cmp(T n1, T n2)
{
    if (n1.y != n2.y)
    {
        return n1.y &lt; n2.y;
    }
    if (n1.m != n2.m)
    {
        return n1.m &lt; n2.m;
    }
    if (n1.d != n2.d)
    {
        return n1.d &lt; n2.d;
    }
    return n1.order &gt; n2.order;
}

int main()
{
    int n;
    cin &gt;&gt; n;
    for (int i = 0; i &lt; n; i++)
    {
        cin &gt;&gt; tl[i].name &gt;&gt; tl[i].y &gt;&gt; tl[i].m &gt;&gt; tl[i].d;
        tl[i].order = i;
    }

    sort(tl, tl + n, cmp);

    for (int i = 0; i &lt; n; i++)
    {
        cout &lt;&lt; tl[i].name &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="k-题-1" tabindex="-1">K 题 <a class="header-anchor" href="#k-题-1" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::5gr605797gww0fkmqntnqe::--><code>t = input()
n = int(input())
l = [input() for _ in range(n)]

if t == &quot;inc&quot;:
    l.sort()
elif t == &quot;dec&quot;:
    l.sort(reverse=True)
elif t == &quot;ncinc&quot;:
    l.sort(key=lambda s: s.lower())
else:
    l.sort(key=lambda s: s.lower(), reverse=True)

for s in l:
    print(s)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::uuy6j2pxpmh1bh5fpnqmtt::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

string tolower_string(const string &amp;s)
{
    string lower_s = s;
    transform(lower_s.begin(), lower_s.end(), lower_s.begin(), ::tolower);
    return lower_s;
}

bool cicmp(const string &amp;m, const string &amp;n) // case insensitive compare
{
    return tolower_string(m) &lt; tolower_string(n);
}

bool cicmpr(const string &amp;m, const string &amp;n)
{
    return tolower_string(m) &gt; tolower_string(n);
}

int main()
{
    string t;
    int n;

    cin &gt;&gt; t;
    cin &gt;&gt; n;

    vector&lt;string&gt; l(n);
    for (int i = 0; i &lt; n; ++i)
    {
        cin &gt;&gt; l[i];
    }

    if (t == &quot;inc&quot;)
    {
        sort(l.begin(), l.end());
        // sort(l.begin(), l.end(), less&lt;string&gt;());
    }
    else if (t == &quot;dec&quot;)
    {
        sort(l.begin(), l.end(), greater&lt;string&gt;());
    }
    else if (t == &quot;ncinc&quot;)
    {
        sort(l.begin(), l.end(), cicmp);
    }
    else
    {
        sort(l.begin(), l.end(), cicmpr);
    }

    for (const string &amp;s : l)
    {
        cout &lt;&lt; s &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-4-周题单-题解分享-a-g-j-o" tabindex="-1">Hrbust ACM 练习 2024 级第 4 周题单 题解分享 (A-G,J-O) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-4-周题单-题解分享-a-g-j-o" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 4 周题单 题解分享 (A-G,J-O)”">&#8203;</a></h2>
<h3 id="前言-2" tabindex="-1">前言 <a class="header-anchor" href="#前言-2" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/655873" target="_blank" rel="noreferrer">2024 级第 4 周题单 - Virtual Judge (vjudge.net)</a></p>
<p>很多同学困惑怎么学习 C++，我在此分享下我的经验。
我也是刚学习 C++ 没几天，按照我之前自己学习 Python 的经验来说，如果有条件买本<strong>翻译水平较好的外国著作</strong>来学习是再好不过的，退一步来说就是从网上的文章或者从下载的电子书中学习 C++。</p>
<p>在我的个人体验中，通过高效精练的文字中学习是比从视频和直播中学习更快的。一本好的书更是能作为参考书来随时查阅。</p>
<p>网站我推荐 <a href="https://oi.wiki/" target="_blank" rel="noreferrer">OI Wiki</a>，在这个网站你可以学习到竞赛所需的语言知识和算法知识，另外推荐使用<a href="https://www.luogu.com.cn/" target="_blank" rel="noreferrer">洛谷 OJ</a> 中的官方题单进行能力训练。</p>
<p>祝大家学有所成！</p>
<h3 id="a-题-2" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-2" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>直接累加会超时，打表观察后直接计算。</p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::5wil8ki0giujmmimm43zmh::--><code>from math import ceil

n = int(input())
if n % 2 == 0:
    print(ceil(n / 2))
else:
    print(-ceil(n / 2))</code></pre>
</div><p>Python Code 另一种实现</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::zvphed1dg89g55gho6807w::--><code>n = int(input())
s = (n + 1) // 2
if n % 2 == 0:
    print(s)
else:
    print(-s)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::k7ucb61mpyh123vwdd3gu1::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin &gt;&gt; n;
    ll s = (n + 1) / 2;
    if (n % 2 == 1) {
        cout &lt;&lt; -s;
    } else {
        cout &lt;&lt; s;
    }
    return 0;
}</code></pre>
</div><h3 id="b-题-2" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-2" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>直接用标准库实现即可</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::a4y405qrg7rx2h730i55ma::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin &gt;&gt; n;
    vector&lt;int&gt; l;

    while (n &gt; 0) {
        n--;
        int a;
        cin &gt;&gt; a;

        if (a == 1) {
            int t;
            cin &gt;&gt; t;
            l.push_back(t);
        } else if (a == 2) {
            sort(l.begin(), l.end());
        } else if (a == 3) {
            reverse(l.begin(), l.end());
        } else if (a == 4) {
            cout &lt;&lt; l.size() &lt;&lt; endl;
        } else if (a == 5) {
            for (int i : l) {
                cout &lt;&lt; i &lt;&lt; &quot; &quot;;
            }
            cout &lt;&lt; endl;
        } else if (a == 6) {
            l.clear();
        }
    }
    return 0;
}</code></pre>
</div><h3 id="c-题-2" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-2" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>直接用标准库实现即可</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::engk5trqez8b5d18pmpouj::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin &gt;&gt; n;
    stack&lt;int&gt; l;
    while (n &gt; 0) {
        n--;
        int a;
        cin &gt;&gt; a;

        if (a == 1) {
            int t;
            cin &gt;&gt; t;
            l.push(t);
        } else if (a == 2) {
            cout &lt;&lt; l.top() &lt;&lt; endl;
        } else if (a == 3) {
            l.pop();
        } else if (a == 4) {
            cout &lt;&lt; l.size() &lt;&lt; endl;
        }
    }
}</code></pre>
</div><h3 id="d-题-2" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-2" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>直接用标准库实现即可</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::df7mf1vc5s6i5bad9bieki::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin &gt;&gt; n;
    stack&lt;int&gt; l;
    while (n &gt; 0) {
        n--;
        int a;
        cin &gt;&gt; a;

        if (a == 1) {
            int t;
            cin &gt;&gt; t;
            l.push(t);
        } else if (a == 2) {
            cout &lt;&lt; l.top() &lt;&lt; endl;
        } else if (a == 3) {
            l.pop();
        } else if (a == 4) {
            cout &lt;&lt; l.size() &lt;&lt; endl;
        }
    }
}</code></pre>
</div><h3 id="e-题-2" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-2" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>按照要求操作即可</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::zc0kg2s6xaaagrcyrv41r::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int T, m, i = 0;
    long long unsigned n;
    cin &gt;&gt; T;

    while (T &gt; 0) {
        T--;
        i++;
        cout &lt;&lt; &quot;Case &quot; &lt;&lt; i &lt;&lt; &quot;:&quot; &lt;&lt; endl;
        cin &gt;&gt; n &gt;&gt; m;
        deque&lt;int&gt; l;
        while (m &gt; 0) {
            m--;
            string a;
            cin &gt;&gt; a;

            if (a == &quot;pushLeft&quot;) {
                int number;
                cin &gt;&gt; number;
                if (l.size() == n) {
                    cout &lt;&lt; &quot;The queue is full&quot; &lt;&lt; endl;
                } else {
                    l.push_front(number);
                    cout &lt;&lt; &quot;Pushed in left: &quot; &lt;&lt; number &lt;&lt; endl;
                }
            } else if (a == &quot;pushRight&quot;) {
                int number;
                cin &gt;&gt; number;
                if (l.size() == n) {
                    cout &lt;&lt; &quot;The queue is full&quot; &lt;&lt; endl;
                } else {
                    l.push_back(number);
                    cout &lt;&lt; &quot;Pushed in right: &quot; &lt;&lt; number &lt;&lt; endl;
                }
            } else if (a == &quot;popLeft&quot;) {
                if (l.size() == 0) {
                    cout &lt;&lt; &quot;The queue is empty&quot; &lt;&lt; endl;
                } else {
                    cout &lt;&lt; &quot;Popped from left: &quot; &lt;&lt; l.front() &lt;&lt; endl;
                    l.pop_front();
                }
            } else if (a == &quot;popRight&quot;) {
                if (l.size() == 0) {
                    cout &lt;&lt; &quot;The queue is empty&quot; &lt;&lt; endl;
                } else {
                    cout &lt;&lt; &quot;Popped from right: &quot; &lt;&lt; l.back() &lt;&lt; endl;
                    l.pop_back();
                }
            }
        }
    }
    return 0;
}</code></pre>
</div><h3 id="f-题-2" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-2" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=1022" target="_blank" rel="noreferrer">HDU 1022</a></p>
<p>车库是个 stack 命名为 st
火车进入序列（顺序）是 st_in
火车退出序列（顺序）是 st_out</p>
<p>思路很简单，每次循环只要车库有车，就先比较<code>车库最口上的车和 st_out 下一个要求出去的车</code>是不是一样的，如果是一样的就出车（st 出车，st_out 删掉要求出车）。
如果<code>车库没车</code>或者<code>车库有车但是车库最口上的车和 st_out 下一个要求出去的车不一样</code>，就从 st_in 取一辆车。
如果从 st_in 取车的时候发现无车可取（st_in 的 size 为 0），那就退出循环。</p>
<p>退出循环后只有两种可能</p>
<ol>
<li>车库没车，从 st_in 取车也没车。这个时候退出的循环，其实就是车全部按照序列走光了。那就是成功了。这时候 st_out 的 size 一定是 0，st 的 size 也是 0。</li>
<li>车库有车，但是<code>车库有车但是车库最口上的车和 st_out 下一个要求出去的车不一样</code>，从 st_in 取车没车。这个时候退出循环说明车被堵住了，没法按照退出序列把车开出去，那就是失败了。这时候 st_out 的 size 一定不为 0，st 的 size 也不为 0。</li>
</ol>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::s4sdilvwd2w2nc2780jhq::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n_o;
    while (cin &gt;&gt; n_o) {
        deque&lt;int&gt; st_in;
        deque&lt;int&gt; st_out;
        stack&lt;int&gt; st;
        deque&lt;string&gt; operations;
        int n = n_o;

        getchar();  // read space
        while (n &gt; 0) {
            st_in.push_back(getchar());
            n--;
        }

        getchar();  // read space
        n = n_o;
        while (n &gt; 0) {
            st_out.push_back(getchar());
            n--;
        }

        while (true) {
            if (st.size() != 0 &amp;&amp; st.top() == st_out.front()) {
                st.pop();
                st_out.pop_front();
                operations.push_back(&quot;out&quot;);
            } else {
                if (st_in.size() == 0) {
                    break;
                } else {
                    st.push(st_in.front());
                    st_in.pop_front();
                    operations.push_back(&quot;in&quot;);
                }
            }
        }

        if (st.size() == 0) {
            cout &lt;&lt; &quot;Yes.&quot; &lt;&lt; endl;
            for (string s : operations) {
                cout &lt;&lt; s &lt;&lt; endl;
            }
        } else {
            cout &lt;&lt; &quot;No.&quot; &lt;&lt; endl;
        }
        cout &lt;&lt; &quot;FINISH&quot; &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="g-题-2" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-2" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=8&amp;page=show_problem&amp;problem=614" target="_blank" rel="noreferrer">UVA 673</a></p>
<p>这题要注意：需要检查的字符串可能为空</p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::h9tx0klev992sz7po0j2k7::--><code>def a(s):
    st = []
    d = {&quot;(&quot;: &quot;)&quot;, &quot;[&quot;: &quot;]&quot;}

    for c in s:
        if c in &quot;)]&quot;:
            if st and d[st[-1]] == c:
                st.pop()
            else:
                return &quot;No&quot;
        else:
            st.append(c)

    return &quot;No&quot; if st else &quot;Yes&quot;


[print(a(input().strip())) for _ in range(int(input()))]</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::pmr0s9q7l6fedy898fyruj::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

string a(string s) {
    stack&lt;char&gt; l;
    map&lt;char, char&gt; d = {{&#039;(&#039;, &#039;)&#039;}, {&#039;[&#039;, &#039;]&#039;}};

    for (char c : s) {
        if (c == &#039;)&#039; || c == &#039;]&#039;) {
            if (!l.empty() &amp;&amp; d[l.top()] == c) {
                l.pop();
            } else {
                return &quot;No&quot;;
            }
        } else {
            l.push(c);
        }
    }
    if (l.empty()) {
        return &quot;Yes&quot;;
    } else {
        return &quot;No&quot;;
    }
}

int main() {
    int n;
    cin &gt;&gt; n;
    getchar();  // 读取上一行输入数据后输入的回车
    while (n &gt; 0) {
        string s;
        getline(cin, s);  // 用 getline 而不是用 cin 是因为后面的字符串序列可能为空
        cout &lt;&lt; a(s) &lt;&lt; endl;
        n--;
    }
    return 0;
}</code></pre>
</div><h3 id="h-题-2" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-2" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>24.9.22 更新</p>
<p>原题是 The 2024 ICPC Asia East Continent Online Contest (I) 的 F 题</p>
<blockquote>
<p>此题未通过</p>
</blockquote>
<p>这题对于我来说太难，一直超时，跳过</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::6n8rwpugquueatajwd5jzg::--><code>c = int(input())

while c &gt; 0:
    rt = 0
    c -= 1
    n = int(input())
    index_max = n - 1
    l = list(map(int, input().split()))
    for i, e in enumerate(l):
        l_step = 0
        r_step = 0
        l_max_number = e
        r_max_number = e
        for l_number in l[i::-1]:
            if l_number &gt; l_max_number:
                l_max_number = l_number
                l_step += 1
            if l_number &lt; l_max_number:
                break
        for r_number in l[i + 1 :]:
            if r_number &gt; r_max_number:
                r_max_number = r_number
                r_step += 1
            if r_number &lt; r_max_number:
                break
        rt += l_step + r_step
    print(rt)</code></pre>
</div><h3 id="i-题-2" tabindex="-1">I 题 <a class="header-anchor" href="#i-题-2" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://codeforces.com/contest/2013/problem/D" target="_blank" rel="noreferrer">Codeforces 2013D</a></p>
<h3 id="j-题-2" tabindex="-1">J 题 <a class="header-anchor" href="#j-题-2" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新题解</p>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=2034" target="_blank" rel="noreferrer">HDU 2034</a></p>
<p>没啥难度，题目的 A-B 是 $A\cap \complement_UB$ （$A\cap \overline{B}$）</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::pgqjmcr8zgosjbps3mq::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    while (cin &gt;&gt; n) {
        cin &gt;&gt; m;
        vector&lt;int&gt; a, b;

        if (n == 0 and m == 0) {
            return 0;
        }

        int _number;
        while (n &gt; 0) {
            n--;
            cin &gt;&gt; _number;
            a.push_back(_number);
        }
        while (m &gt; 0) {
            m--;
            cin &gt;&gt; _number;
            b.push_back(_number);
        }

        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        bool flag = false;
        for (int number : a) {
            if (!binary_search(b.begin(), b.end(), number)) {
                cout &lt;&lt; number &lt;&lt; &quot; &quot;;
                flag = true;
            }
        }
        if (flag == false) {
            cout &lt;&lt; &quot;NULL&quot;;
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="k-题-2" tabindex="-1">K 题 <a class="header-anchor" href="#k-题-2" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新题解</p>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=1004" target="_blank" rel="noreferrer">HDU 1004</a></p>
<p>在一个字典内统计出现次数，
最后遍历找出出现次数最多的输出即可</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::sjnejw6gv2ej4xk2m07na::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int n;
    string bn;
    while (cin &gt;&gt; n) {
        if (n == 0) {
            return 0;
        }

        map&lt;string, int&gt; m;

        while (n &gt; 0) {
            n--;
            cin &gt;&gt; bn;
            if (m.find(bn) == m.end()) {
                m[bn] = 1;
            } else {
                m[bn] += 1;
            }
        }

        string answer_name;
        int answer_times = 0;
        for (map&lt;string, int&gt;::iterator it = m.begin(); it != m.end(); it++) {
            if (it-&gt;second &gt; answer_times) {
                answer_times = it-&gt;second;
                answer_name = it-&gt;first;
            }
        }

        cout &lt;&lt; answer_name &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="l-题-1" tabindex="-1">L 题 <a class="header-anchor" href="#l-题-1" aria-label="Permalink to “L 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新题解</p>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/1722/C" target="_blank" rel="noreferrer">Codeforces 1722C</a></p>
<p>在一个字典中记录各单词出现次数，
最后再各自统计总分即可</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::wzr0aslrq4nlo6i085kfkm::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n_o;
        cin &gt;&gt; n_o;
        int n0 = n_o, n1 = n_o, n2 = n_o;
        string word0[1000], word1[1000], word2[1000];
        map&lt;string, int&gt; word_times;
        string word;
        while (n0 &gt; 0) {
            n0--;
            cin &gt;&gt; word;
            word0[n0] = word;
            if (word_times.find(word) == word_times.end()) {
                word_times[word] = 1;
            } else {
                word_times[word] += 1;
            }
        }
        while (n1 &gt; 0) {
            n1--;
            cin &gt;&gt; word;
            word1[n1] = word;
            if (word_times.find(word) == word_times.end()) {
                word_times[word] = 1;
            } else {
                word_times[word] += 1;
            }
        }
        while (n2 &gt; 0) {
            n2--;
            cin &gt;&gt; word;
            word2[n2] = word;
            if (word_times.find(word) == word_times.end()) {
                word_times[word] = 1;
            } else {
                word_times[word] += 1;
            }
        }
        int rt0 = 0;
        for (string _word : word0) {
            if (word_times[_word] == 1) {
                rt0 += 3;
            } else if (word_times[_word] == 2) {
                rt0 += 1;
            }
        }

        int rt1 = 0;
        for (string _word : word1) {
            if (word_times[_word] == 1) {
                rt1 += 3;
            } else if (word_times[_word] == 2) {
                rt1 += 1;
            }
        }

        int rt2 = 0;
        for (string _word : word2) {
            if (word_times[_word] == 1) {
                rt2 += 3;
            } else if (word_times[_word] == 2) {
                rt2 += 1;
            }
        }

        printf(&quot;%d %d %d\n&quot;, rt0, rt1, rt2);
    }

    return 0;
}</code></pre>
</div><h3 id="m-题" tabindex="-1">M 题 <a class="header-anchor" href="#m-题" aria-label="Permalink to “M 题”">&#8203;</a></h3>
<p>24.9.22 凌晨更新 TL 代码
24.9.23 晚上更新 AC 代码</p>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/1790/D" target="_blank" rel="noreferrer">Codeforces 1790D</a></p>
<p>题单的制作者今天（24.9.23）给题目加了个提示，在标题里标注这个题需要用字典（map）数据结构。</p>
<p>经过查询和测试后得知字典（map）数据结构遍历时，键（key）是从小到大的，我重新实现了代码。
代码分为两部分，第一部分是将数据读入字典，第二部分（从 <code>int rt = 0;</code> 开始）是数据处理部分。
最后字典存储的键代表这个娃的大小，对应的值表示还有多少个这样的娃没用掉。</p>
<p>数据处理的思路是：</p>
<ol>
<li>遍历字典（根据键从小到大）</li>
<li>当检测到键对应的值大于 0（这里用 <code>while</code> 而不是 <code>if</code>，因为可以有多组套娃从同一个数开始），就召唤另一个迭代器（it_son），然后检查后继能否继续组成更长的套娃。
<ul>
<li>如果后继的键是前面的键 +1 且 键对应的值大于 0，说明可以组成更长的套娃。</li>
</ul>
</li>
<li>如果用了这个娃，就对应值 -1，表示用掉一个。</li>
<li>如果后继不满足组成更长的套娃的要求，那就退出循环并且最后统计结果的变量（rt）+1。</li>
</ol>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::9g6x3x9lw09104a63s283q::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        map&lt;int, int&gt; dict;
        cin &gt;&gt; n;

        while (n &gt; 0) {
            n--;
            int _number;
            cin &gt;&gt; _number;
            dict[_number]++;
        }

        int rt = 0;

        for (auto it = dict.begin(); it != dict.end(); it++) {
            while (it-&gt;second &gt; 0) {
                auto it_son = it;
                it_son++;
                int last_one = it-&gt;first;
                while (it_son-&gt;second &gt; 0 &amp;&amp; it_son-&gt;first - 1 == last_one) {
                    it_son-&gt;second--;
                    last_one = it_son-&gt;first;
                    it_son++;
                }
                rt++;
                it-&gt;second--;
            }
        }

        cout &lt;&lt; rt &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><details><summary>这里折叠是代码是带 debug 的代码，将开头的 `bool debug = 1;` 改为 `bool debug = 0;` 即可 AC</summary>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::onl875njeosb2ra20akipn::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;
bool debug = 1;
#define dbg(x)                                                   \
    if (debug)                                                   \
        cerr &lt;&lt; BRIGHT_CYAN &lt;&lt; #x &lt;&lt; COLOR_RESET &lt;&lt; &quot; = &quot; &lt;&lt; (x) \
             &lt;&lt; NORMAL_FAINT &lt;&lt; COLOR_RESET &lt;&lt; endl;
const string COLOR_RESET = &quot;\033[0m&quot;, BRIGHT_CYAN = &quot;\033[1;36m&quot;,
             NORMAL_FAINT = &quot;\033[0;2m&quot;;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        map&lt;int, int&gt; dict;
        cin &gt;&gt; n;

        while (n &gt; 0) {
            n--;
            int _number;
            cin &gt;&gt; _number;
            dict[_number]++;
        }

        int rt = 0;

        for (auto it = dict.begin(); it != dict.end(); it++) {
            dbg(it-&gt;first);
            dbg(it-&gt;second);
            while (it-&gt;second &gt; 0) {
                auto it_son = it;
                it_son++;
                int last_one = it-&gt;first;
                while (it_son-&gt;second &gt; 0 &amp;&amp; it_son-&gt;first - 1 == last_one) {
                    dbg(it_son-&gt;first);
                    dbg(it_son-&gt;second);
                    it_son-&gt;second--;
                    last_one = it_son-&gt;first;
                    it_son++;
                }
                rt++;
                dbg(rt);
                it-&gt;second--;
            }
        }

        cout &lt;&lt; rt &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div></details>
<details>
<summary>先前 TL 的题解</summary>
<p>题解 Time limit exceeded on test 27</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::c1aqayxeine59hyuexa7um::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        vector&lt;int&gt; v, st, temp_st;
        cin &gt;&gt; n;

        while (n &gt; 0) {
            n--;
            int _number;
            cin &gt;&gt; _number;
            temp_st.push_back(_number);
        }
        sort(temp_st.begin(), temp_st.end());

        if (temp_st.front() == temp_st.back()) {
            cout &lt;&lt; temp_st.size() &lt;&lt; endl;
            continue;
        }

        int rt = 0;
        do {
            v = temp_st;
            temp_st.clear();

            for (int _number : v) {
                if (st.size() != 0) {
                    int _back = st.back();
                    if (_back == _number) {
                        temp_st.push_back(_number);
                    } else if (_back + 1 == _number) {
                        st.push_back(_number);
                    } else {
                        rt++;
                        st.clear();
                        st.push_back(_number);
                    }
                } else {
                    st.push_back(_number);
                }
            }

            if (st.size() != 0) {
                rt++;
                st.clear();
            }

        } while (temp_st.size() != 0);

        cout &lt;&lt; rt &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div></details>
<h3 id="n-题" tabindex="-1">N 题 <a class="header-anchor" href="#n-题" aria-label="Permalink to “N 题”">&#8203;</a></h3>
<p>24.9.22 下午更新 TL 代码
24.9.23 下午更新 AC 代码</p>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/1800/C2" target="_blank" rel="noreferrer">Codeforces 1800C2</a></p>
<p>虽然我不会实现最大堆，但是经过检索找到了一个 <code>priority_queue</code> 容器类，默认实现就是最大堆。我把原本 <code>vector</code>+<code>sort</code> 函数的模式改成 <code>priority_queue</code> 就成功 AC 了。</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::mrxwp1lhtxi30ihbx4fwhp::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        ll rt = 0;
        cin &gt;&gt; n;
        priority_queue&lt;int&gt; st;
        int _number;
        while (n &gt; 0) {
            n--;
            cin &gt;&gt; _number;
            if (_number != 0) {
                st.push(_number);
            } else if (st.size() != 0) {
                rt += st.top();
                st.pop();
            }
        }
        cout &lt;&lt; rt &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="o-题" tabindex="-1">O 题 <a class="header-anchor" href="#o-题" aria-label="Permalink to “O 题”">&#8203;</a></h3>
<p>最基础的 10 转 2 进制</p>
<p>原题链接：<a href="https://acm.hdu.edu.cn/showproblem.php?pid=2051" target="_blank" rel="noreferrer">HDU 2051</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::912srlfskr8jinw2t6emrs::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;

    while (cin &gt;&gt; n) {
        vector&lt;int&gt; v;
        if (n == 0) {
            v.push_back(0);
        }
        while (n &gt; 0) {
            if (n % 2 == 0) {
                v.push_back(0);
                n /= 2;
            } else {
                v.push_back(1);
                n /= 2;
            }
        }

        while (v.size() != 0) {
            cout &lt;&lt; v.back();
            v.pop_back();
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>网上冲浪的时候找到的另一种 Cpp 题解，巧妙的利用了递归，分享一下</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::lt2btcnefpsbyue140aj4u::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;

void D2B(int d) {
    if (d / 2) D2B(d / 2);
    cout &lt;&lt; d % 2;
}

int main() {
    int n;

    while (cin &gt;&gt; n) {
        D2B(n);
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-5-周题单-题解分享-a-c-f-h" tabindex="-1">Hrbust ACM 练习 2024 级第 5 周题单 题解分享 (A-C,F-H) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-5-周题单-题解分享-a-c-f-h" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 5 周题单 题解分享 (A-C,F-H)”">&#8203;</a></h2>
<h3 id="前言-3" tabindex="-1">前言 <a class="header-anchor" href="#前言-3" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/657265" target="_blank" rel="noreferrer">2024 级第 5 周题单 - Virtual Judge (vjudge.net)</a></p>
<h3 id="a-题-3" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-3" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://atcoder.jp/contests/abc339/tasks/abc339_c?lang=en" target="_blank" rel="noreferrer">ABC 339C</a></p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::haexjjdx6iuomtpsqxi8::--><code>from itertools import accumulate

input()
min_number = 0
last_number = 0

for n in accumulate(map(int, input().split())):
    if n &lt; min_number:
        min_number = n
    last_number = n

if min_number &lt; 0:
    min_number = -min_number
    print(min_number + last_number)
else:
    print(last_number)</code></pre>
</div><h3 id="b-题-3" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-3" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P3397" target="_blank" rel="noreferrer">P3397</a></p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::rbapj652gh9dpg7wew6u4t::--><code>from itertools import accumulate


n, m = map(int, input().split())
l = []
for _m in range(n):
    l.append([])
    for _ in range(n + 1):
        l[_m].append(0)

while m &gt; 0:
    m -= 1
    x1, y1, x2, y2 = map(int, input().split())
    for x in range(x1 - 1, x2):
        l[x][y1 - 1] += 1
        l[x][y2] -= 1

for sl in l:
    print(*list(accumulate(sl[:-1])))</code></pre>
</div><h3 id="c-题-3" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-3" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P2280" target="_blank" rel="noreferrer">P2280 [HNOI2003] 激光炸弹 - 洛谷</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::33tweo7oni7dqtarpoeec::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int o[5010][5010];

void add(int x, int y, int v) { o[x][y] += v; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, r, x, y, v;
    cin &gt;&gt; n &gt;&gt; r;
    int max_x = r, max_y = r;

    for (int i = 0; i &lt; n; i++) {
        cin &gt;&gt; x &gt;&gt; y &gt;&gt; v;
        x++;    // x 和 y 索引都加一，避免越界
        y++;
        if (x &gt; max_x) {
            max_x = x;
        }
        if (y &gt; max_y) {
            max_y = y;
        }
        add(x, y, v);
    }
    for (int _x = 1; _x &lt;= max_x; _x++) {
        for (int _y = 1; _y &lt;= max_y; _y++) {
            o[_x][_y] =
                o[_x][_y] + o[_x - 1][_y] + o[_x][_y - 1] - o[_x - 1][_y - 1];
        }
    }
    int rt = 0;
    for (int _x = r; _x &lt;= max_x; _x++) {
        for (int _y = r; _y &lt;= max_y; _y++) {
            rt = max(rt, o[_x][_y] - o[_x - r][_y] - o[_x][_y - r] +
                             o[_x - r][_y - r]);
        }
    }
    cout &lt;&lt; rt;
    return 0;
}</code></pre>
</div><p>Cpp Code 另一种实现</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::6rmzci9tkvso6y8milhps::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int o[5010][5010];

void add(int x, int y, int v) { o[x][y] += v; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, r, x, y, v;
    cin &gt;&gt; n &gt;&gt; r;
    int max_x = r, max_y = r;

    for (int i = 0; i &lt; n; i++) {
        cin &gt;&gt; x &gt;&gt; y &gt;&gt; v;
        if (x &gt; max_x) {
            max_x = x;
        }
        if (y &gt; max_y) {
            max_y = y;
        }
        add(x, y, v);
    }

    // 计算 y=0 这一列上的前缀和
    for (int i = 1; i &lt;= max_x; i++) {
        o[i][0] += o[i - 1][0];
    }
    // 计算 x=0 这一行上的前缀和
    for (int j = 1; j &lt;= max_y; j++) {
        o[0][j] += o[0][j - 1];
    }
    // 从 (1,1) 开始计算前缀和
    for (int _x = 1; _x &lt;= max_x; _x++) {
        for (int _y = 1; _y &lt;= max_y; _y++) {
            o[_x][_y] =
                o[_x][_y] + o[_x - 1][_y] + o[_x][_y - 1] - o[_x - 1][_y - 1];
        }
    }

    int rt = 0;
    // 从 索引 (r-1，r-1) 开始计算矩阵内数字和（索引 0 到 r-1 长度为 r）
    for (int _x = r - 1; _x &lt;= max_x; _x++) {
        for (int _y = r - 1; _y &lt;= max_y; _y++) {
            int v1, v2, v3, v4;
            v1 = o[_x][_y];

            // 越界判定，防止索引小于 0
            if (_x - r &lt; 0) {
                // 说明：负索引前缀和都是 0
                // 举个例子原数组 1,0,2,3
                // 对应前缀和 1,1,3,6
                // 现在问索引 -1 的前缀和
                // 那原数组其实就变成了 0,1,0,2,3
                // 对应前缀和 0,1,1,3,6（对应索引 -1,0,1,2,3）
                v2 = 0;
            } else {
                v2 = o[_x - r][_y];
            }

            if (_y - r &lt; 0) {
                v3 = 0;
            } else {
                v3 = o[_x][_y - r];
            }

            if (_y - r &lt; 0 or _x - r &lt; 0) {
                v4 = 0;
            } else {
                v4 = o[_x - r][_y - r];
            }

            rt = max(rt, v1 - v2 - v3 + v4);
        }
    }
    cout &lt;&lt; rt;
    return 0;
}</code></pre>
</div><h3 id="d-题-3" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-3" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::clrfmq2bhpdsgic7czu0in::--><code></code></pre>
</div><h3 id="e-题-3" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-3" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::cpd1hw23g5huh7e2mjb68::--><code></code></pre>
</div><h3 id="f-题-3" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-3" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://codeforces.com/problemset/problem/670/C" target="_blank" rel="noreferrer">CF670C</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::ejckdg2cewts9nmfh1yx1::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

const long long N = 200000 + 10;
ll scientist_language[N], moive_voice[N], moive_subtitle[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin &gt;&gt; n;                        // n = 科学家的数量
    map&lt;ll, ll&gt; scientist_language;  // language_index -&gt; scientist_number
    for (ll i = 1; i &lt;= n; i++) {
        ll language_index;
        cin &gt;&gt; language_index;
        scientist_language[language_index] += 1;
    }
    ll m;
    cin &gt;&gt; m;  // m = 电影院里的电影数量
    for (ll i = 1; i &lt;= m; i++) {
        ll vocie_language;
        cin &gt;&gt; vocie_language;
        moive_voice[i] = vocie_language;  // index 用 1 到 m
    }
    for (ll i = 1; i &lt;= m; i++) {
        ll subtitle_language;
        cin &gt;&gt; subtitle_language;
        moive_subtitle[i] = subtitle_language;  // index 用 1 到 m
    }

    ll very_satisfied = 0;
    ll almost_satisfied = 0;
    ll movie_index = 1;  //  默认值为 1
    for (ll i = 1; i &lt;= m; i++) {
        ll temp_almost_satisfied = scientist_language[moive_subtitle[i]];
        ll temp_very_satisfied = scientist_language[moive_voice[i]];
        if (temp_very_satisfied &gt; very_satisfied) {
            movie_index = i;
            very_satisfied = temp_very_satisfied;
            // almost_satisfied 也要记得更新，否则会错
            almost_satisfied = temp_almost_satisfied;
        } else if (temp_very_satisfied == very_satisfied &amp;&amp;
                   temp_almost_satisfied &gt; almost_satisfied) {
            movie_index = i;
            almost_satisfied = temp_almost_satisfied;
        }
    }

    cout &lt;&lt; movie_index &lt;&lt; endl;
    return 0;
}</code></pre>
</div><p>Cpp Code 另一种实现</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::b0ivl3l6l6stk9ixkkm60b::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

const long long N = 200000 + 10;
ll scientist_language[N], moive_voice[N], moive_subtitle[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin &gt;&gt; n;                        // n = 科学家的数量
    map&lt;ll, ll&gt; scientist_language;  // language_index -&gt; scientist_number
    for (ll i = 1; i &lt;= n; i++) {
        ll language_index;
        cin &gt;&gt; language_index;
        scientist_language[language_index] += 1;
    }
    ll m;
    cin &gt;&gt; m;  // m = 电影院里的电影数量
    for (ll i = 1; i &lt;= m; i++) {
        ll vocie_language;
        cin &gt;&gt; vocie_language;
        moive_voice[i] = vocie_language;  // index 用 1 到 m
    }
    for (ll i = 1; i &lt;= m; i++) {
        ll subtitle_language;
        cin &gt;&gt; subtitle_language;
        moive_subtitle[i] = subtitle_language;  // index 用 1 到 m
    }

    ll very_satisfied = 0;
    ll movie_index = 1;  //  默认值为 1
    for (ll i = 1; i &lt;= m; i++) {
        ll temp = scientist_language[moive_voice[i]];
        if (temp &gt; very_satisfied) {
            very_satisfied = temp;
            movie_index = i;  // 记录电影编号
        }
    }
    ll almost_satisfied = 0;
    for (ll i = 1; i &lt;= m; i++) {
        ll temp_voice = scientist_language[moive_voice[i]];
        ll temp_subtitle = scientist_language[moive_subtitle[i]];
        if (very_satisfied == temp_voice &amp;&amp; almost_satisfied &lt; temp_subtitle) {
            almost_satisfied = temp_subtitle;
            movie_index = i;
        }
    }

    cout &lt;&lt; movie_index &lt;&lt; endl;
    return 0;
}</code></pre>
</div><h3 id="g-题-3" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-3" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://atcoder.jp/contests/abc014/tasks/abc014_3" target="_blank" rel="noreferrer">ABC 014C</a></p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::ml1maqxgnkyatoog82rr::--><code>from itertools import accumulate

n = int(input())
l = [0] * (1000000 + 2)
while n &gt; 0:
    n -= 1
    a, b = map(int, input().split())
    l[a] += 1
    l[b + 1] -= 1
print(max(accumulate(l)))</code></pre>
</div><h3 id="h-题-3" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-3" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://atcoder.jp/contests/abc035/tasks/abc035_c" target="_blank" rel="noreferrer">ABC 035C</a></p>
<p>试了一下 <a href="https://atcoder.jp/" target="_blank" rel="noreferrer">AtCoder</a>，这个判题机是很奇葩的。之前用 <code>print(rt, end=&quot;&quot;)</code> 会 WA。看了别人的博客才知道这个网站的老题有 bug，在程序输出结束后不进行换行是会 WA 的。新题目已修复。</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::wwnpldvww909p9eeefwezo::--><code>from itertools import accumulate


n, q = map(int, input().split())
l = []
for _ in range(0, n + 2):
    l.append(1)

while q &gt; 0:
    q -= 1
    li, ri = map(int, input().split())
    l[li - 1] *= -1
    l[ri] *= -1
_n = 0
last_one = 0
rt = &quot;&quot;
for i in range(0, n):
    if _n == n:
        break
    if l[i] == -1:  # 和前一个不一样
        if i == 0 or last_one == 0:
            last_one = 1
        else:
            last_one = 0
        rt += str(last_one)
    else:  # 和前一个一样
        rt += str(last_one)
    _n += 1
print(rt)</code></pre>
</div><h2 id="hrbust-acm-编程练习-20240922-题解分享" tabindex="-1">Hrbust ACM 编程练习 20240922 题解分享 <a class="header-anchor" href="#hrbust-acm-编程练习-20240922-题解分享" aria-label="Permalink to “Hrbust ACM 编程练习 20240922 题解分享”">&#8203;</a></h2>
<h3 id="前言-4" tabindex="-1">前言 <a class="header-anchor" href="#前言-4" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="http://acm.hrbust.edu.cn/contests/index.php?act=login&amp;cid=2365" target="_blank" rel="noreferrer">编程练习 20240922 @ Hrbust Online Judge</a></p>
<h3 id="a-题-4" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-4" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p><code>d</code> 的数据类型要用 <code>double</code> 而不是 <code>float</code> ，否则最后计算的答案会有精度损失。</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::bx80yfwkxcq6ob8ytfmnal::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int p, w, s;
        double d = 0;
        cin &gt;&gt; p &gt;&gt; w &gt;&gt; s;
        if (s &lt; 250) {
            d = 0;
        } else if (s &lt; 500) {
            d = 0.02;
        } else if (s &lt; 1000) {
            d = 0.05;
        } else if (s &lt; 2000) {
            d = 0.08;
        } else if (s &lt; 3000) {
            d = 0.1;
        } else {
            d = 0.15;
        }
        cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; 1.0 * p * w * s * (1 - d);
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="b-题-4" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-4" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>打表代码</p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::jeulx1uy0eiuczsz5q0t8::--><code>l = []
for i in range(-9, 9 + 1):
    temp_l = []
    for _ in range(1, 9 + 1):
        temp_l.append(0)
    l.append(temp_l)

for a in range(-9, 9 + 1):
    for n in range(1, 9 + 1):
        sum = 0
        for le in range(1, n + 1):
            sum += int(le * &quot;1&quot;) * a
        l[a + 9][n - 1] = sum
print(l)</code></pre>
</div><p>以上代码输出</p>
<!-- markdownlint-disable MD013 -->
<div class="language-log"><button title="Copy Code" class="copy"></button><span class="lang">log</span><pre><!--::markdown-it-async::jqyt55prc8be9w9nt1e2g6::--><code>[[-9, -108, -1107, -11106, -111105, -1111104, -11111103, -111111102, -1111111101], [-8, -96, -984, -9872, -98760, -987648, -9876536, -98765424, -987654312], [-7, -84, -861, -8638, -86415, -864192, -8641969, -86419746, -864197523], [-6, -72, -738, -7404, -74070, -740736, -7407402, -74074068, -740740734], [-5, -60, -615, -6170, -61725, -617280, -6172835, -61728390, -617283945], [-4, -48, -492, -4936, -49380, -493824, -4938268, -49382712, -493827156], [-3, -36, -369, -3702, -37035, -370368, -3703701, -37037034, -370370367], [-2, -24, -246, -2468, -24690, -246912, -2469134, -24691356, -246913578], [-1, -12, -123, -1234, -12345, -123456, -1234567, -12345678, -123456789], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789], [2, 24, 246, 2468, 24690, 246912, 2469134, 24691356, 246913578], [3, 36, 369, 3702, 37035, 370368, 3703701, 37037034, 370370367], [4, 48, 492, 4936, 49380, 493824, 4938268, 49382712, 493827156], [5, 60, 615, 6170, 61725, 617280, 6172835, 61728390, 617283945], [6, 72, 738, 7404, 74070, 740736, 7407402, 74074068, 740740734], [7, 84, 861, 8638, 86415, 864192, 8641969, 86419746, 864197523], [8, 96, 984, 9872, 98760, 987648, 9876536, 98765424, 987654312], [9, 108, 1107, 11106, 111105, 1111104, 11111103, 111111102, 1111111101]]</code></pre>
</div><!-- markdownlint-enable MD013 -->
<p>用任意文本编辑器将<code>[</code>替换为<code>{</code>，<code>]</code>替换为<code>}</code>即可直接使用</p>
<p>AC 代码</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::3wawvh6447lx2m12fthay::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int ans[][9] = {
    {-9, -108, -1107, -11106, -111105, -1111104, -11111103, -111111102,
     -1111111101},
    {-8, -96, -984, -9872, -98760, -987648, -9876536, -98765424, -987654312},
    {-7, -84, -861, -8638, -86415, -864192, -8641969, -86419746, -864197523},
    {-6, -72, -738, -7404, -74070, -740736, -7407402, -74074068, -740740734},
    {-5, -60, -615, -6170, -61725, -617280, -6172835, -61728390, -617283945},
    {-4, -48, -492, -4936, -49380, -493824, -4938268, -49382712, -493827156},
    {-3, -36, -369, -3702, -37035, -370368, -3703701, -37037034, -370370367},
    {-2, -24, -246, -2468, -24690, -246912, -2469134, -24691356, -246913578},
    {-1, -12, -123, -1234, -12345, -123456, -1234567, -12345678, -123456789},
    {0, 0, 0, 0, 0, 0, 0, 0, 0},
    {1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789},
    {2, 24, 246, 2468, 24690, 246912, 2469134, 24691356, 246913578},
    {3, 36, 369, 3702, 37035, 370368, 3703701, 37037034, 370370367},
    {4, 48, 492, 4936, 49380, 493824, 4938268, 49382712, 493827156},
    {5, 60, 615, 6170, 61725, 617280, 6172835, 61728390, 617283945},
    {6, 72, 738, 7404, 74070, 740736, 7407402, 74074068, 740740734},
    {7, 84, 861, 8638, 86415, 864192, 8641969, 86419746, 864197523},
    {8, 96, 984, 9872, 98760, 987648, 9876536, 98765424, 987654312},
    {9, 108, 1107, 11106, 111105, 1111104, 11111103, 111111102, 1111111101}};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a, n;
        cin &gt;&gt; a &gt;&gt; n;
        cout &lt;&lt; ans[a + 9][n - 1];
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="c-题-4" tabindex="-1">C 题 <a class="header-anchor" href="#c-题-4" aria-label="Permalink to “C 题”">&#8203;</a></h3>
<p>打表代码</p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::q11iyir6lfnb2p4lzmgzg::--><code>for i in range(1000):
    if (i**2) &lt;= 1000000:
        if str(i**2).endswith(str(i)):
            print(i**2, end=&quot;,&quot;)</code></pre>
</div><p>以上代码输出</p>
<div class="language-log"><button title="Copy Code" class="copy"></button><span class="lang">log</span><pre><!--::markdown-it-async::jt3mutfnmwnqs7m41unlgr::--><code>0,1,25,36,625,5776,141376,390625,</code></pre>
</div><p>AC 代码</p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::6rxj5vwa4thcdu6v1npzbh::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int ans[] = {0, 1, 25, 36, 625, 5776, 141376, 390625};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a, b;
        cin &gt;&gt; a &gt;&gt; b;
        bool flag = true;
        for (int number : ans) {
            if (number &lt;= b &amp;&amp; number &gt;= a) {
                // 避免输出多余空格的设计
                if (flag) {
                    cout &lt;&lt; number;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot; &quot; &lt;&lt; number;
                }
            }
        }
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="d-题-4" tabindex="-1">D 题 <a class="header-anchor" href="#d-题-4" aria-label="Permalink to “D 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::tjsix5j1z3bn6ubc7s9aig::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin &gt;&gt; n;
    while (n &gt; 0) {
        n--;
        int a, b;
        cin &gt;&gt; a &gt;&gt; b;
        vector&lt;int&gt; l;
        bool start_flag = true;
        for (int i = a; i &lt;= b; i++) {
            if (i % 3 != 0) {
                if (start_flag) {
                    cout &lt;&lt; i;
                    start_flag = false;
                    continue;
                }
                cout &lt;&lt; &quot; &quot; &lt;&lt; i;
            }
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><h3 id="e-题-4" tabindex="-1">E 题 <a class="header-anchor" href="#e-题-4" aria-label="Permalink to “E 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::lw9ggi393xqg97qhgsw81j::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a;
        cin &gt;&gt; a;
        int max_line = 2 * a - 1;
        for (int i = 1; i &lt;= max_line; i += 2) {
            for (int ii = 0; ii &lt;= ((max_line - i) / 2) - 1; ii++) {
                cout &lt;&lt; &quot; &quot;;
            }
            for (int iii = 0; iii &lt;= i - 1; iii++) {
                cout &lt;&lt; &quot;*&quot;;
            }

            cout &lt;&lt; endl;
        }
        for (int i = max_line; i &gt; 1; i -= 2) {
            for (int ii = (max_line - i) / 2 + 1; ii &gt; 0; ii--) {
                cout &lt;&lt; &quot; &quot;;
            }
            for (int iii = (i - 1) - 1; iii &gt; 0; iii--) {
                cout &lt;&lt; &quot;*&quot;;
            }

            cout &lt;&lt; endl;
        }
    }
    return 0;
}</code></pre>
</div><h3 id="f-题-4" tabindex="-1">F 题 <a class="header-anchor" href="#f-题-4" aria-label="Permalink to “F 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::pmedkjucu2kg0mzmobt7ps::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int a;
        cin &gt;&gt; a;
        int max_line = 2 * a + 1;
        for (int i = 1; i &lt;= max_line; i += 2) {
            int c = (i + 1) / 2;
            for (int ii = 0; ii &lt;= ((max_line - i) / 2) - 1; ii++) {
                cout &lt;&lt; &quot; &quot;;
            }
            bool flag = false;
            for (int iii = 0; iii &lt;= i - 1; iii++) {
                cout &lt;&lt; c;
                if (c &gt; 1) {
                    if (flag) {
                        c++;
                    } else {
                        c--;
                    }
                } else if (c == 1) {
                    c++;
                    flag = true;
                }
            }

            cout &lt;&lt; endl;
        }
        for (int i = max_line; i &gt; 1; i -= 2) {
            int c = (i - 2 + 1) / 2;
            for (int ii = (max_line - i) / 2 + 1; ii &gt; 0; ii--) {
                cout &lt;&lt; &quot; &quot;;
            }
            bool flag = false;
            for (int iii = i - 2; iii &gt; 0; iii--) {
                cout &lt;&lt; c;
                if (c &gt; 1) {
                    if (flag) {
                        c++;
                    } else {
                        c--;
                    }
                } else if (c == 1) {
                    c++;
                    flag = true;
                }
            }

            cout &lt;&lt; endl;
        }
    }
    return 0;
}</code></pre>
</div><h3 id="g-题-4" tabindex="-1">G 题 <a class="header-anchor" href="#g-题-4" aria-label="Permalink to “G 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::2ssihvchdjum6yc94jan6f::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int o_a, o_b, max_number = 0, ans_x = 0, ans_y = 0, a = 0;
        cin &gt;&gt; o_a &gt;&gt; o_b;
        while (a &lt; o_a) {
            a++;
            int b = 0;
            while (b &lt; o_b) {
                b++;
                int temp;
                cin &gt;&gt; temp;
                if (temp &gt; max_number) {
                    max_number = temp;
                    ans_x = a;
                    ans_y = b;
                }
            }
        }
        cout &lt;&lt; ans_x &lt;&lt; &quot; &quot; &lt;&lt; ans_y &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="h-题-4" tabindex="-1">H 题 <a class="header-anchor" href="#h-题-4" aria-label="Permalink to “H 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::tzf3hltqx498m4ssjxvh8::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t, n, x;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        cin &gt;&gt; n &gt;&gt; x;
        t--;
        bool flag = true, flag2 = true;
        while (n &gt; 0) {
            n--;
            int temp;
            cin &gt;&gt; temp;
            if (temp &gt;= x &amp;&amp; flag2) {
                if (flag) {
                    cout &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; temp;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot; &quot; &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; temp;
                }
                flag2 = false;
            } else {
                if (flag) {
                    cout &lt;&lt; temp;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot; &quot; &lt;&lt; temp;
                }
            }
        }
        if (flag2) {
            cout &lt;&lt; &quot; &quot; &lt;&lt; x;
        }
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="i-题-3" tabindex="-1">I 题 <a class="header-anchor" href="#i-题-3" aria-label="Permalink to “I 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::grirrfxbxqrt348713lu6o::--><code>#include &lt;bits/stdc++.h&gt;
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    cin.ignore();
    while (t &gt; 0) {
        t--;
        string s;
        int letter = 0, digit = 0, space = 0, others = 0;

        getline(cin, s);
        for (char c : s) {
            if (isupper(c) or islower(c)) {
                letter++;
            } else if (isdigit(c)) {
                digit++;
            } else if (isspace(c)) {
                space++;
            } else {
                others++;
            }
        }

        printf(&quot;%d %d %d %d\n&quot;, letter, space, digit, others);
    }
    return 0;
}</code></pre>
</div><h3 id="j-题-3" tabindex="-1">J 题 <a class="header-anchor" href="#j-题-3" aria-label="Permalink to “J 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::36v7uannjjpltrpmufee88::--><code>#include &lt;bits/stdc++.h&gt;
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    cin.ignore();
    while (t &gt; 0) {
        t--;
        string s;
        int word = 0;
        bool last_one = false;

        getline(cin, s);
        bool flag = false;
        for (char c : s) {
            if (isspace(c)) {
                last_one = flag;
                flag = false;
            } else {  //  非空
                last_one = flag;
                flag = true;
            }
            if (flag &amp;&amp; last_one == false) {
                word++;
            }
        }

        printf(&quot;%d\n&quot;, word);
    }
    return 0;
}</code></pre>
</div><h3 id="k-题-3" tabindex="-1">K 题 <a class="header-anchor" href="#k-题-3" aria-label="Permalink to “K 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::va5vlz4kgs8w1xbrr9tsk::--><code>#include &lt;bits/stdc++.h&gt;
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    cin.ignore();
    while (t &gt; 0) {
        t--;
        string s;
        int line = 3;
        int upper = 0, lower = 0, digit = 0, space = 0, others = 0;

        while (line &gt; 0) {
            line--;
            getline(cin, s);
            for (char c : s) {
                if (isupper(c)) {
                    upper++;
                } else if (islower(c)) {
                    lower++;
                } else if (isdigit(c)) {
                    digit++;
                } else if (isspace(c)) {
                    space++;
                } else {
                    others++;
                }
            }
        }
        printf(&quot;%d %d %d %d %d\n&quot;, upper, lower, digit, space, others);
    }
    return 0;
}</code></pre>
</div><h3 id="l-题-2" tabindex="-1">L 题 <a class="header-anchor" href="#l-题-2" aria-label="Permalink to “L 题”">&#8203;</a></h3>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::qtms61me0cnb7rtd7sa6so::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        cin &gt;&gt; n;
        int ret = 0;
        while (n &gt;= 5) {
            n /= 5;
            ret += n;
        }
        cout &lt;&lt; ret &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h3 id="m-题-1" tabindex="-1">M 题 <a class="header-anchor" href="#m-题-1" aria-label="Permalink to “M 题”">&#8203;</a></h3>
<p><a href="https://oi-wiki.org/misc/josephus/" target="_blank" rel="noreferrer">约瑟夫问题 - OI Wiki (oi-wiki.org)</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::lpysi800z9fo7dket3perg::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int josephus(int n, int k) {
    int res = 0;
    for (int i = 2; i &lt;= n; ++i) {
        res = (res + k) % i;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int M, K;
        cin &gt;&gt; M &gt;&gt; K;
        // 约瑟夫环公式使用示例
        int i;
        for (i = 1; i &lt;= M; i++) {
            if (josephus(M, i) + 1 == K) {
                cout &lt;&lt; i &lt;&lt; &quot;\n&quot;;
                break;
            };
        }
        if (i &gt; M) {
            cout &lt;&lt; &quot;No Solution!\n&quot;;
        }
    }

    return 0;
}</code></pre>
</div><h3 id="n-题-1" tabindex="-1">N 题 <a class="header-anchor" href="#n-题-1" aria-label="Permalink to “N 题”">&#8203;</a></h3>
<p>一开始 AC 的代码，因为之前的代码 TL 了
Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::vazhxgniqxs3ymz6nl09hs::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

vector&lt;int&gt; prime = {
    2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,  43,
    47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101, 103, 107,
    109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
    191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
    269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
    353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
    439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
    523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
    617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
    709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
    811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
    907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        ll n;
        cin &gt;&gt; n;
        cout &lt;&lt; n &lt;&lt; &quot;=&quot;;
        bool flag = true;
        for (int p_number : prime) {
            while (n % p_number == 0) {
                n /= p_number;
                if (flag) {
                    cout &lt;&lt; p_number;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot;*&quot; &lt;&lt; p_number;
                }
            }
        }
        int divisor = 1021;
        while (n &gt; 1) {
            while (n % divisor == 0) {
                if (flag) {
                    cout &lt;&lt; divisor;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot;*&quot; &lt;&lt; divisor;
                }
                n /= divisor;
                prime.push_back(divisor);
                divisor = prime.back();
            }
            divisor++;
        }
        cout &lt;&lt; endl;
    }

    return 0;
}</code></pre>
</div><p>事实是我想多了，这样也能 AC。之前 TL 的代码找不到了，也要成未解之谜了。
Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::45skbxvuymmf78tzmtf3::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin &gt;&gt; t;
    while (t &gt; 0) {
        t--;
        int n;
        cin &gt;&gt; n;
        cout &lt;&lt; n &lt;&lt; &quot;=&quot;;
        bool flag = true;
        int divisor = 2;
        while (n &gt; 1) {
            while (n % divisor == 0) {
                if (flag) {
                    cout &lt;&lt; divisor;
                    flag = false;
                } else {
                    cout &lt;&lt; &quot;*&quot; &lt;&lt; divisor;
                }
                n /= divisor;
                divisor = 2;
            }
            divisor++;
        }
        cout &lt;&lt; endl;
    }
    return 0;
}</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-9-周题单-题解分享-a-b" tabindex="-1">Hrbust ACM 练习 2024 级第 9 周题单 题解分享 (A-B) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-9-周题单-题解分享-a-b" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 9 周题单 题解分享 (A-B)”">&#8203;</a></h2>
<h3 id="前言-5" tabindex="-1">前言 <a class="header-anchor" href="#前言-5" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/666642" target="_blank" rel="noreferrer">2024 级第九周题单 (DFS &amp;&amp; BFS) - Virtual Judge (vjudge.net)</a></p>
<h3 id="a-题-5" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-5" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/B3622" target="_blank" rel="noreferrer">B3622 枚举子集（递归实现指数型枚举） - 洛谷</a></p>
<p>Python Code</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::iyzvrbi3or0cy7ju0i4v0s::--><code>arr = [0] * 11

def dfs(site):
    if site == n+1:
        print(&quot;&quot;.join(arr[1:site]))
    if site &lt;= n:
        for j in [&quot;N&quot;,&quot;Y&quot;]:
            arr[site] = j
            dfs(site+1)

n = int(input())
dfs(1)</code></pre>
</div><p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::ulbtil3790j0mfmkexj513n::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
typedef long long ll;

int m;
char arr[11],s[2]={&#039;N&#039;,&#039;Y&#039;};

void dfs(int cur) {
    if (cur == m+1) {
        for (int j = 1; j &lt;= cur - 1; ++j) printf(&quot;%c&quot;, arr[j]);
        printf(&quot;\n&quot;);
    }
    if (cur &lt;= m) {
        for (int j = 0; j &lt;= 1; ++j) {
            arr[cur] = s[j];
            dfs(cur + 1);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    scanf(&quot;%d&quot;, &amp;m);
    dfs(1);
    return 0;
}</code></pre>
</div><h3 id="b-题-5" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-5" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P1706" target="_blank" rel="noreferrer">P1706 全排列问题 - 洛谷</a>、<a href="https://www.jisuanke.com/problem/T1735" target="_blank" rel="noreferrer">T1735 全排列问题 - 计蒜客</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::zcc31f3ubbcpehcdsfwih::--><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
#define endl &#039;\n&#039;
#define ios ios::sync_with_stdio(false), cin.tie(nullptr)

const int N = 10;  // 1 based
int n;
int a[N];    // 记录已经使用的数字构成的序列
bool st[N];  // 记录数字是否使用

void dfs(int cur) {
    if (cur == n + 1) {
        for (int i = 1; i &lt;= n; ++i) {
            cout &lt;&lt; std::setw(5) &lt;&lt; a[i];
        }
        cout &lt;&lt; endl;
        return;
    }
    for (int i = 1; i &lt;= n; ++i) {
        if (st[i]) {
            continue;
        }
        a[cur] = i;
        st[i] = true;
        dfs(cur + 1);
        a[cur] = 0;
        st[i] = false;
    }
}
void solve() {
    cin &gt;&gt; n;
    dfs(1);
}

int main() {
    ios;
    int T = 1;
    while (T--) {
        solve();
    }
}</code></pre>
</div><p>Python Code 洛谷能过，计蒜客上最后一个点会超时，可能是 Python 递归效率低导致的</p>
<div class="language-python"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre><!--::markdown-it-async::bbowcxanc0qinl7yg0oglp::--><code>N = 10
a = [0] * N
st = [False] * N


def dfs(cur):
    if cur == n + 1:
        print(&quot;&quot;.join(f&quot;{x:5}&quot; for x in a[1 : n + 1]))

    for i in range(1, n + 1):
        if st[i]:
            continue
        a[cur] = i
        st[i] = True
        dfs(cur + 1)
        a[cur] = 0
        st[i] = False


n = int(input())
dfs(1)</code></pre>
</div><h2 id="hrbust-acm-练习-2024-级第-11-周题单-题解分享-a-b" tabindex="-1">Hrbust ACM 练习 2024 级第 11 周题单 题解分享 (A-B) <a class="header-anchor" href="#hrbust-acm-练习-2024-级第-11-周题单-题解分享-a-b" aria-label="Permalink to “Hrbust ACM 练习 2024 级第 11 周题单 题解分享 (A-B)”">&#8203;</a></h2>
<h3 id="前言-6" tabindex="-1">前言 <a class="header-anchor" href="#前言-6" aria-label="Permalink to “前言”">&#8203;</a></h3>
<p>题单链接：<a href="https://vjudge.net/contest/670756" target="_blank" rel="noreferrer">2024 第 11 周题单 图论基础 - Virtual Judge</a></p>
<h3 id="a-题-6" tabindex="-1">A 题 <a class="header-anchor" href="#a-题-6" aria-label="Permalink to “A 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P5318" target="_blank" rel="noreferrer">P5318【深基 18.例 3】查找文献 - 洛谷</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::4td1subdw66v5lxzg6t1w::--><code>#include &lt;bits/stdc++.h&gt;

using namespace std;

int n, m;
vector&lt;bool&gt; vis;
vector&lt;int&gt; max_node;
vector&lt;vector&lt;int&gt;&gt; adj;

void dfs(int u) {
    if (vis[u]) {
        return;
    }

    vis[u] = true;
    cout &lt;&lt; u &lt;&lt; &quot; &quot;;
    for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
        dfs(adj[u][i]);
    }
    return;
}

// 另一种 dfs 实现
// void dfs(int u) {
//     vis[u] = true;
//     cout &lt;&lt; u &lt;&lt; &quot; &quot;;
//     for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
//         int next_node = adj[u][i];
//         if (!vis[next_node]) {
//             dfs(next_node);
//         }
//     }
//     return;
// }

void bfs(int u) {
    queue&lt;int&gt; q;

    q.push(u);
    vis[u] = true;
    cout &lt;&lt; u &lt;&lt; &quot; &quot;;

    while (!q.empty()) {
        u = q.front();
        q.pop();
        for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
            if (!vis[adj[u][i]]) {
                q.push(adj[u][i]);
                vis[adj[u][i]] = true;
                cout &lt;&lt; adj[u][i] &lt;&lt; &quot; &quot;;
            }
        }
    }
}

int main() {
    cin &gt;&gt; n &gt;&gt; m;

    adj.resize(n + 1);

    for (int i = 1; i &lt;= m; ++i) {
        int u, v;
        cin &gt;&gt; u &gt;&gt; v;
        adj[u].push_back(v);
    }

    for (int i = 1; i &lt;= n; i++) {
        sort(adj[i].begin(), adj[i].end());
    }

    vis.assign(n + 1, false);
    for (int i = 1; i &lt;= 2; i++) {
        dfs(i);
    }

    cout &lt;&lt; &#039;\n&#039;;

    vis.assign(n + 1, false);
    bfs(1);

    return 0;
}</code></pre>
</div><h3 id="b-题-6" tabindex="-1">B 题 <a class="header-anchor" href="#b-题-6" aria-label="Permalink to “B 题”">&#8203;</a></h3>
<p>原题链接：<a href="https://www.luogu.com.cn/problem/P3916" target="_blank" rel="noreferrer">P3916 图的遍历 - 洛谷</a></p>
<p>Cpp Code</p>
<div class="language-cpp"><button title="Copy Code" class="copy"></button><span class="lang">cpp</span><pre><!--::markdown-it-async::rhdhn7i67jsi1lfnm8he::--><code>#include &lt;bits/stdc++.h&gt;

using namespace std;

int n, m;
vector&lt;bool&gt; vis;
vector&lt;int&gt; max_node;
vector&lt;vector&lt;int&gt;&gt; adj;

void dfs(int u, int start_node) {
    if (vis[u]) {  // 要是访问过，一定是被比较大的 start_node 访问的
        return;
    }
    vis[u] = true;
    max_node[u] = start_node;
    for (int i = 0; i &lt; (int)adj[u].size(); ++i) {
        dfs(adj[u][i], start_node);
    }
    return;
}

int main() {
    cin &gt;&gt; n &gt;&gt; m;

    vis.assign(n + 1, false);
    adj.resize(n + 1);
    max_node.resize(n + 1);

    for (int i = 1; i &lt;= m; ++i) {
        int u, v;
        cin &gt;&gt; u &gt;&gt; v;
        adj[v].push_back(u);
    }

    for (int i = n; i &gt;= 1; i--) {
        dfs(i, i);
    }
    for (int i = 1; i &lt;= n; ++i) {
        cout &lt;&lt; max_node[i] &lt;&lt; &quot; &quot;;
    }

    return 0;
}</code></pre>
</div>]]></content:encoded>
            <author>HowieHz</author>
        </item>
        <item>
            <title><![CDATA[UltraIso 9.7.6.3829 注册码]]></title>
            <link>https://howiehz.top/misc/posts/junk/ultraiso-license-key</link>
            <guid isPermaLink="false">https://howiehz.top/misc/posts/junk/ultraiso-license-key</guid>
            <pubDate>Mon, 29 Jan 2024 02:16:10 GMT</pubDate>
            <description><![CDATA[UltraIso 9.7.6.3829 注册码
::: details 迁移自主站
- 链接：`/archives/1706494568081`
- 分类：`资源图谱 
- 标签：`系统-Window]]></description>
            <content:encoded><![CDATA[<h1 id="ultraiso-9-7-6-3829-注册码" tabindex="-1">UltraIso 9.7.6.3829 注册码 <a class="header-anchor" href="#ultraiso-9-7-6-3829-注册码" aria-label="Permalink to “UltraIso 9.7.6.3829 注册码”">&#8203;</a></h1>
<details  class="details custom-block"><summary>迁移自主站</summary>
<ul>
<li>链接：<code>/archives/1706494568081</code></li>
<li>分类：<code>资源图谱 &gt; 工具集 &gt; 工具评测&amp;分享</code></li>
<li>标签：<code>系统-Windows</code> <code>转载重排</code> <code>简体中文</code> <code>2024</code></li>
<li>发布时间 2024-01-29T10:16:10+08:00</li>
<li>访问量：162</li>
<li>评论量：0</li>
<li>移动原因：单纯的复制粘贴，内容有一点点价值。</li>
</ul>
</details>
<p>迁移自本地<code>Obsidian</code>库，原记录于 2023-06-20T22:11:39+08:00。</p>
<p>原帖：<a href="https://www.aihao.cc/thread-86086-1-1.html" target="_blank" rel="noreferrer">原帖</a>由
<a href="https://www.aihao.cc/space-uid-75734.html" target="_blank" rel="noreferrer">xiangnan</a> 发布于 2022-11-23 10:42:23</p>
<p>9.7.6.3829 版官网下载地址：<a href="https://www.ezbsystems.com/ultraiso/" target="_blank" rel="noreferrer">https://www.ezbsystems.com/ultraiso/</a></p>
<h2 id="注册码" tabindex="-1">注册码 <a class="header-anchor" href="#注册码" aria-label="Permalink to “注册码”">&#8203;</a></h2>
<p>两个版本不通用，请注意</p>
<h3 id="中文版" tabindex="-1">中文版 <a class="header-anchor" href="#中文版" aria-label="Permalink to “中文版”">&#8203;</a></h3>
<p>name:</p>
<div class="language-plaintext"><button title="Copy Code" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::nx92hy3ioddb750k5jbmdu::--><code>王涛</code></pre>
</div><p>serial:</p>
<div class="language-plaintext"><button title="Copy Code" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::6pz39cbgmp6cr0gebh9xwl::--><code>7C81-1689-4046-626F</code></pre>
</div><h3 id="多国语言-pe-版" tabindex="-1">多国语言 PE 版 <a class="header-anchor" href="#多国语言-pe-版" aria-label="Permalink to “多国语言 PE 版”">&#8203;</a></h3>
<p>name:</p>
<div class="language-plaintext"><button title="Copy Code" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::351jbchto9f2mmgzl7n1yy::--><code>ru-board</code></pre>
</div><p>serial:</p>
<div class="language-plaintext"><button title="Copy Code" class="copy"></button><span class="lang">plaintext</span><pre><!--::markdown-it-async::bl2kwvf6ybum4ucjhh1bk::--><code>8F5C-FB35-D4BD-943D</code></pre>
</div>]]></content:encoded>
            <author>HowieHz</author>
        </item>
    </channel>
</rss>