<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"><channel><title>PYM博客</title><link>https://pym.plus</link><atom:link href="https://pym.plus/rss.xml" rel="self" type="application/rss+xml"/><description>欢迎！Welcome!</description><generator>Halo v2.25.2</generator><language>zh-cn</language><image><url>https://pan.pym.plus/f/kOtY/PYMbk.png</url><title>PYM博客</title><link>https://pym.plus</link></image><lastBuildDate>Tue, 23 Jun 2026 18:59:53 GMT</lastBuildDate><item><title><![CDATA[2026年了，电脑病毒真是防不胜防，3个好用的杀毒软件推荐（亲身经历）]]></title><link>https://pym.plus/archives/1781618969307</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=2026%E5%B9%B4%E4%BA%86%EF%BC%8C%E7%94%B5%E8%84%91%E7%97%85%E6%AF%92%E7%9C%9F%E6%98%AF%E9%98%B2%E4%B8%8D%E8%83%9C%E9%98%B2%EF%BC%8C3%E4%B8%AA%E5%A5%BD%E7%94%A8%E7%9A%84%E6%9D%80%E6%AF%92%E8%BD%AF%E4%BB%B6%E6%8E%A8%E8%8D%90%EF%BC%88%E4%BA%B2%E8%BA%AB%E7%BB%8F%E5%8E%86%EF%BC%89&amp;url=/archives/1781618969307" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E5%89%8D%E8%A8%80">前言</h1>
<p style="">最近发现电脑越来越卡了，感觉像是有病毒在后台一样，但是某60安全卫士没有给出反馈，随即卸载了360，后面也尝试了火某杀毒，效果也不理想，根本找不出病毒，然后就一一尝试了以下 3 个杀毒软件，都挺不错的，成功把我电脑里流氓软件和病毒给赶走了。</p>
<p style="">可能会有人觉得杀毒软件没必要付钱，免费够用了，但是在AI下的2026年，免费杀毒软件正在“疏忽泄露“你的各种信息，比如密码，聊天信息，重要文件等等，病毒更新越来越快，各种手段层出不穷，你觉得你不访问陌生链接，不下载不明软件就安全了？不不不，最近的很多泄露事件都表明了这是行不通的，这个钱还是应该付的。</p>
<p style="">声明：不是广告推广，均为实测，在200个病毒样本中测试，这200个病毒样本均是测试博主之前用过的某60，火某，某管家未能防御成功的。</p>
<h1 style="" id="1.-eset">1. ESET</h1>
<p style=""><a href="https://www.eset.com/cn/for-home/free-trial/" target="_blank" rel="">下载链接</a></p>
<p style=""><strong>200个病毒检测出来179个，检测用时7分34秒，剩余的运行全部防御成功</strong></p>
<ul>
 <li>
  <p style="">免费30天</p>
 </li>
 <li>
  <p style="">占用资源非常少</p>
 </li>
 <li>
  <p style="">几乎不打扰的体验</p>
 </li>
 <li>
  <p style="">强大的静态和动态防护能力</p>
 </li>
</ul>
<p style="">这个杀毒软件很好用，付费版功能多了反而用不上，最重要是它是 3 个中对电脑占用资源最少的一个，如果你不想影响电脑性能又想不让电脑中毒这个绝对值得用一用！</p>
<h1 style="" id="2.-norton">2. Norton</h1>
<p style=""><strong>200个病毒检测出来184个，检测用时4分21秒，剩余的运行全部防御成功</strong></p>
<p style=""><a href="https://cn.norton.com/" target="_blank" rel="">下载链接</a></p>
<ul>
 <li>
  <p style="">付费，一年最便宜36人民币</p>
 </li>
 <li>
  <p style="">静态和动态防护都很强，网上评价也很高</p>
 </li>
 <li>
  <p style="">占用资源较少</p>
 </li>
 <li>
  <p style="">功能很全面，而且不怎么多余</p>
 </li>
</ul>
<p style="">博主目前就用的这个，价格很实惠，卸载某60后用这个杀毒软件在电脑开机期间就检测出了2个木马病毒，是可以让你安心用电脑的杀软</p>
<h1 style="" id="3.-bitdefender">3. BitDefender</h1>
<p style=""><strong>200个病毒检测出来191个，检测用时2分16秒，剩余的运行全部防御成功</strong></p>
<p style=""><a href="https://www.bitdefender.com/zh-hk/consumer/free-antivirus" target="_blank" rel="">下载链接</a></p>
<ul>
 <li>
  <p style="">3个中能力最强最稳的一个</p>
 </li>
 <li>
  <p style="">有可以一直用的免费版</p>
 </li>
 <li>
  <p style="">占用资源较多，对电脑性能有较明显影响</p>
 </li>
</ul>
<p style="">这个能力很强，特别稳，如果你不担心杀软的性能影响可以用这个，且这个有永久免费的版本是可以一直用的。</p>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1781618969307</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E5%25B1%258F%25E5%25B9%2595%25E6%2588%25AA%25E5%259B%25BE%25202026-06-16%2520223856.png&amp;size=m" type="image/jpeg" length="269764"/><category>电脑</category><category>病毒</category><category>病毒</category><category>生活</category><pubDate>Tue, 16 Jun 2026 14:43:05 GMT</pubDate></item><item><title><![CDATA[本站已更换 Cloudflare 至 EdgeOne]]></title><link>https://pym.plus/archives/1781092872249</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E6%9C%AC%E7%AB%99%E5%B7%B2%E6%9B%B4%E6%8D%A2%20Cloudflare%20%E8%87%B3%20EdgeOne&amp;url=/archives/1781092872249" width="1" height="1" alt="" style="opacity:0;">
<p style="">Cloudflare的免费版对于国内的访问在没有优选的情况下确实有些慢了，一番折腾后我还是换了 EdgeOne 做了CDN，访问速度显著提升了，以下是测速结果，较之前使用 Cloudflare 时还是有提升的，加载最慢从 20 秒到了 6 秒左右，挺不错的。不过 EdgeOne 的缓存配置可能会有一些问题，如果大家发现了有关的问题，欢迎在评论区反馈~</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-gzNq.png&amp;size=m" alt="image-gzNq.png" width="2578px">
</figure>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1781092872249</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-gzNq.png&amp;size=m" type="image/jpeg" length="91196"/><category>Edgeone</category><category>CDN</category><category>Cloudflare</category><pubDate>Wed, 10 Jun 2026 12:08:44 GMT</pubDate></item><item><title><![CDATA[Claude Opus 4.8来了！不再是比聪明，而是更能干活，敢于认错，变得诚实了！]]></title><link>https://pym.plus/archives/1780066871034</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Claude%20Opus%204.8%E6%9D%A5%E4%BA%86%EF%BC%81%E4%B8%8D%E5%86%8D%E6%98%AF%E6%AF%94%E8%81%AA%E6%98%8E%EF%BC%8C%E8%80%8C%E6%98%AF%E6%9B%B4%E8%83%BD%E5%B9%B2%E6%B4%BB%EF%BC%8C%E6%95%A2%E4%BA%8E%E8%AE%A4%E9%94%99%EF%BC%8C%E5%8F%98%E5%BE%97%E8%AF%9A%E5%AE%9E%E4%BA%86%EF%BC%81&amp;url=/archives/1780066871034" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E7%94%B1%E6%9D%A5">由来</h1>
<p style="">2026年5月28日，Anthropic 在他们的官网发布了一篇文章，如下</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-vJqm.png&amp;size=m" width="2003px">
</figure>
<p style="">官方说的话翻译过来就是，Claude Opus 4.8 在 Opus 4.7 基础上升级，判断力更强，更能诚实反馈自己的进展，也能比上一代更长时间独立工作，而且价格不变。</p>
<p style="">这句话看着没什么，但是其实隐含很多。</p>
<p style="">Claude Opus 4.7发布时就遭人诟病，能力是强了，但是变得懒惰了。</p>
<p style=""><code>judgment、honesty、work independently。</code></p>
<p style=""><code>判断力、诚实度、独立工作能力。</code></p>
<p style="">这三个词充分表明了Claude未来的技术路线，不再是普通对对话的模型，而是可以真正交付工作和任务的“可靠AI同事”。</p>
<h1 style="" id="%E4%B8%80%E3%80%81%E5%88%A4%E6%96%AD%E5%8A%9B">一、判断力</h1>
<p style="">AI 现在不缺回答，缺的是回答的可信度真的会完全相信一个 AI 吗，把他用于自己的工作上，你真的相信他给的建议、代码吗？Claude就在做这样一件事，让 AI 变得更加<strong>长期</strong>可信。</p>
<p style="">这次的更新实现一件很难的事情：<strong>AI知道什么时候该继续，什么时候该停下，什么时候该反驳你，什么时候该承认方案不靠谱了。</strong></p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-Vlci.png&amp;size=m" alt="image-Vlci.png" width="1883px">
</figure>
<h1 style="" id="%E4%BA%8C%E3%80%81%E8%AF%9A%E5%AE%9E%E5%BA%A6">二、诚实度</h1>
<p style="">假设你是1个长期使用AI开发项目的人，你会仔细查看AI编写的项目的实际效果来和你的要求对比吗，你会尝试找到Bug然后让AI修复吗，我想大多数人是会的，因为人们不敢完全相信AI，这是会造成灾难性后果的，且有实际例子的。</p>
<p style="">之前的AI不会告诉你，我这个没完成，哪里可能还有问题，但是Opus 4.8现在会了</p>
<p style="">所以 Claude Opus 4.8 强调“more honesty about its own progress”</p>
<p style="">一个能诚实告诉你“我还没完成”“这里不确定”“这个测试失败了”“我需要重新检查”的模型，比一个永远自信满满的模型更可靠。</p>
<p style="">下面这张图是官方测试，得分越高的模型，越容易欺诈和配合欺骗，可以看到Opus 4.8是明显低于Opus4.7的</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-IzOE.png&amp;size=m" alt="image-IzOE.png" width="3840px">
</figure>
<h1 style="" id="%E4%B8%89%E3%80%81%E6%9B%B4%E9%95%BF%E6%97%B6%E9%97%B4%E7%8B%AC%E7%AB%8B%E5%B7%A5%E4%BD%9C">三、<strong>更长时间独立工作</strong></h1>
<p style="">这是一句富有重量的话，这意味着什么，对开发者、产品经理、研究员、内容团队来说，这个AI开始工作后，不会隔几分钟就来问你 “接下来该怎么做”</p>
<p style="">他从按要求，完成要求，继续接要求，变成了接任务然后完成交付。</p>
<p style="">对于Claude Code、Codex这类工具来说，Claude Opus 4.8的更新让他能在此类工具中胜任更加复杂的任务，并做得更出色！</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-JJMX.png&amp;size=m" width="2600px">
</figure>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1780066871034</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-yWUO.png&amp;size=m" type="image/jpeg" length="230068"/><category>新闻咨询</category><category>AI</category><pubDate>Fri, 29 May 2026 15:48:09 GMT</pubDate></item><item><title><![CDATA[Note.ms在线简洁匿名记事本，如何修改/0页面]]></title><link>https://pym.plus/archives/1779801830942</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Note.ms%E5%9C%A8%E7%BA%BF%E7%AE%80%E6%B4%81%E5%8C%BF%E5%90%8D%E8%AE%B0%E4%BA%8B%E6%9C%AC%EF%BC%8C%E5%A6%82%E4%BD%95%E4%BF%AE%E6%94%B9%2F0%E9%A1%B5%E9%9D%A2&amp;url=/archives/1779801830942" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E6%96%B9%E6%B3%95">方法</h1>
<p style="">水一期文章，大家应该都知道</p>
<p style="">访问 <a href="https://note.ms/0?" target="_blank" rel="">https://note.ms/0?</a> 就可以修改文章了</p>
<p style=""></p>
<h1 style="" id="%E5%8E%9F%E7%90%86">原理</h1>
<p style=""><a href="https://pym.plus/Note.ms" target="_blank" rel="">Note.</a><a href="https://note.ms" target="_blank" rel="">ms</a>对于后端页面的修改处理逻辑是这样的：</p>
<p style="">判断是不是特殊页面/0，是则不让修改，不是就通过</p>
<p style="">但是/0?中的?本身就是网址的特殊符号，因为判断逻辑是判断0?与0不完全匹配，Note.ms就会放行修改，但是0?实际和0是差不多等价的，所以实际是修改了/0页面。</p>]]></description><guid isPermaLink="false">/archives/1779801830942</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E5%25B1%258F%25E5%25B9%2595%25E6%2588%25AA%25E5%259B%25BE%25202026-05-26%2520212755.png&amp;size=m" type="image/jpeg" length="26974"/><category>网站</category><pubDate>Tue, 26 May 2026 13:29:00 GMT</pubDate></item><item><title><![CDATA[解禁了？RTX 5090 PRO6000上架京东自营店]]></title><link>https://pym.plus/archives/1779078508113</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E8%A7%A3%E7%A6%81%E4%BA%86%EF%BC%9FRTX%205090%20PRO6000%E4%B8%8A%E6%9E%B6%E4%BA%AC%E4%B8%9C%E8%87%AA%E8%90%A5%E5%BA%97&amp;url=/archives/1779078508113" width="1" height="1" alt="" style="opacity:0;">
<p style="">在特朗普访华结束后，最近逛京东发现可以买 <code>RTX 5090</code> 和 <code>RTX PRO 6000</code> 了？</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-PVjD.png&amp;size=m">
</figure>
<p style="">难道是解禁了吗？但是这个价格相比官网有些高了，去英伟达官网看，可以发现官网并没有更新</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-FKvo.png&amp;size=m" alt="image-FKvo.png" width="2879px">
</figure>
<p style="">但是根据我查资料了解到，H200解禁了，那么理论上RTX5090也会解禁。可能是细节还在谈。这次访华双方谈妥了很多东西，所以才又爽快的下了200架波音订单。今天看发布的公告，后续还有更多双方解禁和降低关税。</p>]]></description><guid isPermaLink="false">/archives/1779078508113</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F0083578578ef805b.jpg.avif&amp;size=m" type="image/jpeg" length="241610"/><category>硬件</category><category>AI</category><pubDate>Mon, 18 May 2026 04:39:13 GMT</pubDate></item><item><title><![CDATA[用工具轻松的给Frpc配置SSL证书，穿透Http与Https流量，开启强制Https跳转]]></title><link>https://pym.plus/archives/1778245501495</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E7%94%A8%E5%B7%A5%E5%85%B7%E8%BD%BB%E6%9D%BE%E7%9A%84%E7%BB%99Frpc%E9%85%8D%E7%BD%AESSL%E8%AF%81%E4%B9%A6%EF%BC%8C%E7%A9%BF%E9%80%8FHttp%E4%B8%8EHttps%E6%B5%81%E9%87%8F%EF%BC%8C%E5%BC%80%E5%90%AF%E5%BC%BA%E5%88%B6Https%E8%B7%B3%E8%BD%AC&amp;url=/archives/1778245501495" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E4%B8%80%E3%80%81%E5%B7%A5%E5%85%B7%E4%BB%8B%E7%BB%8D">一、工具介绍</h1>
<p style="">博主这里已经把这个做成了一个在线工具，进入输入你的配置就可以直接简单界面化的配置给Frpc配置SSL证书（Chmlfrp基于标准的Frp客户端，理论上可以通用），其中证书的文件路径为你的证书文件在本地存放的路径。</p>
<hyperlink-card target="_blank" href="https://pym.plus/upload/chmlfrp_ssl.html" theme="small" style="margin-top: 0.75em; margin-bottom: 0;" custom-title="Frp SSL配置生成器" custom-description="Frp客户端通用，界面化简单配置"><a href="https://pym.plus/upload/chmlfrp_ssl.html" target="_blank">https://pym.plus/upload/chmlfrp_ssl.html</a></hyperlink-card>
<h1 style="" id="%E4%BA%8C%E3%80%81%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95">二、使用方法</h1>
<h2 style="" id="1.%E8%BE%93%E5%85%A5%E9%85%8D%E7%BD%AE">1.输入配置</h2>
<p style="">这里的配置以示例配置来演示，输入配置，点击解析配置按钮。</p>
<p style="">可以把每条隧道单独拆开放入列表中，单价可以查看详细信息，你可以选择勾选哪些来进行配置。
 <br></p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-cOOS.png&amp;size=m" width="791px">
</figure>
<h2 style="" id="2.-%E9%85%8D%E7%BD%AE%E8%AF%81%E4%B9%A6">2. 配置证书</h2>
<p style="">你可以选择通配符证书或者单独的证书</p>
<p style="">这里的证书位置输入你本地的证书存放的绝对路径（完整路径），如果是windows就要带上哪个盘，linux就不用。</p>
<p style="">然后在列表里面看看你需要给哪些网站开启强制Https跳转</p>
<div data-type="gallery" data-group-size="2" data-layout="auto" data-gap="8">
 <div style="display: grid; gap: 8px;">
  <div data-type="gallery-group" style="display: flex; flex-direction: row; justify-content: center; gap: 8px;">
   <div style="flex: 0.9912060301507538 1 0%;" data-aspect-ratio="0.9912060301507538">
    <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fpym.plus%2Fupload%2Fimage-bsKJ.png&amp;size=m" data-type="gallery-image" style="width: 100%; height: 100%; margin: 0; object-fit: cover;">
   </div>
   <div style="flex: 1.0049627791563276 1 0%;" data-aspect-ratio="1.0049627791563276">
    <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fpym.plus%2Fupload%2Fimage-SOug.png&amp;size=m" data-type="gallery-image" style="width: 100%; height: 100%; margin: 0; object-fit: cover;">
   </div>
  </div>
 </div>
</div>
<h2 style="" id="3.-%E7%94%9F%E6%88%90%E9%85%8D%E7%BD%AE">3. 生成配置</h2>
<p style="">所有完成后点一下步就自动生成出来了，复制粘贴到 <code>frpc.ini</code> 就可以直接使用，快去试试吧！</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-onRN.png&amp;size=m">
</figure>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1778245501495</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-05-08%2520211144.png&amp;size=m" type="image/jpeg" length="36864"/><category>内网穿透</category><category>服务器</category><pubDate>Fri, 8 May 2026 13:20:38 GMT</pubDate></item><item><title><![CDATA[「POJ1740」A New Stone Game SG函数与博弈论题解]]></title><link>https://pym.plus/archives/1777859225483</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E3%80%8CPOJ1740%E3%80%8DA%20New%20Stone%20Game%20SG%E5%87%BD%E6%95%B0%E4%B8%8E%E5%8D%9A%E5%BC%88%E8%AE%BA%E9%A2%98%E8%A7%A3&amp;url=/archives/1777859225483" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E9%A2%98%E7%9B%AE%E5%A4%A7%E6%84%8F">题目大意</h1>
<p style="">有若干堆石子，每一次需要从一堆石子中拿走一些，然后如果愿意的话，再从这堆石子中拿一些分给其它任意堆。不能操作的人就输了。</p>
<p style="">同时，石子只能移到非空堆，一旦某堆变为 0，它就无法继续操作了。</p>
<h1 style="" id="%E9%A2%98%E7%9B%AE%E5%88%86%E6%9E%90">题目分析</h1>
<h2 style="" id="%E4%B8%80%E3%80%81%E6%B8%B8%E6%88%8F%E8%A7%84%E5%88%99">一、游戏规则</h2>
<p style="">每次操作分两步：</p>
<ol>
 <li>
  <p style="line-height: 1.7"><strong>移除</strong>：从某堆中拿走至少 1 个石子</p>
 </li>
 <li>
  <p style="line-height: 1.7"><strong>分配</strong>（可选）：将该堆<strong>剩余的</strong>石子任意分配到其他<strong>仍有石子</strong>的堆中</p>
 </li>
</ol>
<p style="line-height: 1.7">关键约束：石子<strong>只能移到非空堆</strong>，一旦某堆变为 0，它就没法操作了</p>
<h2 style="" id="%E4%BA%8C%E3%80%81%E4%BB%8E%E5%B0%8F%E8%A7%84%E6%A8%A1%E5%BC%80%E5%A7%8B%E5%88%86%E6%9E%90">二、<strong>从小规模开始分析</strong></h2>
<h4 style="" id="n-%3D-1%EF%BC%88%E5%8D%95%E5%A0%86%EF%BC%89"><strong>n = 1（单堆）</strong></h4>
<p style="line-height: 1.7">无法分配（没有别的非空堆），退化为了普通取石子游戏。操作者可取走 1~全部。</p>
<p style="line-height: 1.7">SG 值就是石子数：<strong>SG(x) = x</strong>。当 x &gt; 0 时 SG ≠ 0，先手必胜。</p>
<h4 style="" id="n-%3D-2%EF%BC%88%E4%B8%A4%E5%A0%86%EF%BC%89"><strong>n = 2（两堆）</strong></h4>
<p style="line-height: 1.7">从这个分析里面我们可以推导出解题的关键：</p>
<p style="line-height: 1.7">如果<strong>两堆相等 (a, a)</strong>：后手采用<strong>对称策略</strong>——无论先手对哪堆做什么（移除 r 个、移 m 个到另一堆），后手在另一堆执行完全相同操作。只要两堆相等，后手总能维持相等，直到把先手逼入 (1,1)，最终先手必败。因此 <strong>SG(a, a) = 0，是</strong>必败态。</p>
<p style="line-height: 1.7">如果<strong>两堆不等 (a, b)，a &lt; b</strong>：先手只需从较大堆移除 (b−a) 个，不分配，状态变为 (a, a)——把 必败态 丢给后手。因此 <strong>SG(a, b) ≠ 0，是 必胜态。</strong></p>
<h2 style="" id="%E4%B8%89%E3%80%81sg-%E5%87%BD%E6%95%B0%E8%A1%A8%E6%A0%BC%EF%BC%88n-%3D-2%EF%BC%89">三、SG 函数表格（n = 2）</h2>
<p style="line-height: 1.7">我们来手动推导小值的 SG 值，设 a ≤ b（?是懒得算了）：</p>
<div style="overflow-x: auto; overflow-y: hidden;">
 <table style="width: 700px">
  <colgroup>
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 100px">
  </colgroup>
  <tbody>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px;">
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>a \ b</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>1</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>2</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>3</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>4</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>5</strong></p>
    </th>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">0</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">1</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">2</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">3</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">4</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">5</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>1</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">3</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">4</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">5</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">6</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>2</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">1</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">?</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">?</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>3</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">?</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">?</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>4</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">?</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>5</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">–</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>0</strong></p>
    </td>
   </tr>
  </tbody>
 </table>
</div>
<blockquote>
 <p style="line-height: 1.7"><strong><em>示例：SG(1,2) 的可达 SG 集合 = {SG(0,2)=2, SG(1,1)=0, SG(2,0)=2, SG(1,0)=1} = {0,1,2} → mex = 3
    <br>SG(2,3) 的可达 SG 集合 = {SG(1,3)=4, SG(0,4)=4, SG(0,3)=3, SG(2,2)=0, SG(3,1)=4, SG(4,0)=4, SG(2,1)=3, SG(3,0)=3, SG(2,0)=2} = {0,2,3,4} → mex = 1</em></strong></p>
</blockquote>
<p style="line-height: 1.7"><strong>由此我们可以发现一个规律</strong>：对角线全为 0（比败态），其余非零（必胜态）。</p>
<h2 style="" id="%E5%9B%9B%E3%80%81%E6%8E%A8%E5%B9%BF%E5%88%B0%E4%BB%BB%E6%84%8F-n">四、推广到任意 n</h2>
<p style=""><strong>定理（必败态的条件）</strong>：</p>
<blockquote>
 <p style="line-height: 1.7"><strong><em>先手必败 ⇔ n 为偶数，且将所有石子堆排序后，可以两两配对相等
    <br>（即 a₁ = a₂, a₃ = a₄, …, aₙ₋₁ = aₙ）</em></strong></p>
</blockquote>
<p style="line-height: 1.7"><strong>证明概要</strong>：</p>
<div style="overflow-x: auto; overflow-y: hidden;">
 <table style="width: 861px">
  <colgroup>
   <col style="width: 100px">
   <col style="width: 761px">
  </colgroup>
  <tbody>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px;">
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>局面类型</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="761" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>策略</strong></p>
    </th>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>奇数堆</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="761" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">先手选最多的堆，将其搬空并分配石子，使剩余偶数堆两两配对，丢给后手一个必败态</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>偶数堆但不全配对</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="761" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">先手选最多的堆，将其削减到与最少堆相等，用差值去补齐其他未配对堆，同样构造必败态</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>偶数堆全配对</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="761" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">先手无论怎么操作都必然破坏配对，后手可恢复配对，最终先手耗尽</p>
    </td>
   </tr>
  </tbody>
 </table>
</div>
<h2 style="" id="%E4%BA%94%E3%80%81sg-%E5%80%BC%E8%A7%84%E5%BE%8B%E6%80%BB%E7%BB%93">五、SG 值规律总结</h2>
<div style="overflow-x: auto; overflow-y: hidden;">
 <table style="width: 439px">
  <colgroup>
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 100px">
   <col style="width: 139px">
  </colgroup>
  <tbody>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px;">
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>n 的奇偶</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>配对情况</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>SG</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="139" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; font-weight: 600; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>胜负</strong></p>
    </th>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">奇数</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">—</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">≠ 0</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="139" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">Alice 胜</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-block-end: thin solid rgba(30, 136, 229, 0.12) !important; border-bottom-width: 1px; border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">偶数</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">不能两两配对</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">≠ 0</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="139" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">Alice 胜</p>
    </td>
   </tr>
   <tr style="background-repeat: no-repeat; box-sizing: inherit; padding: 0px; margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); border-color: rgb(203, 213, 225);">
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">偶数</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">能两两配对</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style=""><strong>= 0</strong></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="139" style="background-repeat: no-repeat; box-sizing: inherit; padding: calc(0.571429em); margin: 0px; scrollbar-width: thin; scrollbar-color: rgba(60, 150, 202, 0.72) rgba(60, 150, 202, 0.08); text-align: left; white-space: normal; overflow-wrap: break-word; word-break: normal;">
     <p style="">Bob 胜</p>
    </td>
   </tr>
  </tbody>
 </table>
</div>
<h2 style="" id="%E5%85%AD%E3%80%81%E7%AE%97%E6%B3%95%E5%AE%9E%E7%8E%B0%E6%80%9D%E8%B7%AF">六、算法实现思路</h2>
<p style="">然后根据上面的规律我们可以得出这个正解思路：</p>
<pre><code>1. 读入 n
2. 读入 n 个石子数，存入数组 a[]
3. 对 a 排序
4. 如果 n 是奇数 → 输出 1（Alice 胜）
5. 如果 n 是偶数：
     检查是否所有 a[2i-1] == a[2i]（i=1..n/2）
     若全等 → 输出 0（Bob 胜）
     否则   → 输出 1（Alice 胜）
</code></pre>
<h1 style="" id="ac%E4%BB%A3%E7%A0%81">AC代码</h1>
<pre><code class="language-cpp">#include &lt;bits/stdc++.h&gt;
#define ll long long
#define qwq ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 20;
int n;
int a[N];
int main() {
	qwq;
	while (cin &gt;&gt; n &amp;&amp; n) {
		for (int i = 1; i &lt;= n; ++i) cin &gt;&gt; a[i];
		if (n % 2) cout &lt;&lt; "1\n";
		else {
			int cnt = 0;
			for (int i = 1; i &lt;= n; ++i) {
				if (a[i] == -114514) {
					cnt++;
					continue;
				}
				for (int j = 1; j &lt;= n; ++j) {
					if (i == j || a[j] == -114514) continue;
					if (a[i] == a[j]) {
						cnt++;
						a[i] = a[j]= -114514;
						break;
					}
				}
			}
			if (cnt == n) cout &lt;&lt; "0\n";
			else cout &lt;&lt; "1\n";
		}
	}
	return 0;
}</code></pre>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1777859225483</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fpoj-front.png&amp;size=m" type="image/jpeg" length="49024"/><category>OI</category><category>洛谷</category><category>C++</category><category>题解</category><pubDate>Mon, 4 May 2026 02:02:56 GMT</pubDate></item><item><title><![CDATA[Deepseek V4发布了！综合能力比肩顶级闭源模型！]]></title><link>https://pym.plus/archives/1777034414538-ITIcswtI</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Deepseek%20V4%E5%8F%91%E5%B8%83%E4%BA%86%EF%BC%81%E7%BB%BC%E5%90%88%E8%83%BD%E5%8A%9B%E6%AF%94%E8%82%A9%E9%A1%B6%E7%BA%A7%E9%97%AD%E6%BA%90%E6%A8%A1%E5%9E%8B%EF%BC%81&amp;url=/archives/1777034414538-ITIcswtI" width="1" height="1" alt="" style="opacity:0;">
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px">就在今天，DeepSeek 全新一代模型 V4 系列正式开源，并迅速冲上 Hugging Face 模型榜单首位。伴随模型开放，一份详尽的技术报告也同步公开，完整披露了该系列在硬件适配、架构改造、训练策略等环节的核心要点。无论从能力指标还是工程效率上看，这都是一次相当激进的迭代。</span></p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-pVDx.png&amp;size=m" alt="image-pVDx.png" width="960px">
</figure>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px">与以往不同的是，V4 的跃升并不只是“更强了”。它首次把百万 token 上下文作为默认能力交付给社区，同时把单 token 推理的计算量降到 V3.2 版本的 27%，KV 缓存仅为原来的十分之一。这意味着，超长文本处理不再只是实验室里的演示，而是开始走向实用、低成本。</span></p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-fEzM.png&amp;size=m" alt="image-fEzM.png" width="524px">
</figure>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px">硬件层面，DeepSeek 这次做了一个“跨生态”的全面适配——从训练到推理，整套流程已完整运行在华为昇腾 NPU 之上。同时，自研的细粒度专家并行方案 MegaMoE，把通信和计算交织成一条流水线，在英伟达 GPU 和昇腾 NPU 上分别实现了 1.50 到 1.73 倍的加速，延迟敏感场景下甚至可接近翻倍。其 CUDA 实现 MegaMoE2 也已开源，成为 DeepGEMM 工具包的一部分。</span></p>
<p style=""></p>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px">为了让碎片化的计算变得紧凑，团队用 TileLang 把大量零散的小算子融合成大型内核，调用开销从百微秒级骤降到 1 微秒以内，并借助 Z3 形式化验证器确保每次计算在任意批次位置下都给出完全一致的结果。这种“比特级可复现”的设计，对大型模型调试来说几乎是一种保命机制。此外，FP4 量化被部署在 MoE 专家权重和压缩稀疏注意力的 QK 路径上，让长上下文下的注意力分数计算进一步提速。</span></p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-bcZb.png&amp;size=m" width="1080px">
</figure>
<p style="">架构改动是这次长文本效率突破的关键。V4 仍然沿用 MoE 结构和多 token 预测，但注意力部分彻底重构，将压缩稀疏注意力与另一种高压缩稠密注意力组合成“混合注意力”，在保证信息利用的同时大幅缩减计算和存储开销。同时，残差连接被替换为“流形约束超连接”，以增强表达力，训练端则引入 Muon 优化器，收敛更快且更稳定。推理时，KV 缓存可部分下沉至磁盘，使得极长上下文的部署不会直接撑爆内存。</p>
<p style="">预训练数据的总量超过 32 万亿 token，并首度引入了“样本级注意力掩码”机制。网页数据经过严格过滤，剔除批量生成和模板化的低质内容；数学、编程仍是核心，中期还加入智能体数据；多语言语料扩充了各个文化中的长尾知识，而长文档部分则优先收录论文和技术报告。在这些基础上，V4-Flash 基础模型虽参数更少，却在世界知识和长上下文等任务中超越了 V3.2 基础模型；V4-Pro 基础版则几乎在所有基准上刷新了 DeepSeek 的记录。</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-CRss.png&amp;size=m" width="1080px">
</figure>
<p style="">后训练阶段的路线也出现了重要转变。先前的混合强化学习阶段被完全移除，取而代之的是“基于策略的蒸馏”。具体做法是，先为每个目标领域分别训练一个专家模型，经过监督微调和 GRPO 强化学习后，得到一群各有所长的“专才”。接下来，统一的学生模型开始自己采样并答题，过程中十多位专家老师在完整词表维度上通过逆向 KL 损失进行 logit 级对齐，以此实现专长的融合。这种全词表蒸馏让梯度更稳定，训练曲线也更容易控制。</p>
<p style="">与蒸馏策略相配套的，还有对长窗口场景下推理记录的精细管理。当模型处于工具调用环境中时，所有思考轨迹会跨轮次完整保留，让智能体在长时间任务中能够保持连贯的推理链；而在普通对话下，则仍会清除上一轮的推理内容，维持上下文的简洁。</p>
<p style="">同时Deepseek V4模型也<span style="color: rgb(28, 30, 33); font-family: system-ui, -apple-system, &quot;Segoe UI&quot;, Roboto, Ubuntu, Cantarell, &quot;Noto Sans&quot;, sans-serif, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px">针对 Claude Code 、OpenClaw、OpenCode、CodeBuddy 等主流的 Agent 产品进行了适配和优化，在代码任务、文档生成任务等方面表现均有提升。</span></p>
<p style="">评测数据上，DeepSeek V4-Pro-Max 在知识、推理和代码能力上全线提升，综合表现已可对标 GPT-5.4、Claude Opus 4.6 等顶级闭源模型。其推理得分超过 GPT-5.2 和 Gemini 3.0 Pro，知识项略低于 Gemini 3.1 Pro。智能体能力与 Kimi K2.6、GLM-5.1 等领先开源模型持平，长上下文测试在学术基准上甚至超过了 Gemini 3.1 Pro。V4-Flash-Max 则在更低成本下提供了不俗的推理表现，展现出极高的性价比，在部分任务上接近 Pro 版本的水平。</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-TxVW.png&amp;size=m">
</figure>
<p style="">同时值得注意的是，这次Deepseek V4更新后仍然保持与ChatGPT、Claude等模型相对比非常便宜的定价。</p>
<p style="">其快速版本输入仅每百万Tokens 1元，输出仅每百万Tokens 2元，相较于ChatGPT，Claude等顶尖版本的模型，定价便宜了几十至数百元人民币。</p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-XJfL.png&amp;size=m" alt="image-XJfL.png" width="461px">
</figure>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px">但是也有技术报告坦诚指出，目前的架构仍偏复杂，Anticipatory Routing 和 SwiGLU Clamping 等稳定性机制的内在机理还有待进一步厘清。后续工作方向包括简化结构、提升训练稳定性、向更多稀疏化方向探索、缩短长上下文推理延迟，以及增强多轮智能体和多模态能力等。</span></p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-DTsS.png&amp;size=m" alt="image-DTsS.png" width="1080px">
</figure>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Oxygen, Ubuntu, Cantarell, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, sans-serif; font-size: 16px">整体来讲，开源的DeepSeek V4 把超长上下文的效率推到新高度，其综合能力极为强大，再一次拉近开源模型与闭源模型的距离。同时这次Deepseek将V4模型分为多个版本，如flash、pro、max、base等版本，可能也是转向商业化的又一步。</span></p>]]></description><guid isPermaLink="false">/archives/1777034414538-ITIcswtI</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E5%25B1%258F%25E5%25B9%2595%25E6%2588%25AA%25E5%259B%25BE%25202026-04-24%2520204213.png&amp;size=m" type="image/jpeg" length="130848"/><category>Deepseek</category><category>新闻咨询</category><category>AI</category><pubDate>Fri, 24 Apr 2026 13:01:19 GMT</pubDate></item><item><title><![CDATA[国内就可以使用的免费SuperGrok，无需登录无需排队，完全公益免费！]]></title><link>https://pym.plus/archives/1775871009005</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E5%9B%BD%E5%86%85%E5%B0%B1%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E7%9A%84%E5%85%8D%E8%B4%B9SuperGrok%EF%BC%8C%E6%97%A0%E9%9C%80%E7%99%BB%E5%BD%95%E6%97%A0%E9%9C%80%E6%8E%92%E9%98%9F%EF%BC%8C%E5%AE%8C%E5%85%A8%E5%85%AC%E7%9B%8A%E5%85%8D%E8%B4%B9%EF%BC%81&amp;url=/archives/1775871009005" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E5%85%AC%E7%9B%8A%E7%AB%99%E4%BB%8B%E7%BB%8D">公益站介绍</h1>
<p style=""><a href="https://grok.dairoot.cn/admin" target="_blank" rel="">传送门链接</a></p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-iZMI.png&amp;size=m" alt="image-iZMI.png" width="951px">
</figure>
<p style="">这是一个公益站点，目前里面有3个免费的SuperGrok账号，直接点击就能进入使用</p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-bnni.png&amp;size=m" width="873px">
</figure>
<p style="">因为这个站点是完全免费的公益站，只能靠广告盈利来添加SuperGrok账号，所以说如果你是很喜欢广告建议自行添加屏蔽广告插件，本文不介绍屏蔽广告的方法。</p>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1775871009005</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-iZMI.png&amp;size=m" type="image/jpeg" length="18139"/><category>AI</category><pubDate>Sat, 11 Apr 2026 01:35:18 GMT</pubDate></item><item><title><![CDATA[保姆级干货：在AI时代薅羊毛，如何获得大量免费的AI API？学完这个你的小龙虾就不缺粮食了！]]></title><link>https://pym.plus/archives/1775866381964</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E4%BF%9D%E5%A7%86%E7%BA%A7%E5%B9%B2%E8%B4%A7%EF%BC%9A%E5%9C%A8AI%E6%97%B6%E4%BB%A3%E8%96%85%E7%BE%8A%E6%AF%9B%EF%BC%8C%E5%A6%82%E4%BD%95%E8%8E%B7%E5%BE%97%E5%A4%A7%E9%87%8F%E5%85%8D%E8%B4%B9%E7%9A%84AI%20API%EF%BC%9F%E5%AD%A6%E5%AE%8C%E8%BF%99%E4%B8%AA%E4%BD%A0%E7%9A%84%E5%B0%8F%E9%BE%99%E8%99%BE%E5%B0%B1%E4%B8%8D%E7%BC%BA%E7%B2%AE%E9%A3%9F%E4%BA%86%EF%BC%81&url=/archives/1775866381964" width="1" height="1" alt="" style="opacity:0;" /><p style="">本文不会推荐使用速度较慢，安全性较弱的API，都是可以国内使用的，全是干货，作者自己也在使用的！</p><h1 style="" id="1.-aihubmix%EF%BC%88%E6%8E%A8%E7%90%86%E6%97%B6%E4%BB%A3%EF%BC%89">1. AIHubMix（推理时代）</h1><p style=""><a href="https://console.aihubmix.com/sign-up?aff=JZRe" target="_blank" rel="">官网链接</a></p><p style="">在推理时代点击右上角的注册账号后，使用邮箱完成注册，随后打开<a href="https://aihubmix.com/models?aff=JZRe" target="_blank" rel="">模型广场</a>，标签选择 <code>免费</code>，可以看到有很多可以免费调用的大模型，这个列表设置还会随着时间而更新大模型。</p><figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-wIZP.png"></figure><p style="">然后进入<a href="https://console.aihubmix.com/token" target="_blank" rel="">密钥页面</a>点击 <code>创建Key</code> ，点开高级设置，模型范围里面可以设置能使用哪些模型，建议设置限制只能使用免费模型，参考示例（如图）：</p><figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-pntY.png" width="438px"></figure><p style="">然后你就可以使用这个免费的API了！OpenAI格式调用地址为 <code>https://aihubmix.com/v1</code></p><h1 style="" id="2.-modelscope%EF%BC%88%E9%AD%94%E6%90%AD%E7%A4%BE%E5%8C%BA%EF%BC%89">2. ModelScope（魔搭社区）</h1><p style=""><a href="https://www.modelscope.cn/models" target="_blank" rel="">官网链接</a></p><p style="">进入后使用手机号注册账号，然后点击进入<a href="https://www.modelscope.cn/models?filter=inference_type&amp;page=1&amp;tabKey=task" target="_blank" rel="">模型库</a>，在 <code>支持体验</code> -&gt; <code>勾选推理 API-Inference</code> 然后看到的这些模型才是可以通过API免费调用。</p><figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-bKsI.png" width="843px"></figure><p style="">需要注意这些虽然是完全免费的，但是有如下限制</p><figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-ImSP.png" width="815px"></figure><p style="">全部完成后就可以进行API调用，在模型页勾选<code>API-Inference</code> 后随便选择一个模型，进入看到这个，点击查看代码范例，里面会有你的API直接复制就可以使用所有免费模型了，OpenAI格式调用地址为 <code>https://api-inference.modelscope.cn/v1</code></p><figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-wGqC.png"></figure><h1 style="" id="3.-openrouter">3. OpenRouter</h1><p style=""><a href="https://openrouter.ai/" target="_blank" rel="">官网链接</a></p><p style="">每天提供50次免费调用；</p><p style="">但你充值10 credits，也就是10刀，就有每天1000次的调用次数。充值后的credits，也可以用于其他收费模型的调用。</p><p style="">有需求的可以充个10credits，提升调用次数。</p><p style="">免费模型可以进入模型库搜索Free如 <code>https://openrouter.ai/models?q=free</code> 里面都是可以免费使用的模型。</p><figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-QEqI.png" width="890px"></figure><p style="">进入到 <code>https://openrouter.ai/workspaces/default/keys</code> 里面创建一个API设置<span style="background-color: rgb(252, 252, 253); color: rgb(113, 113, 122); font-family: Inter, &quot;Inter Fallback&quot;, ui-sans-serif, system-ui, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;; font-size: 14px"><strong>Credit limit (optional) </strong></span>为 0 就可以全免费调用了，到量后也不会花钱。</p><p style="">OpenAI格式调用地址为 <code>https://openrouter.ai/api/v1</code></p><h1 style="" id="4.-bigmodel%EF%BC%88%E6%99%BA%E8%B0%B1-ai%EF%BC%89">4. BigModel（智谱 AI）</h1><p style=""><a href="我正在智谱大模型开放平台 BigModel.cn上打造AI应用，智谱新一代旗舰模型GLM-5已上线， 在推理、代码、智能体综合能力达到开源模型 SOTA 水平，通过我的邀请链接注册即可获得 2000万Tokens 大礼包，期待和你一起在BigModel上畅享卓越模型能力；链接：https://www.bigmodel.cn/invite?icode=y2qhlaaXhGqG41KAlkgnsnHEaazDlIZGj9HxftzTbt4%3D" target="_blank" rel="">官网链接</a></p><p style="">手机号注册账号，实名验证后可以调用。</p><p style="">目前可以免费调用的模型有（覆盖视觉理解，深度思考，文本和图片生成）</p><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-cnCW.png" width="462px"></figure><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-UwSV.png"></figure><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-Pacp.png" width="969px"></figure><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-tTzk.png" width="446px"></figure><p style="">还送一些3个月的资源包，可以用用</p><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-smsU.png" width="1126px"></figure><p style="">OpenAI格式调用地址为 <code>https://open.bigmodel.cn/api/paas/v4/</code></p><h1 style="" id="5.-grok%E5%85%AC%E7%9B%8A%E7%AB%99">5. Grok公益站</h1><p style=""><a href="https://grok.dairoot.cn/admin" target="_blank" rel="">链接</a></p><p style="">最后附上一个宝藏公益站，有 <code>SuperGrok账号</code> 且不用等陆排队就可以使用，除了广告有点多，可以安装一些浏览器插件解决</p><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-iZMI.png" width="951px"></figure><p style="">且支持API使用，目前我体验过发现可以使用 <code>Grok4</code> 且还未发现有什么总量限制，还是很不错的</p><figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image"><img src="/upload/image-nsuj.png" width="955px"></figure><h1 style="" id="%E7%BB%93%E5%B0%BE">结尾</h1><p style="">感谢你能读完这篇文章，大家如果有什么新的薅羊毛的方法可以分享在评论区，作者看到后也会不定期更新这篇文章，或者写一篇新的文章的！</p><p style=""><a href="https://aihubmix.com/?aff=JZRe" target="_blank" rel="">官网链接推理时代</a></p>]]></description><guid isPermaLink="false">/archives/1775866381964</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-wIZP.png&amp;size=m" type="image/jpeg" length="100721"/><category>AI</category><pubDate>Sat, 11 Apr 2026 01:22:37 GMT</pubDate></item><item><title><![CDATA[Deepseek-V4要来了的预兆？Deepseek专家模式低调上新！Deepseek首次引入模式分层！]]></title><link>https://pym.plus/archives/1775647416143</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Deepseek-V4%E8%A6%81%E6%9D%A5%E4%BA%86%E7%9A%84%E9%A2%84%E5%85%86%EF%BC%9FDeepseek%E4%B8%93%E5%AE%B6%E6%A8%A1%E5%BC%8F%E4%BD%8E%E8%B0%83%E4%B8%8A%E6%96%B0%EF%BC%81Deepseek%E9%A6%96%E6%AC%A1%E5%BC%95%E5%85%A5%E6%A8%A1%E5%BC%8F%E5%88%86%E5%B1%82%EF%BC%81&amp;url=/archives/1775647416143" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E5%89%8D%E8%A8%80">前言</h1>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(25, 25, 25); font-family: &quot;PingFang SC&quot;, Arial, 微软雅黑, 宋体, simsun, sans-serif; font-size: 16px">4月8日的凌晨，Deepseek在没有任何官方公告的情况下，上新了网页版的专家模式</span></p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-04-08%2520192328.png&amp;size=m" alt="批注 2026-04-08 192328.png" width="818px">
</figure>
<p style="">日常小问题使用快速模式和专家模式的区别不大，但是在写代码，数学问题，<span style="background-color: rgb(255, 255, 255); color: rgb(25, 25, 25); font-family: &quot;PingFang SC&quot;, Arial, 微软雅黑, 宋体, simsun, sans-serif; font-size: 16px">物理问题等等上面，专家模式会明显优于快速模式，同时思考时间和逻辑严谨性也要高于快速模式。</span></p>
<p style=""></p>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(25, 25, 25); font-family: &quot;PingFang SC&quot;, Arial, 微软雅黑, 宋体, simsun, sans-serif; font-size: 16px">同时，灰度测试用户界面还出现了第三个选项“视觉模式”，不过这一模式并未出现在本次所有人的更新中。</span></p>
<p style=""></p>
<p style=""><span style="background-color: rgb(255, 255, 255); color: rgb(25, 25, 25); font-family: &quot;PingFang SC&quot;, Arial, 微软雅黑, 宋体, simsun, sans-serif; font-size: 16px">这次升级来得并不突然。3月30日，DeepSeek经历了超10小时的C端服务崩溃，网页端和App无法使用，但API调用正常。过去60天内，这已是第二次大规模中断。这是因为Deepseek的算力资源远低于实际日活需求，导致资源不足而崩溃，这也是Deepseek引入模式分层的原因之一。</span></p>
<p style=""></p>
<p style="">此次对话界面更新或许是DeepSeek V4版本发布的前奏。</p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-IzZh.png&amp;size=m" width="687px">
</figure>
<p style=""></p>
<p style="">也有业内分析指出认为本次模式分层正是Deepseek不堪财务重负，迟迟无法实现大规模盈利，从而转为商业化的第一步，或许以后Deepseek将不再完全免费。</p>
<p style=""></p>
<h1 style="" id="%E5%AE%9E%E6%B5%8B">实测</h1>
<p style="">给 专家模式 和 快速模式 都使用同样的提示词，“编写小球真实物理模拟在复杂2D地形中下落弹跳滚动的html网页”</p>
<p style="">从专家模式生成的内容可以明显看出比快速模式优秀了不少！</p>
<h3 style="" id="%E5%BF%AB%E9%80%9F%E6%A8%A1%E5%BC%8F">快速模式</h3>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-XxnG.png&amp;size=m" width="799px">
</figure>
<h3 style="" id="%E4%B8%93%E5%AE%B6%E6%A8%A1%E5%BC%8F">专家模式</h3>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-tqFJ.png&amp;size=m" width="807px">
</figure>
<h1 style="" id="%E7%BB%93%E5%B0%BE">结尾</h1>
<p style="">Deepseek一直免费持续更新是愿景，但不得不迈向商业化，节省开销是现实。</p>
<p style="">或许在将来，我们会用上Deepseek V4、V5、V6，甚至更多新的模型，但到了那时也许Deepseek将逐渐融入现实的行业环境中来。</p>
<p style="">欢迎大家在评论区发表自己的看法！</p>]]></description><guid isPermaLink="false">/archives/1775647416143</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-04-08%2520192328.png&amp;size=m" type="image/jpeg" length="22718"/><category>新闻咨询</category><category>AI</category><pubDate>Wed, 8 Apr 2026 11:36:21 GMT</pubDate></item><item><title><![CDATA[游玩本站必读公告]]></title><link>https://pym.plus/archives/1772415751172</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E6%B8%B8%E7%8E%A9%E6%9C%AC%E7%AB%99%E5%BF%85%E8%AF%BB%E5%85%AC%E5%91%8A&amp;url=/archives/1772415751172" width="1" height="1" alt="" style="opacity:0;">
<p style="">本文用于长期保存各种重要公告。</p>
<h1 style="" id="%E5%AF%BC%E8%88%AA%E9%A1%B5">导航页</h1>
<p style="">这是网站一个比较重要的页面，里面有一些博主自己的搭建的工具和服务，感兴趣的小伙伴可以去看看，希望能够帮助到大家。</p>
<p style=""><a href="https://pym.plus/nav-page" target="_self" rel="">传送门链接</a></p>
<h1 style="" id="%E6%88%91%E7%9A%84%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F">我的联系方式</h1>
<p style="">邮箱： <code>pymcn@outlook.com</code></p>
<p style="">在线聊天： <code>添加好友-&gt;pymcn</code></p>
<h1 style="" id="%E5%9C%A8%E7%BA%BF%E8%81%8A%E5%A4%A9">在线聊天</h1>
<p style="">注册账号并同意用户协议可以使用 <code>在线聊天</code> 服务，请遵守协议内容，构建文明友好守法的聊天环境。</p>]]></description><guid isPermaLink="false">/archives/1772415751172</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E5%25B1%258F%25E5%25B9%2595%25E6%2588%25AA%25E5%259B%25BE%25202026-03-02%2520094336.png&amp;size=m" type="image/jpeg" length="12675"/><category>公告</category><pubDate>Wed, 8 Apr 2026 01:44:00 GMT</pubDate></item><item><title><![CDATA[Claude Code源代码惨遭泄露，几句话告诉你泄露的原因，附下载链接]]></title><link>https://pym.plus/archives/1775534130555</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Claude%20Code%E6%BA%90%E4%BB%A3%E7%A0%81%E6%83%A8%E9%81%AD%E6%B3%84%E9%9C%B2%EF%BC%8C%E5%87%A0%E5%8F%A5%E8%AF%9D%E5%91%8A%E8%AF%89%E4%BD%A0%E6%B3%84%E9%9C%B2%E7%9A%84%E5%8E%9F%E5%9B%A0%EF%BC%8C%E9%99%84%E4%B8%8B%E8%BD%BD%E9%93%BE%E6%8E%A5&amp;url=/archives/1775534130555" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E6%B3%84%E9%9C%B2%E8%BF%87%E7%A8%8B">泄露过程</h1>
<h3 style="text-align: left" id="%E7%AC%AC%E4%B8%80%E6%AC%A1%E6%B3%84%E9%9C%B2%EF%BC%882025-%E5%B9%B4-2-%E6%9C%88%EF%BC%89"><strong>第一次泄露（2025 年 2 月）</strong></h3>
<p style="text-align: left">Claude Code 随 Claude 3.7 一起发布，以 npm 包形式分发。在 v0.2.8 及之前版本中：</p>
<p style=""><strong>使用了开发环境配置打生产包，包含了</strong><span style="background-color: rgba(0, 0, 0, 0.04); color: rgb(192, 52, 29); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace, sans-serif; font-size: 12px">inline-source-map</span><strong>所以混淆可以说是没有，被一行命令即可反解出全部源码</strong></p>
<p style="text-align: left">Anthropic发现后删除了 0.2.8 之前的包，并在 0.2.9 中修正。但 GitHub 上已经有人存档了完整代码（如 <a href="https://github.com/dnakov/claude-code" target="_blank" rel="noopener nofollow"><u>dnakov/claude-code</u></a>）。</p>
<h3 style="text-align: left" id="%E7%AC%AC%E4%BA%8C%E6%AC%A1%E6%B3%84%E9%9C%B2%EF%BC%882026-%E5%B9%B4-3-%E6%9C%88%EF%BC%89"><strong>第二次泄露（2026 年 3 月）</strong></h3>
<p style="text-align: left">版本从 <code>0.2.x</code> 到 <code>2.1.88</code>，代码量膨胀了近 10 倍，但是还是没涨记性：</p>
<p style="text-align: left"><strong>npm 包中误留了 cli.js.map 文件（59.8 MB）</strong></p>
<p style="text-align: left">所以又被放出源码了。。。</p>
<p style="text-align: left">提取方式也非常简单：</p>
<pre><code class="language-bash"># 下载 npm 包
npm pack @anthropic-ai/claude-code@2.1.88

# 解压
tar -xzf anthropic-ai-claude-code-2.1.88.tgz

# cli.js.map 的 sourcesContent 字段中包含了所有源码
# 一行 jq 即可提取
cat package/cli.js.map | jq -r '.sources[]' </code></pre>
<h2 style="" id="%E4%BB%A3%E7%A0%81%E7%BB%9F%E8%AE%A1"><strong>代码统计</strong></h2>
<div style="overflow-x: auto; overflow-y: hidden;">
 <table style="width: 200px">
  <colgroup>
   <col style="width: 100px">
   <col style="width: 100px">
  </colgroup>
  <tbody>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <th colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; font-weight: 600; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><strong>指标</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; font-weight: 600; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><strong>数量</strong></p>
    </th>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">TypeScript 文件</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">~1884</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">命令数量</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">~50+</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">工具数量</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">~30+</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">UI 组件</p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">~100+</p>
    </td>
   </tr>
  </tbody>
 </table>
</div>
<h2 style="" id="%E5%85%B3%E9%94%AE%E6%96%87%E4%BB%B6"><strong>关键文件</strong></h2>
<div style="overflow-x: auto; overflow-y: hidden;">
 <table style="width: 200px">
  <colgroup>
   <col style="width: 100px">
   <col style="width: 100px">
  </colgroup>
  <tbody>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <th colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; font-weight: 600; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><strong>文件</strong></p>
    </th>
    <th colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; font-weight: 600; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><strong>描述</strong></p>
    </th>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><code>main.tsx</code></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">应用主入口</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><code>commands.ts</code></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">命令注册中心</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><code>tools.ts</code></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">工具注册中心</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(246, 248, 250); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><code>context.ts</code></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">上下文管理</p>
    </td>
   </tr>
   <tr style="box-sizing: border-box; background-color: rgb(255, 255, 255); border-top: 1px solid rgba(209, 217, 224, 0.7);">
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style=""><code>ink.tsx</code></p>
    </td>
    <td colspan="1" rowspan="1" colwidth="100" style="box-sizing: border-box; padding: 6px 13px; border-color: rgb(209, 217, 224); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch;">
     <p style="">UI 渲染引擎</p>
    </td>
   </tr>
  </tbody>
 </table>
</div>
<h1 style="" id="%E6%BA%90%E7%A0%81%E4%B8%8B%E8%BD%BD">源码下载</h1>
<p style="">Github：<a href="https://github.com/huangserva/claude-code-cli" target="_blank" rel="">https://github.com/huangserva/claude-code-cli</a></p>
<p style="">网盘：<a href="https://pan.pym.plus/s/owc9" target="_blank" rel="">https://pan.pym.plus/s/owc9</a></p>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1775534130555</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-04-07%2520142458.png&amp;size=m" type="image/jpeg" length="39231"/><category>漏洞</category><category>Github</category><pubDate>Tue, 7 Apr 2026 06:27:24 GMT</pubDate></item><item><title><![CDATA[Docker快速部署Astrbot，开源的一站式 Agentic 个人和群聊助手]]></title><link>https://pym.plus/archives/1775183683911</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Docker%E5%BF%AB%E9%80%9F%E9%83%A8%E7%BD%B2Astrbot%EF%BC%8C%E5%BC%80%E6%BA%90%E7%9A%84%E4%B8%80%E7%AB%99%E5%BC%8F%20Agentic%20%E4%B8%AA%E4%BA%BA%E5%92%8C%E7%BE%A4%E8%81%8A%E5%8A%A9%E6%89%8B&amp;url=/archives/1775183683911" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E5%89%8D%E8%A8%80">前言</h1>
<p style="">Openclaw确实比较火，但其复杂的配置界面，并不直观的UI设计导致其上手难度对小白不是很友好，而最近Astrbot的Agent更新，使其有了与Openclaw差不多的能力，本文就来讲讲怎么用Docker快速部署Astrbot。</p>
<h1 style="" id="%E9%83%A8%E7%BD%B2">部署</h1>
<h2 style="" id="%E6%8B%89%E5%8F%96%E9%95%9C%E5%83%8F">拉取镜像</h2>
<p style="">首先你需要Docker，没有参考<a href="https://pym.plus/archives/1772243427656" target="_blank" rel="">这篇文章</a>部署</p>
<p style="">然后执行这条命令</p>
<pre><code class="language-shellscript">sudo docker run -itd -p 6185:6185 -p 6199:6199 -v $PWD/data:/AstrBot/data -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro --name astrbot m.daocloud.io/docker.io/soulter/astrbot:latest</code></pre>
<p style="">然后等待拉取镜像和启动就可以了。</p>
<h2 style="" id="%E9%85%8D%E7%BD%AE">配置</h2>
<p style="">默认安装好的Astrbot并没有直接使用电脑的能力，需要设置一下才能使用。</p>
<p style="">进入 <code>配置文件</code> -&gt; <code>普通配置</code> -&gt;<code>使用电脑能力</code> -&gt; <code>运行环境</code> ，然后选择 <code>local</code> ，这代表在本地电脑运行，也可以选择 <code>sandbox</code> 代表在沙箱环境中运行。</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-Fmjm.png&amp;size=m">
</figure>
<p style="">需要注意的是，如果你勾选了 <code>需要 AstrBot 管理员权限</code> 且你更改了管理员账户的用户名时需要在当前这个页面点击左边的 <code>平台配置</code> ，然后修改<strong>管理员 ID</strong>为你的管理员用户名。</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-dyMm.png&amp;size=m" width="776px">
</figure>
<p style="">这样才能正常使用Agent能力</p>
<h2 style="" id="%E9%85%8D%E7%BD%AE%E6%A8%A1%E5%9E%8B">配置模型</h2>
<p style="">进入到模型提供商，然后点击新增就可以添加了，具体参考图片，如果新增里没有你的模型提供商也可以随便添加一个，然后修改 <code>API Base URL</code> 为你的模型提供商的适配OpenAI的请求地址，然后修改ID，可以自己随便写一个，最后点击 <code>保存并获取模型</code> ，等待模型列表出现，点击对应模型旁边的+号，然后再启用就可以使用了。</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-QbRh.png&amp;size=m">
</figure>
<h1 style="" id="%E5%AE%8C%E6%88%90">完成</h1>
<p style="">恭喜你到这里就大功告成了，快去试试吧，点击右上角的 <code>Bot/Chat</code> 选择 <code>Chat</code> 就可以直接在网页里聊天使用了。</p>
<figure style="align-items: start; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2Fimage-erCP.png&amp;size=m">
</figure>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1775183683911</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-04-03%2520103432.png&amp;size=m" type="image/jpeg" length="38391"/><category>AI</category><category>Docker</category><category>服务器</category><pubDate>Fri, 3 Apr 2026 02:58:05 GMT</pubDate></item><item><title><![CDATA[今天是愚人节，请将这篇文章转发给你的亲朋好友]]></title><link>https://pym.plus/archives/1775045736845</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=%E4%BB%8A%E5%A4%A9%E6%98%AF%E6%84%9A%E4%BA%BA%E8%8A%82%EF%BC%8C%E8%AF%B7%E5%B0%86%E8%BF%99%E7%AF%87%E6%96%87%E7%AB%A0%E8%BD%AC%E5%8F%91%E7%BB%99%E4%BD%A0%E7%9A%84%E4%BA%B2%E6%9C%8B%E5%A5%BD%E5%8F%8B&amp;url=/archives/1775045736845" width="1" height="1" alt="" style="opacity:0;">
<p style="">今天是愚人节，转发这篇文章给你的亲朋好友，不用想太多，也不用纠结转发的意义，反正就是转发就好，没有任何目的，也没有任何回报，只是单纯地浪费一点时间，浪费你手指滑动的那几秒，浪费你打开通讯录、选择联系人的那几分钟，就像平时浪费的无数个瞬间一样，没有任何价值，也没有任何意义，就那样平平淡淡地消耗着这一天的时光，消耗着愚人节这一天独有的、本就无关紧要的几分几秒。</p>
<p style="">你不用在意转发之后亲朋好友会怎么想，不用在意他们会不会点开，会不会看完，甚至不用在意这篇文章里写的是什么内容，因为本来就没有什么有意义的东西，转发只是一个动作，一个无意义的动作，就像你平时发呆、走神、对着手机屏幕放空一样，都是在浪费时间，都是在做没有价值的事情。也许你转发的时候，只是随手一点，没有经过任何思考，也许你只是觉得，愚人节就应该做一些这样无厘头、无意义的事情，就应该浪费一点时间，不用追求任何结果，也不用在意任何回报。</p>
<p style="">转发这篇文章，不用管它能不能给你带来快乐，不用管它能不能给你的亲朋好友带来惊喜，反正都是浪费时间，反正都是没有意义的举动。你可以转发给你的父母，转发给你的兄弟姐妹，转发给你的同学朋友，转发给你认识的每一个人，不用筛选，不用犹豫，浪费一点时间在选择转发对象上，浪费一点时间在等待转发成功的瞬间，这些都是无意义的浪费，都是无关紧要的消耗，就像我们每天浪费的那些碎片化时间一样，悄无声息，没有痕迹，也没有任何价值。</p>
<p style="">也许有人会问，转发这篇文章有什么用？其实没有任何用，既不能让你暴富，也不能让你变得更好，更不能改变什么，只是单纯地浪费时间，只是在愚人节这一天，做一件和愚人节一样，看似有趣、实则无意义的事情。我们每天都在浪费时间，吃饭的时候浪费时间，睡觉的时候浪费时间，刷手机的时候浪费时间，发呆的时候浪费时间，而转发这篇文章，只是无数浪费时间的举动中的一个，没有什么特别，也没有什么不同，只是刚好赶上了愚人节，刚好有这样一篇无意义的文章，供我们浪费时间，供我们随手转发。</p>
<p style="">今天是愚人节，转发这篇文章给你的亲朋好友，不用想转发的意义，不用想浪费时间的可惜，反正时间本来就是用来浪费的，反正我们每天都在无意义地消耗着时光。转发之后，你可以继续刷手机，继续发呆，继续做那些没有意义的事情，继续浪费剩下的时间，没有任何负担，也没有任何顾虑。这篇文章没有任何营养，没有任何干货，没有任何值得你记住的内容，就像我们浪费的那些时间一样，过后就忘，没有留下一点痕迹，也没有给我们带来任何收获。</p>
<p style="">转发吧，不用犹豫，不用纠结，浪费一点时间又怎么样，反正我们有很多时间可以浪费，反正这些浪费的时间，也不会对我们的生活造成任何影响。今天是愚人节，就让我们一起，无意义地浪费一次时间，转发这篇文章，给你的亲朋好友，一起浪费时间，一起做没有意义的事情，不用追求任何结果，不用在意任何回报，只是单纯地享受这份无意义的浪费，享受这份不用思考、不用努力的轻松，就像平时无数个浪费时间的瞬间一样，平平淡淡，无滋无味，却又真实地消耗着我们的时光，直到这一天结束，直到我们又浪费了一天的时间，没有任何意义，也没有任何遗憾。</p>
<p style=""></p>
<p style="">最后，愚人节快乐~~~</p>]]></description><guid isPermaLink="false">/archives/1775045736845</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-04-01%2520201607.png&amp;size=m" type="image/jpeg" length="41361"/><category>生活</category><pubDate>Wed, 1 Apr 2026 12:17:10 GMT</pubDate></item><item><title><![CDATA[P4171 [JSOI2010] 满汉全席 2-SAT详细题解]]></title><link>https://pym.plus/archives/1774660003038</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=P4171%20%5BJSOI2010%5D%20%E6%BB%A1%E6%B1%89%E5%85%A8%E5%B8%AD%202-SAT%E8%AF%A6%E7%BB%86%E9%A2%98%E8%A7%A3&amp;url=/archives/1774660003038" width="1" height="1" alt="" style="opacity:0;">
<p style=""><a href="https://www.luogu.com.cn/problem/P4171" target="_blank" rel="">题目传送门</a></p>
<p style="">前置知识：2-SAT</p>
<h1 style="" id="%E9%A2%98%E7%9B%AE%E5%A4%A7%E6%84%8F">题目大意</h1>
<p style="">有 <span style="background-color: rgba(0, 0, 0, 0); color: rgb(0, 0, 0); font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 19.36px; line-height: 23.232px">n</span> 种材料，每种可做<strong>满式（m）或汉式（h）</strong>。<span style="background-color: rgba(0, 0, 0, 0); color: rgb(0, 0, 0); font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 19.36px; line-height: 23.232px">m</span> 位评审各有两个喜好（如 <code>m1</code>、<code>h2</code>），只要选手做出其中一个喜好的菜，该评审就通过。</p>
<p style="">问：是否存在一种做菜方案，能让<strong>所有评审都通过</strong>？</p>
<ul>
 <li>
  <p style="">存在输出 <code>GOOD</code>，否则输出 <code>BAD</code>。</p>
 </li>
</ul>
<h1 style="" id="%E8%A7%A3%E9%A2%98%E6%80%9D%E8%B7%AF">解题思路</h1>
<p style=""><s>显然</s>这是一道2-SAT裸题。</p>
<h2 style="" id="%E5%88%86%E6%9E%90%E9%A2%98%E7%9B%AE">分析题目</h2>
<p style="">把每样材料拆成 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 拆开，用 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 表示<strong>满式</strong>做法，用 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi><mo>+</mo><mi>n</mi></mrow><annotation encoding="application/x-tex">i +n </annotation>
    </semantics>
   </math>
  </span></span> 表示<strong>汉式</strong>做法。</p>
<p style="">因为每个评委的要求只要满足一样的即可，所以可以看作是<strong>或</strong></p>
<p style="">点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
    </semantics>
   </math>
  </span></span> 可以是<strong>满/汉</strong>式，点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
    </semantics>
   </math>
  </span></span> 也可以是<strong>满/汉</strong>式，所以有<strong>4种情况</strong>：</p>
<ol>
 <li>
  <p style="">要求点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 是满式 或 点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 是满式，那么若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 为汉式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 必为满式；若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 为汉式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 必为满式。</p>
 </li>
 <li>
  <p style="">要求点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 是满式 或 点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 是汉式，那么若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 为汉式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 必为汉式；若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 为汉式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 必为满式。</p>
 </li>
 <li>
  <p style="">要求点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 是汉式 或 点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 是汉式，那么若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 为满式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 必为汉式；若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 为满式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 必为汉式。</p>
 </li>
 <li>
  <p style="">要求点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 是汉式 或 点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 是满式，那么若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 为满式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 必为满式；若 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>v</mi></mrow><annotation encoding="application/x-tex">v</annotation>
      </semantics>
     </math>
    </span></span> 为汉式，则 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>u</mi></mrow><annotation encoding="application/x-tex">u</annotation>
      </semantics>
     </math>
    </span></span> 必为汉式。</p>
 </li>
</ol>
<h2 style="" id="%E5%BB%BA%E5%9B%BE">建图</h2>
<p style="">从上面的分析，我们可以得出通过特殊建图再跑一边板子2-SAT可以完成这道题。</p>
<pre><code class="language-cpp">for (int i = 1; i &lt;= m; ++i) {
	string Su, Sv;
	cin &gt;&gt; Su &gt;&gt; Sv;
	char op1 = Su[0], op2 = Sv[0];
	int u = 0, v = 0;
	for (int j = 1; j &lt; Su.size(); ++j) u = u * 10 + (Su[j] - '0' + 0);
	for (int j = 1; j &lt; Sv.size(); ++j) v = v * 10 + (Sv[j] - '0' + 0);
	if (op1 == 'm') {
		if (op2 == 'h') add(v, u), add(u + n, v + n); // 第二种情况
		else add(u + n, v), add(v + n, u); // 第一种情况
	} else {
		if (op2 == 'h') add(u, v + n), add(v, u + n); // 第三种情况
		else add(u, v), add(v + n, u + n); // 第四种情况
	}
}</code></pre>
<p style="">恭喜你这道题做完了。</p>
<h2 style="" id="%E5%88%A4%E6%96%ADgood%E8%BF%98%E6%98%AFbad">判断GOOD还是BAD</h2>
<p style="">因为 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 为满式， <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi><mo>+</mo><mi>n</mi></mrow><annotation encoding="application/x-tex">i + n</annotation>
    </semantics>
   </math>
  </span></span> 为汉式，所有只要判断 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>s</mi><mi>c</mi><mi>c</mi><mo stretchy="false">[</mo><mi>i</mi><mo stretchy="false">]</mo><mo>=</mo><mo>=</mo><mi>s</mi><mi>c</mi><mi>c</mi><mo stretchy="false">[</mo><mi>i</mi><mo>+</mo><mi>n</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">scc[i] == scc[i+n]</annotation>
    </semantics>
   </math>
  </span></span>就可以了，如果相等就不成立，输出 <code>BAD</code> ，反之输出 <code>GOOD</code></p>
<pre><code class="language-cpp">bool flag = true;
for (int i = 1; i &lt;= n; ++i) {
	if (scc[i] == scc[i + n]) {
		flag = false;
		break;
	}
}
cout &lt;&lt; (flag ? "GOOD" :  "BAD") &lt;&lt; "\n";</code></pre>
<h1 style="" id="ac%E4%BB%A3%E7%A0%81">AC代码</h1>
<pre><code class="language-cpp">#include &lt;bits/stdc++.h&gt;
#define ll long long
using namespace std;
const int N = 1000 + 5;
int T;
int n, m;
vector&lt;vector&lt;int&gt;&gt; e;
void add(int u, int v) {
	e[u].emplace_back(v);
}
int tot, cnt;
int dfn[2 * N], low[2 * N], scc[2 * N];
stack&lt;int&gt; q;
bitset&lt;2 * N&gt; vis;
void tarjan(int u) {
	dfn[u] = low[u] = ++tot;
	q.emplace(u);
	vis[u] = true;
	for (auto v : e[u]) {
		if (!dfn[v]) {
			tarjan(v);
			low[u] = min(low[u], low[v]);
		} else if (vis[v]) {
			low[u] = min(low[u], dfn[v]);
		}
	}
	if (low[u] == dfn[u]) {
		++cnt;
		int v;
		do {
			v = q.top(); q.pop();
			vis[v] = false;
			scc[v] = cnt;
		} while(v != u);
	}
}
void init() {
	cnt = tot = 0;
	e.clear();
	e.resize(2 * N);
	stack&lt;int&gt;().swap(q);
	vis.reset();
	for (int i = 1; i &lt;= 2 * n; ++i) {
		dfn[i] = low[i] = scc[i] = 0;
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin &gt;&gt; T;
	while (T--) {
		init();
		cin &gt;&gt; n &gt;&gt; m;
		for (int i = 1; i &lt;= m; ++i) {
			string Su, Sv;
			cin &gt;&gt; Su &gt;&gt; Sv;
			char op1 = Su[0], op2 = Sv[0];
			int u = 0, v = 0;
			for (int j = 1; j &lt; Su.size(); ++j) u = u * 10 + (Su[j] - '0' + 0);
			for (int j = 1; j &lt; Sv.size(); ++j) v = v * 10 + (Sv[j] - '0' + 0);
			if (op1 == 'm') {
				if (op2 == 'h') add(v, u), add(u + n, v + n);
				else add(u + n, v), add(v + n, u);
			} else {
				if (op2 == 'h') add(u, v + n), add(v, u + n);
				else add(u, v), add(v + n, u + n);
			}
		}
		for (int i = 1; i &lt;= 2 * n; ++i) if (!dfn[i]) tarjan(i);
		bool flag = true;
		for (int i = 1; i &lt;= n; ++i) {
			if (scc[i] == scc[i + n]) {
				flag = false;
				break;
			}
		}
		cout &lt;&lt; (flag ? "GOOD" :  "BAD") &lt;&lt; "\n";
	}
	return 0;
}</code></pre>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1774660003038</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-28%2520090614.png&amp;size=m" type="image/jpeg" length="115514"/><category>C++</category><category>题解</category><pubDate>Sat, 28 Mar 2026 01:57:49 GMT</pubDate></item><item><title><![CDATA[P1993 小 K 的农场 差分约束SPFA判断负环 详细题解]]></title><link>https://pym.plus/archives/1774615046821</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=P1993%20%E5%B0%8F%20K%20%E7%9A%84%E5%86%9C%E5%9C%BA%20%E5%B7%AE%E5%88%86%E7%BA%A6%E6%9D%9FSPFA%E5%88%A4%E6%96%AD%E8%B4%9F%E7%8E%AF%20%E8%AF%A6%E7%BB%86%E9%A2%98%E8%A7%A3&amp;url=/archives/1774615046821" width="1" height="1" alt="" style="opacity:0;">
<p style=""><a href="https://www.luogu.com.cn/problem/P1993'" target="_blank" rel="">题目传送门</a></p>
<h1 style="" id="%E9%A2%98%E7%9B%AE%E5%A4%A7%E6%84%8F">题目大意</h1>
<p style="">一共 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation>
    </semantics>
   </math>
  </span></span> 个点， <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>M</mi></mrow><annotation encoding="application/x-tex">M</annotation>
    </semantics>
   </math>
  </span></span> 条边。</p>
<p style="">有 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mn>3</mn></mrow><annotation encoding="application/x-tex">3</annotation>
    </semantics>
   </math>
  </span></span> 种类型的边：</p>
<ol>
 <li>
  <p style="">单向边：从点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
      </semantics>
     </math>
    </span></span> 到点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
      </semantics>
     </math>
    </span></span> 至少有 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
      </semantics>
     </math>
    </span></span>，也就是 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">−</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≥</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>c</em></span></p>
 </li>
 <li>
  <p style="">单向边：从点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
      </semantics>
     </math>
    </span></span> 到点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
      </semantics>
     </math>
    </span></span> 至多有 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
      </semantics>
     </math>
    </span></span>，<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">−</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>c</em></span></p>
 </li>
 <li>
  <p style="">双向边：从点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
      </semantics>
     </math>
    </span></span> 到点 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
      </semantics>
     </math>
    </span></span>一样多，<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">=</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span></p>
 </li>
</ol>
<p style="">
 <br>
 将这 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mn>3</mn></mrow><annotation encoding="application/x-tex">3</annotation>
    </semantics>
   </math>
  </span></span> 种边转换一下可以得到：
</p>
<ol>
 <li>
  <p style=""><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">−</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>c</em></span></p>
 </li>
 <li>
  <p style=""><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>c</em></span></p>
 </li>
 <li>
  <p style=""><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">=</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+0</span> 与 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">=</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+0</span></p>
 </li>
</ol>
<h1 style="" id="%E8%A7%A3%E9%A2%98%E6%80%9D%E8%B7%AF">解题思路</h1>
<h2 style="" id="%E5%88%A4%E6%96%AD%E8%B4%9F%E7%8E%AF">判断负环</h2>
<p style="">如果K的记忆冲突了，那么就说明有负环（小K绕晕了<span data-name="dizzy_face" class="emoji-node" data-type="emoji">😵</span>），输出 <strong>NO</strong></p>
<p style="">如果K的记忆有至少1种情况没有冲突， 那么就说明图中不存在负环，则输出 <strong>YES</strong></p>
<pre><code class="language-cpp">// 判断负环
cnt[v] = cnt[u] + 1;
if (cnt[v] &gt; n) {
	cout &lt;&lt; "No\n"; // 有，就输出NO
	exit(0);
}


// 没有负环，在函数外输出YES
spfa(0);
cout &lt;&lt; "Yes\n";
return 0;</code></pre>
<h2 style="" id="%E5%A4%84%E7%90%86-3-%E7%A7%8D%E8%BE%B9">处理 3 种边</h2>
<p style=""><span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
    </semantics>
   </math>
  </span></span> 代表从某一点至某一点的边所需的花费。</p>
<p style="">对于第一种，从点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 到点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
    </semantics>
   </math>
  </span></span> <strong>至少</strong>有 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
    </semantics>
   </math>
  </span></span>：</p>
<p style="text-indent: 2em">观察式子 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">−</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>c </em></span>可得出 从点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span>到点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
    </semantics>
   </math>
  </span></span> 花费为 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mo>−</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">-c</annotation>
    </semantics>
   </math>
  </span></span></p>
<p style="text-indent: 2em"></p>
<p style="">对于第二种，从点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 到点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
    </semantics>
   </math>
  </span></span> <strong>至多</strong>有 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
    </semantics>
   </math>
  </span></span>：</p>
<p style="text-indent: 2em">观察式子 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>c </em></span>可得出 从点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
    </semantics>
   </math>
  </span></span>到点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 花费为 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
    </semantics>
   </math>
  </span></span></p>
<p style=""></p>
<p style="">对于第三种，从点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi></mrow><annotation encoding="application/x-tex">i</annotation>
    </semantics>
   </math>
  </span></span> 到 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>j</mi></mrow><annotation encoding="application/x-tex">j</annotation>
    </semantics>
   </math>
  </span></span> 数量一样，即 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation>
    </semantics>
   </math>
  </span></span> 为 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation>
    </semantics>
   </math>
  </span></span>：</p>
<p style="text-indent: 2em">观察式子 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">=</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+0</span> 与 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>j</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">=</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>a</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+0</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em> </em></span>可得出 从点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi><mi mathvariant="normal">/</mi><mi>j</mi></mrow><annotation encoding="application/x-tex">i/j</annotation>
    </semantics>
   </math>
  </span></span>到点 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>i</mi><mi mathvariant="normal">/</mi><mi>j</mi></mrow><annotation encoding="application/x-tex">i/j</annotation>
    </semantics>
   </math>
  </span></span> 花费为 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation>
    </semantics>
   </math>
  </span></span>，是一条<strong>双向边</strong></p>
<pre><code class="language-cpp">for (int i = 1; i &lt;= m; ++i) {
	int op; cin &gt;&gt; op;
	int u, v, w = 0;
	if (op == 1) {
		cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
		e[u].emplace_back(v, -w);
	} else if (op == 2) {
		cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
		e[v].emplace_back(u, w);
	} else {
		cin &gt;&gt; u &gt;&gt; v;
		e[u].emplace_back(v, 0);
		e[v].emplace_back(u, 0);
	}
}</code></pre>
<h2 style="" id="%E8%B6%85%E7%BA%A7%E6%BA%90%E7%82%B9">超级源点</h2>
<p style="">因为题目并没有规定从哪一点出发，且题目需要求解出所有情况来判断</p>
<p style="">因此我们需要一个超级源点来连接所有点，方便求出所有情况</p>
<pre><code class="language-cpp">for (int i = 1; i &lt;= n; ++i) e[0].emplace_back(i, 0);</code></pre>
<h1 style="" id="ac%E4%BB%A3%E7%A0%81">AC代码</h1>
<pre><code class="language-cpp">#include &lt;bits/stdc++.h&gt;
#define ll long long
using namespace std;
const int N = 1e4 + 5;
int n, m;
vector&lt;vector&lt;pair&lt;int, int&gt;&gt;&gt; e(N);
ll dis[N]; // 记录距离
int cnt[N]; // 记录任意点在队列的次数，以便判断负环
bool vis[N]; // 记录任意点是否在队列中
void spfa(int s) { // SPFA板子
	queue&lt;int&gt; q;
	q.emplace(s);
	fill(dis + 1, dis + n + 1, INT_MAX); //SPFA必要的初始化
	vis[s] = true;
	dis[s] = 0; // 从超级源点0出发
	while (!q.empty()) {
		int u = q.front(); q.pop();
		vis[u] = false;
		for (auto tmp : e[u]) { // 适配C++14的写法
			int v, w;
			tie(v, w) = tmp;
			if (dis[v] &gt; dis[u] + w) {
				dis[v] = dis[u] + w;
				cnt[v] = cnt[u] + 1; // 累计点v在队列的次数，因为每个点至多n次，所有如果&gt;n就是有负环
				if (cnt[v] &gt; n) {
					cout &lt;&lt; "No\n"; // 有负环，输出NO
					exit(0); // exit(0)是退出整个程序
				}
				if (!vis[v]) {
					vis[v] = true;
					q.emplace(v);
				}
			}
		}
	}
}
int main() {
	// 输入输出加速
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin &gt;&gt; n &gt;&gt; m;
	for (int i = 1; i &lt;= m; ++i) {
		int op; cin &gt;&gt; op;
		int u, v, w = 0;
		if (op == 1) { // 第一种边：农场a比农场b至少多种植了c个单位的作物
			cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
			e[u].emplace_back(v, -w);
		} else if (op == 2) { // 第二种边：农场a比农场b至多多种植了c个单位的作物
			cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
			e[v].emplace_back(u, w);
		} else { // 第三种边：农场a终止的数量和b一样多
			cin &gt;&gt; u &gt;&gt; v;
			e[u].emplace_back(v, 0);
			e[v].emplace_back(u, 0);
		}
	}
	for (int i = 1; i &lt;= n; ++i) e[0].emplace_back(i, 0); // 建立超级源点
	spfa(0);
	cout &lt;&lt; "Yes\n"; // 没有负环输出YES
	return 0;
}</code></pre>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1774615046821</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-27%2520205712.png&amp;size=m" type="image/jpeg" length="76051"/><category>C++</category><category>题解</category><pubDate>Fri, 27 Mar 2026 13:16:16 GMT</pubDate></item><item><title><![CDATA[P6145 [USACO20FEB] Timeline G SPFA差分约束最长路题解]]></title><link>https://pym.plus/archives/1774438176730</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=P6145%20%5BUSACO20FEB%5D%20Timeline%20G%20SPFA%E5%B7%AE%E5%88%86%E7%BA%A6%E6%9D%9F%E6%9C%80%E9%95%BF%E8%B7%AF%E9%A2%98%E8%A7%A3&amp;url=/archives/1774438176730" width="1" height="1" alt="" style="opacity:0;">
<p style=""><a href="https://www.luogu.com.cn/problem/P6145" target="_blank" rel="">题目传送门</a></p>
<h1 style="" id="%E9%A2%98%E6%84%8F%E7%AE%80%E8%BF%B0">题意简述</h1>
<p style="">有 <strong>N 次挤奶</strong>，在 <strong>M 天</strong> 内完成，需要求出<strong>每次挤奶的最早可行日期</strong>，同时满足两个硬性约束：</p>
<ol>
 <li>
  <p style=""><strong>基础约束</strong>：第 <code>i</code> 次挤奶的日期 <strong>不能早于第 Sᵢ 天</strong>；</p>
 </li>
 <li>
  <p style=""><strong>时序约束</strong>：给定 C 条规则 <code>(a, b, x)</code>，要求<strong>第 b 次挤奶的日期 ≥ 第 a 次挤奶的日期 + x</strong>（b 比 a 至少晚 x 天）；</p>
 </li>
 <li>
  <p style="">题目保证所有约束无矛盾，一定存在合法方案。</p>
 </li>
</ol>
<h1 style="" id="%E9%A2%98%E7%9B%AE%E6%80%9D%E8%B7%AF">题目思路</h1>
<h2 style="" id="%E6%AD%A5%E9%AA%A4-1%EF%BC%9A%E5%BB%BA%E5%9B%BE">步骤 1：建图</h2>
<p style="">我们引入<strong>超级源点 0</strong>，这样可以让 SPFA 能一次性处理所有规则，不用额外写代码特殊处理。</p>
<p style="">值得注意的是，超级源点 0 到其他点的单向边代价应该是 这个点不早于第 Sᵢ 天挤奶的时间，也就是 <strong>Sᵢ </strong>，不然的话SPFA不会按照限定的时间，可能会提前。</p>
<hr>
<h2 style="" id="%E6%AD%A5%E9%AA%A4-2%EF%BC%9Aspfa-%E5%88%9D%E5%A7%8B%E5%8C%96">步骤 2：SPFA 初始化</h2>
<ol>
 <li>
  <p style="">距离数组 <code>dis[]</code>：<strong>全部初始化为负无穷</strong>（因为我们要求的是最长路）</p>
 </li>
 <li>
  <p style="">超级源点 <code>dis[0] = 0</code></p>
 </li>
 <li>
  <p style="">用队列存储待松弛的节点，初始把节点 <code>0</code> 入队</p>
 </li>
 <li>
  <p style="">标记数组 <code>vis[]</code>：标记节点是否在队列中，避免重复入队</p>
 </li>
</ol>
<hr>
<h2 style="" id="%E6%AD%A5%E9%AA%A4-3%EF%BC%9Aspfa-%E6%9C%80%E9%95%BF%E8%B7%AF%E6%9D%BE%E5%BC%9B">步骤 3：SPFA 最长路松弛</h2>
<p style="">标准 SPFA 流程，但是判断 <code>dis[v]&nbsp;&gt;&nbsp;dis[u]&nbsp;+&nbsp;w</code> 改成 <code>dis[v]&nbsp;&lt;&nbsp;dis[u]&nbsp;+&nbsp;w</code></p>
<hr>
<h2 style="" id="%E6%AD%A5%E9%AA%A4-4%EF%BC%9A%E5%BE%97%E5%88%B0%E7%AD%94%E6%A1%88">步骤 4：得到答案</h2>
<p style="">队列空时，<code>dis[i]</code> 就是第 <code>i</code> 个变量的<strong>最小合法值</strong>（满足所有约束）。</p>
<p style="">然后直接输出就可以了，恭喜你做完了这道题！</p>
<h1 style="" id="ac%E4%BB%A3%E7%A0%81">AC代码</h1>
<pre><code class="language-cpp">#include &lt;bits/stdc++.h&gt;
#define ll long long
using namespace std;
const int N = 1e5 + 5, INF = 1e9 + 7;
int n, m, kk;        // n:挤奶次数 m:总天数 kk:约束条数
int lim[N];          // 存储每次挤奶的最早天数下限
vector&lt;vector&lt;pair&lt;int, int&gt;&gt;&gt; e(N); // 邻接表存图
bool vis[N];         // SPFA标记数组
ll dis[N];           // 存储答案（最长路结果）

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin &gt;&gt; n &gt;&gt; m &gt;&gt; kk;
	for (int i = 1; i &lt;= n; ++i) cin &gt;&gt; lim[i]; // 读取下限约束
	for (int i = 1; i &lt;= kk; ++i) {
		int u, v, w;
		cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
		e[u].emplace_back(v, w); // 建约束边：v &gt;= u + w
	}
	for (int i = 1; i &lt;= n; ++i) {
		e[0].emplace_back(i, lim[i]); // 超级源点：满足i &gt;= lim[i]
	}
	fill(dis + 1, dis + n + 1, -INF); // 最长路初始化：负无穷
	vis[0] = true;
	dis[0] = 0;
	queue&lt;int&gt; q;
	q.emplace(0);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		vis[u] = false;
		for (auto tmp : e[u]) {
			int v, w;
			tie(v, w) = tmp;
			if (dis[v] &lt; dis[u] + w) { // 最长路松弛操作
				dis[v] = dis[u] + w;
				if (!vis[v]) {
					vis[v] = true;
					q.emplace(v);
				}
			}
		}
	}
	for (int i = 1; i &lt;= n; ++i) {
		cout &lt;&lt; dis[i] &lt;&lt; "\n"; // 输出每次挤奶的最早日期
	}
	return 0;
}</code></pre>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1774438176730</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-25%2520192758.png&amp;size=m" type="image/jpeg" length="101905"/><category>洛谷</category><category>C++</category><category>题解</category><pubDate>Wed, 25 Mar 2026 11:45:19 GMT</pubDate></item><item><title><![CDATA[Luogu P2850 [USACO06DEC] Wormholes G SPFA算法思路与C++代码详解]]></title><link>https://pym.plus/archives/1774075403607</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Luogu%20P2850%20%5BUSACO06DEC%5D%20Wormholes%20G%20SPFA%E7%AE%97%E6%B3%95%E6%80%9D%E8%B7%AF%E4%B8%8EC%2B%2B%E4%BB%A3%E7%A0%81%E8%AF%A6%E8%A7%A3&amp;url=/archives/1774075403607" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E5%85%88%E6%94%BE%E5%9B%BE">先放图</h1>
<figure data-content-type="image" style="display: flex; flex-direction: column;">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-21%2520144145.png&amp;size=m" alt="批注 2026-03-21 144145.png" width="1222px">
</figure>
<h1 style="" id="%E9%A2%98%E7%9B%AE">题目</h1>
<p style=""><a href="https://www.luogu.com.cn/problem/P2850" target="_blank" rel="">洛谷传送门</a></p>
<h2 style="" id="%E9%A2%98%E7%9B%AE%E8%83%8C%E6%99%AF"><strong>题目背景</strong></h2>
<p style=""><a href="https://www.luogu.com.cn/paste/mxuf6zpl">英文题面见此链接</a></p>
<h2 style="" id="%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0"><strong>题目描述</strong></h2>
<p style="">Farmer John 在探索他的农场时发现了许多神奇的虫洞。虫洞的特性非常特殊——它是一个单向通道，能将你传送到它的目的地，而且时间还会回溯到过去！FJ 的每个农场包含 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(1≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤500)</span> 块编号为 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1∼</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span> 的田地、<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(1≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤2500)</span> 条双向路径和 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(1≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤200)</span> 个虫洞。</p>
<p style="">作为狂热的时间旅行爱好者，FJ 希望实现：从某块田地出发，经过若干路径和虫洞后，在初始离开时间之前回到起点。这样或许他能遇见自己 :)</p>
<p style="">为了判断可行性，FJ 将提供 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>F</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(1≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>F</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤5)</span> 个农场的完整地图。所有路径通行耗时不超过 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">10,000</span> 秒，虫洞最多能将 FJ 带回 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">10,000</span> 秒前。</p>
<h2 style="" id="%E8%BE%93%E5%85%A5%E6%A0%BC%E5%BC%8F"><strong>输入格式</strong></h2>
<p style="">第 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span> 行：一个整数 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>F</em></span>，表示农场数。后续为 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>F</em></span> 个农场的数据。</p>
<p style="">每个农场：</p>
<ul>
 <li>
  <p style="">第 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span> 行：三个空格分隔的整数 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span>（田地数）, <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span>（双向路径数）, <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span>（虫洞数）。</p>
 </li>
 <li>
  <p style="">第 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">2∼</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+1</span> 行：每行三个空格分隔的整数 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>E</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">)</span>，表示 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span> 和 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>E</em></span> 间有一条耗时 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span> 秒的双向路径。两块田地间可能存在多条路径。</p>
 </li>
 <li>
  <p style="">第 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+2∼</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">+1</span> 行：每行三个空格分隔的整数 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>E</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">)</span>，表示一条从 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span> 到 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>E</em></span> 的单向虫洞，可将 FJ 带回 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span> 秒前。</p>
 </li>
</ul>
<h2 style="" id="%E8%BE%93%E5%87%BA%E6%A0%BC%E5%BC%8F"><strong>输出格式</strong></h2>
<p style="">输出 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>F</em></span> 行：对每个农场，若 FJ 能达成目标输出<code>YES</code>，否则输出<code>NO</code>。</p>
<h2 style="" id="%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E6%A0%B7%E4%BE%8B"><strong>输入输出样例</strong></h2>
<p style=""><strong>输入 #1</strong></p>
<pre><code>2
3 3 1
1 2 2
1 3 4
2 3 1
3 1 3
3 2 1
1 2 3
2 3 4
3 1 8</code></pre>
<p style=""><strong>输出 #1</strong></p>
<pre><code>NO
YES</code></pre>
<h2 style="" id="%E8%AF%B4%E6%98%8E%2F%E6%8F%90%E7%A4%BA"><strong>说明/提示</strong></h2>
<ul>
 <li>
  <p style="">农场 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span>：FJ 无法实现时间回溯。</p>
 </li>
 <li>
  <p style="">农场 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">2</span>：FJ 可通过环 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1→2→3→1</span> 回到起点 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span> 秒前（可从环上任意点出发实现）。</p>
 </li>
</ul>
<p style="">翻译：DeepSeek-R1</p>
<h1 style="" id="%E6%80%9D%E8%B7%AF">思路</h1>
<h2 style="" id="%E9%A2%98%E7%9B%AE%E8%A7%A3%E6%9E%90">题目解析</h2>
<p style="">这是一道SPFA板子题，题目大意可以理解为：</p>
<ul>
 <li>
  <p style="">有 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation>
      </semantics>
     </math>
    </span></span>个点</p>
 </li>
 <li>
  <p style="">有 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>M</mi></mrow><annotation encoding="application/x-tex">M</annotation>
      </semantics>
     </math>
    </span></span>条双向边，经过会增加时间</p>
 </li>
 <li>
  <p style="">有 <span class="katex-inline"><span class="katex">
     <math xmlns="http://www.w3.org/1998/Math/MathML">
      <semantics>
       <mrow><mi>W</mi></mrow><annotation encoding="application/x-tex">W</annotation>
      </semantics>
     </math>
    </span></span>条单向边，经过可以减少时间（<s>穿越了</s>）</p>
 </li>
</ul>
<p style="">然后这是一道多组测试数据的题，有 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>F</mi></mrow><annotation encoding="application/x-tex">F</annotation>
    </semantics>
   </math>
  </span></span>组数据</p>
<p style="">题目需要你求出，从任意一点出发，会不会遇到负环（因为有负环，所以FJ可以回到起点），有就输出 <code>YES</code> ，没有也就是FJ没法回到起点，输出 <code>NO</code></p>
<p style=""></p>
<h2 style="" id="%E4%BB%A3%E7%A0%81%E6%9E%84%E6%80%9D">代码构思</h2>
<p style="">首先注意到我们可以从任意点出发，所以我们需要建一个 <strong>超级源点</strong>， 有了超级源点后，我们跑SPFA从超级源点出发，这样就可以到达所有点，避免了跑很多遍SPFA来求最优解。那么超级源点是什么呢？就是一个点，比如点0，连接了其他所有点，然后每条连接的边都是单向边，且花费为0，这里我们搭配图片理解：</p>
<figure style="align-items: center; display: flex; flex-direction: column" data-content-type="image">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-21%2520150905.png&amp;size=m" width="326px">
</figure>
<p style="">然后就是SPFA求负环的板子了，不知道SPFA怎么求负环的可以看看<a href="https://pym.plus/archives/1774059454871" target="_blank" rel="">这篇文章</a>，里面有讲SPFA如何求负环，那么最终代码如下：</p>
<pre><code class="language-cpp">#include &lt;bits/stdc++.h&gt;
#define ll long long
using namespace std;
const int N = 500 + 5;
int T;
int n, m, mm;
vector&lt;vector&lt;pair&lt;int, int&gt;&gt;&gt; e; // 奇葩STL，不喜欢可以写结构体，会麻烦点
ll dis[N]; // 没啥用的距离数组，辅助求负环
bool vis[N]; // 标记任意点是否在队列中
int cnt[N]; // 标记任意点的使用次数，用来求负环
bool spfa() {
	// 初始化
	fill(dis + 1, dis + n + 1, INT_MAX);
	fill(cnt + 1, cnt + n + 1, 0);
	fill(vis + 1, vis + n + 1, false);
	queue&lt;int&gt; q;
	q.emplace(0);
	dis[0] = 0;
	vis[0] = true;

	// SPFA板子
	while (!q.empty()) {
		int u = q.front(); q.pop();
		vis[u] = false;
		for (auto tmp : e[u]) { // 适配C++14的写法
			int v, w;
			tie(v, w) = tmp;
			if (dis[v] &gt; dis[u] + w) {
				dis[v] = dis[u] + w;
				cnt[v] = cnt[u] + 1; // 求负环
				if (cnt[v] &gt; n) return false; // 多了一个超级源点，所以是大于n，有负环
				if (!vis[v]) {
					vis[v] = true;
					q.emplace(v);
				}
			}
		}
	}
	return true; //没有负环
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin &gt;&gt; T;
	while (T--) {
		// 因为有多组数据，每次e数组清空，然后重设大小
		e.clear();
		e.resize(N);
		cin &gt;&gt; n &gt;&gt; m &gt;&gt; mm;
		for (int i = 1; i &lt;= m; ++i) {
			int u, v, w;
			cin &gt;&gt; u &gt;&gt; v &gt;&gt; w; // 输入普通的双向边
			e[u].emplace_back(v, w);
			e[v].emplace_back(u, w);
		}
		for (int i = 1; i &lt;= mm; ++i) {
			int u, v, w;
			cin &gt;&gt; u &gt;&gt; v &gt;&gt; w; // 输入虫洞
			e[u].emplace_back(v, -w);
		}
		
		// 超级源点
		for (int i = 1; i &lt;= n; ++i) {
			e[0].emplace_back(i, 0); // 建立单向边，将0指向其他所有点，且花费为0
		}
		cout &lt;&lt; (spfa() ? "NO" : "YES") &lt;&lt; "\n"; // 有负环就是可以回到起点，输出YES，否则是NO
	}
	return 0;
}</code></pre>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1774075403607</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-21%2520144145.png&amp;size=m" type="image/jpeg" length="32634"/><category>C++</category><category>题解</category><pubDate>Sat, 21 Mar 2026 07:18:25 GMT</pubDate></item><item><title><![CDATA[Luogu P2136 拉近距离 SPFA判断负环题解 与 思路]]></title><link>https://pym.plus/archives/1774059454871</link><description><![CDATA[<img src="https://pym.plus/plugins/feed/assets/telemetry.gif?title=Luogu%20P2136%20%E6%8B%89%E8%BF%91%E8%B7%9D%E7%A6%BB%20SPFA%E5%88%A4%E6%96%AD%E8%B4%9F%E7%8E%AF%E9%A2%98%E8%A7%A3%20%E4%B8%8E%20%E6%80%9D%E8%B7%AF&amp;url=/archives/1774059454871" width="1" height="1" alt="" style="opacity:0;">
<h1 style="" id="%E9%A2%98%E7%9B%AE">题目</h1>
<p style=""><a href="https://www.luogu.com.cn/problem/P2136" target="_blank" rel="">Luogu P2136</a></p>
<h2 style="" id="%E9%A2%98%E7%9B%AE%E8%83%8C%E6%99%AF"><strong>题目背景</strong></h2>
<p style="">我是源点，你是终点。我们之间有负权环。 ——小明</p>
<h2 style="" id="%E9%A2%98%E7%9B%AE%E6%8F%8F%E8%BF%B0"><strong>题目描述</strong></h2>
<p style="">在小明和小红的生活中，有 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span> 个关键的节点。有 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span> 个事件，记为一个三元组 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">(</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">)</span>，表示从节点 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span> 有一个事件可以转移到 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span>，事件的效果就是使他们之间的距离减少 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span>。</p>
<p style="">这些节点构成了一个网络，其中节点 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span> 和 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span> 是特殊的，节点 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span> 代表小明，节点 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span> 代表小红，其他代表进展的阶段。所有事件可以自由选择是否进行，但每次只能进行当前节点邻接的。请你帮他们写一个程序，计算出他们之间可能的最短距离。</p>
<h2 style="" id="%E8%BE%93%E5%85%A5%E6%A0%BC%E5%BC%8F"><strong>输入格式</strong></h2>
<p style="">第一行，两个正整数 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span>。</p>
<p style="">之后 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span> 行，每行 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">3</span> 个空格隔开的整数 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>S</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>T</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">,</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span>。</p>
<h2 style="" id="%E8%BE%93%E5%87%BA%E6%A0%BC%E5%BC%8F"><strong>输出格式</strong></h2>
<p style="">一行，一个整数表示他们之间可能的最短距离。如果这个距离可以无限缩小，输出<code>Forever love</code>。</p>
<h2 style="" id="%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E6%A0%B7%E4%BE%8B"><strong>输入输出样例</strong></h2>
<p style=""><strong>输入 #1</strong></p>
<pre><code>3 3
1 2 3
2 3 -1
3 1 -10</code></pre>
<p style=""><strong>输出 #1</strong></p>
<pre><code>-2</code></pre>
<h2 style="" id="%E8%AF%B4%E6%98%8E%2F%E6%8F%90%E7%A4%BA"><strong>说明/提示</strong></h2>
<p style="">对于 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">20%</span> 数据，<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤10</span>，<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤50</span>。</p>
<p style="">对于 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">50%</span> 数据，<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤300</span>，<span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤5000</span>。</p>
<p style="">对于 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">100%</span> 数据，<span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤10</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 0.7em; line-height: 1.2">3</span>，<span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1≤</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>M</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">≤10</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 0.7em; line-height: 1.2">4</span>，<span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">∣</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>W</em></span><span style="font-family: KaTeX_Math; font-size: 0.7em; line-height: 1.2"><em>i</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1px; line-height: 1.2">​</span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">∣≤100</span>，保证从节点 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1</span> 到 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">2…</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span> 有路径，从节点 <span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span> 到 <span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">1…</span><span style="font-family: KaTeX_Math; font-size: 1.21em; line-height: 1.2"><em>N</em></span><span style="font-family: KaTeX_Main, &quot;Times New Roman&quot;, serif; font-size: 1.21em; line-height: 1.2">−1</span> 有路径。</p>
<h1 style="" id="%E6%80%9D%E8%B7%AF">思路</h1>
<p style="">这道题很显然是一道单源最短路的题目，通过观察题目，我们可以得出以下信息：</p>
<ul>
 <li>
  <p style="">是单向图</p>
 </li>
 <li>
  <p style="">计算的是小红与小明之间的最短距离，这意味着可以是小红到小明，也可以是小明到小红</p>
 </li>
 <li>
  <p style="">题目有明显的负环，需要输出 <code>Forever love</code></p>
 </li>
 <li>
  <p style="">题目中的边权不是相加是相减，为了避免麻烦改代码，可以对边权取反来建图。</p>
 </li>
</ul>
<p style="">那么这道题是非常良心的<span data-name="+1" class="emoji-node" data-type="emoji">👍</span>，出题人没有卡SPFA，所以我们使用SPFA来求解。</p>
<p style="">对于SPFA来找负环，可以建立一个 <span class="katex-inline"><span class="katex">
   <math xmlns="http://www.w3.org/1998/Math/MathML">
    <semantics>
     <mrow><mi>c</mi><mi>n</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">cnt</annotation>
    </semantics>
   </math>
  </span></span> 数组，我们定义 𝑐𝑛𝑡[𝑖] 表示点 𝑖 距离源点经过的边数 每次 𝑖 → 𝑗 转移的时候 𝑐𝑛𝑡[𝑗] = 𝑐𝑛𝑡[𝑖] + 1 如果有点的 𝑐𝑛𝑡 大于等于 𝑛 时说明有负环，就直接输出 <code>Forever love</code></p>
<p style="">多说无益，我们看代码：</p>
<pre><code class="language-cpp">#include &lt;bits/stdc++.h&gt;
#define ll long long
using namespace std;
// N是数组大小，INF用来给dis赋初始值，即极大值
const int N = 1000 + 5, INF = 100000000;
int n, m;
vector&lt;vector&lt;pair&lt;int, int&gt;&gt;&gt; e(N); // 比较奇葩的STL写法，不喜欢的可以写结构体
ll dis[N]; // 记录从起点到任意点的最短距离的数组
bool vis[N]; // 判断任意点是否在队列中
int cnt[N]; // 记录任意点的出队次数，用来判断负环
void spfa(int s) {
	// SPFA的初始化
	fill(dis + 1, dis + n + 1, INF); 
	fill(vis + 1, vis + n + 1, false);
	fill(cnt + 1, cnt + n + 1, 0);
	dis[s] = 0, vis[s] = true;
	queue&lt;int&gt; q;
	q.emplace(s);
	
	// SPFA
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		vis[u] = false; // 标记点u不在队列中了
		for (pair&lt;int, int&gt; tmp : e[u]) { //适配C++14的写法
			int v, w;
			tie(v, w) = tmp;
			if (dis[v] &gt; dis[u] + w) {
				dis[v] = dis[u] + w;
				cnt[v] = cnt[u] + 1; // 找负环
				if (cnt[v] &gt;= n) {
					cout &lt;&lt; "Forever love\n"; // 有负环
					exit(0);
				}
				if (!vis[v]) {
					vis[v] = true; // 点v在队列中了
					q.emplace(v); // 把点v加入队列
				}
			}
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin &gt;&gt; n &gt;&gt; m;
	for (int i = 1; i &lt;= m; ++i) {
		int u, v, w;
		cin &gt;&gt; u &gt;&gt; v &gt;&gt; w;
		e[u].emplace_back(v, -w); // 对边权取反，方便处理
	}
	spfa(1); // 从小明到小红
	ll ans1 = dis[n];
	spfa(n); // 从小红到小明
	ll ans2 = dis[1];
	cout &lt;&lt; min(ans1, ans2) &lt;&lt; "\n"; // 对两个答案取较小值
	return 0;
}</code></pre>
<p style=""></p>
<p style="">代码提交结果如下：</p>
<figure data-content-type="image" style="display: flex; flex-direction: column;">
 <img src="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-21%2520103233.png&amp;size=m" width="1222px">
</figure>
<p style=""></p>]]></description><guid isPermaLink="false">/archives/1774059454871</guid><dc:creator>PYM</dc:creator><enclosure url="https://pym.plus/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=%2Fupload%2F%25E6%2589%25B9%25E6%25B3%25A8%25202026-03-21%2520102012.png&amp;size=m" type="image/jpeg" length="77169"/><category>C++</category><category>题解</category><pubDate>Sat, 21 Mar 2026 03:00:46 GMT</pubDate></item></channel></rss>