<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>元素的笔记</title>
  <icon>https://www.ptoe.cc/icon.png</icon>
  <subtitle>技术创造新生</subtitle>
  <link href="https://www.ptoe.cc/atom.xml" rel="self"/>
  
  <link href="https://www.ptoe.cc/"/>
  <updated>2026-01-24T18:17:03.976Z</updated>
  <id>https://www.ptoe.cc/</id>
  
  <author>
    <name>元素</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>P1962 斐波那契数列</title>
    <link href="https://www.ptoe.cc/2026/01/24/p1962.html"/>
    <id>https://www.ptoe.cc/2026/01/24/p1962.html</id>
    <published>2026-01-24T14:42:35.000Z</published>
    <updated>2026-01-24T18:17:03.976Z</updated>
    
    
    <summary type="html">&lt;h2 id=&quot;题目描述&quot;&gt;题目描述&lt;/h2&gt;
&lt;p&gt;大家都知道，斐波那契数列是满足如下性质的一个数列：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;$$F_n = &#92;left&#92;{&#92;begin{aligned} 1 &#92;space (n
&#92;le 2) &#92;&#92; F_{n-1}+F_{n-2} &#92;space (n&#92;ge 3)
&#92;end{aligned}&#92;right.$$&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;请你求出 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;F&lt;/em&gt;&lt;sub&gt;&lt;em&gt;n&lt;/em&gt;&lt;/sub&gt; mod  10&lt;sup&gt;9&lt;/sup&gt; + 7&lt;/span&gt;
的值。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="数学" scheme="https://www.ptoe.cc/tags/mathematics/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
    <category term="递归" scheme="https://www.ptoe.cc/tags/recursion/"/>
    
  </entry>
  
  <entry>
    <title>P14923 [GESP202512 八级] 猫和老鼠</title>
    <link href="https://www.ptoe.cc/2026/01/18/p14923.html"/>
    <id>https://www.ptoe.cc/2026/01/18/p14923.html</id>
    <published>2026-01-18T07:06:19.000Z</published>
    <updated>2026-01-24T18:06:26.081Z</updated>
    
    
    <summary type="html">&lt;p&gt;猫和老鼠所在的庄园可以视为一张由 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt; 个点和 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt;
条带权无向边构成的连通图。结点依次以 &lt;span
class=&quot;math inline&quot;&gt;1, 2, …, &lt;em&gt;n&lt;/em&gt;&lt;/span&gt; 编号，结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt;（&lt;span
class=&quot;math inline&quot;&gt;1 ≤ &lt;em&gt;i&lt;/em&gt; ≤ &lt;em&gt;n&lt;/em&gt;&lt;/span&gt;）有价值为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;c&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt; 的奶酪。在
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt; 条带权无向边中，第 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt;（&lt;span
class=&quot;math inline&quot;&gt;1 ≤ &lt;em&gt;i&lt;/em&gt; ≤ &lt;em&gt;m&lt;/em&gt;&lt;/span&gt;）条无向边连接结点
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;u&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt; 与结点
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;v&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;，边权
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;w&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;
表示猫和老鼠通过这条边所需的时间。&lt;/p&gt;
&lt;p&gt;猫窝位于结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;&lt;/span&gt;，老鼠洞位于结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;b&lt;/em&gt;&lt;/span&gt;。对于老鼠而言，结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;u&lt;/em&gt;&lt;/span&gt;
是&lt;strong&gt;安全的&lt;/strong&gt;当且仅当：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;老鼠能规划一条从结点 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;u&lt;/em&gt;&lt;/span&gt;
出发逃往老鼠洞的路径，使得对于路径上任意结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;x&lt;/em&gt;&lt;/span&gt;（包括结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;u&lt;/em&gt;&lt;/span&gt; 与老鼠洞）都有：猫从猫窝出发到结点
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;x&lt;/em&gt;&lt;/span&gt;
的最短时间&lt;strong&gt;严格大于&lt;/strong&gt;老鼠从结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;u&lt;/em&gt;&lt;/span&gt;
&lt;strong&gt;沿这条路径&lt;/strong&gt;前往结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;x&lt;/em&gt;&lt;/span&gt; 所需的时间。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;老鼠在拿取安全结点的奶酪时不存在被猫抓住的可能，但在拿取不是安全结点的奶酪时则不一定。为了确保万无一失，老鼠决定只拿取安全结点放置的奶酪。请你计算老鼠所能拿到的奶酪价值之和。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="GESP" scheme="https://www.ptoe.cc/tags/gesp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="最短路" scheme="https://www.ptoe.cc/tags/shortest-path/"/>
    
    <category term="最大瓶颈路" scheme="https://www.ptoe.cc/tags/maximum-bottleneck-path/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="数学" scheme="https://www.ptoe.cc/tags/mathematics/"/>
    
    <category term="深度优先搜索" scheme="https://www.ptoe.cc/tags/depth-first-search/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
  </entry>
  
  <entry>
    <title>P11380 [GESP202412 八级] 排队</title>
    <link href="https://www.ptoe.cc/2025/12/25/p11380.html"/>
    <id>https://www.ptoe.cc/2025/12/25/p11380.html</id>
    <published>2025-12-25T10:53:57.000Z</published>
    <updated>2026-01-24T18:06:26.079Z</updated>
    
    
    <summary type="html">&lt;h2 id=&quot;题目描述&quot;&gt;题目描述&lt;/h2&gt;
&lt;p&gt;小杨所在班级共有 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt;
位同学，依次以 &lt;span class=&quot;math inline&quot;&gt;1, 2, …, &lt;em&gt;n&lt;/em&gt;&lt;/span&gt;
标号。这 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt;
位同学想排成一行队伍，其中有些同学之间关系非常好，在队伍里需要排在相邻的位置。具体来说，有
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt; 对这样的关系（&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt; 是一个非负整数）。当 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt; ≥ 1&lt;/span&gt; 时，第 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt; 对关系（&lt;span
class=&quot;math inline&quot;&gt;1 ≤ &lt;em&gt;i&lt;/em&gt; ≤ &lt;em&gt;m&lt;/em&gt;&lt;/span&gt;）给出 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;, &lt;em&gt;b&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;，表示排队时编号为
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;
的同学需要排在编号为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;b&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;
的同学前面，并且两人在队伍中相邻。&lt;/p&gt;
&lt;p&gt;现在小杨想知道总共有多少种排队方式。由于答案可能很大，你只需要求出答案对
&lt;span class=&quot;math inline&quot;&gt;10&lt;sup&gt;9&lt;/sup&gt; + 7&lt;/span&gt; 取模的结果。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="GESP" scheme="https://www.ptoe.cc/tags/gesp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="数学" scheme="https://www.ptoe.cc/tags/mathematics/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
    <category term="排序算法" scheme="https://www.ptoe.cc/tags/sorting-algorithm/"/>
    
    <category term="递归" scheme="https://www.ptoe.cc/tags/recursion/"/>
    
    <category term="模拟" scheme="https://www.ptoe.cc/tags/simulation/"/>
    
  </entry>
  
  <entry>
    <title>[C++] 菜鸟驿站模拟</title>
    <link href="https://www.ptoe.cc/2025/12/25/cainiaosim.html"/>
    <id>https://www.ptoe.cc/2025/12/25/cainiaosim.html</id>
    <published>2025-12-25T03:19:17.000Z</published>
    <updated>2026-01-24T18:06:26.079Z</updated>
    
    
    <summary type="html">&lt;p&gt;闲着没事写的&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="模拟" scheme="https://www.ptoe.cc/tags/simulation/"/>
    
  </entry>
  
  <entry>
    <title>P1668 [USACO04DEC] Cleaning Shifts S</title>
    <link href="https://www.ptoe.cc/2025/10/04/p1668.html"/>
    <id>https://www.ptoe.cc/2025/10/04/p1668.html</id>
    <published>2025-10-04T07:34:44.000Z</published>
    <updated>2026-01-24T18:06:26.076Z</updated>
    
    
    <summary type="html">&lt;p&gt;一天有 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt;(1 ≤ &lt;em&gt;T&lt;/em&gt; ≤ 10&lt;sup&gt;6&lt;/sup&gt;)&lt;/span&gt;
个时段。约翰正打算安排他的 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt;(1 ≤ &lt;em&gt;N&lt;/em&gt; ≤ 2.5 × 10&lt;sup&gt;4&lt;/sup&gt;)&lt;/span&gt;
只奶牛来值班，打扫打扫牛棚卫生。每只奶牛都有自己的空闲时间段 $ &lt;a
href=&quot;1&#92;le%20S_i&#92;le%20E_i&#92;le%20T&quot;&gt;S_i,E_i&lt;/a&gt;$，只能把空闲的奶牛安排出来值班。而且，每个时间段必需有奶牛在值班。&lt;/p&gt;
&lt;p&gt;那么，最少需要动用多少奶牛参与值班呢？如果没有办法安排出合理的方案，就输出
&lt;span class=&quot;math inline&quot;&gt;−1&lt;/span&gt;。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="最短路" scheme="https://www.ptoe.cc/tags/shortest-path/"/>
    
    <category term="最大瓶颈路" scheme="https://www.ptoe.cc/tags/maximum-bottleneck-path/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="Python" scheme="https://www.ptoe.cc/tags/python/"/>
    
    <category term="贪心算法" scheme="https://www.ptoe.cc/tags/greedy-algorithm/"/>
    
    <category term="区间覆盖" scheme="https://www.ptoe.cc/tags/interval-coverage/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P3372 【模板】线段树 1</title>
    <link href="https://www.ptoe.cc/2025/07/25/p3372.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p3372.html</id>
    <published>2025-07-25T07:10:27.000Z</published>
    <updated>2026-01-24T18:06:26.074Z</updated>
    
    
    <summary type="html">&lt;p&gt;如题，已知一个数列 &lt;span
class=&quot;math inline&quot;&gt;{&lt;em&gt;a&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;}&lt;/span&gt;，你需要进行下面两种操作：&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;将某区间每一个数加上 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;k&lt;/em&gt;&lt;/span&gt;。&lt;/li&gt;
&lt;li&gt;求出某区间每一个数的和。&lt;/li&gt;
&lt;/ol&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="树" scheme="https://www.ptoe.cc/tags/tree/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
    <category term="区间覆盖" scheme="https://www.ptoe.cc/tags/interval-coverage/"/>
    
    <category term="递归" scheme="https://www.ptoe.cc/tags/recursion/"/>
    
  </entry>
  
  <entry>
    <title>[Python] P2866 [USACO06NOV] Bad Hair Day S</title>
    <link href="https://www.ptoe.cc/2025/07/25/p2866.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p2866.html</id>
    <published>2025-07-25T07:06:16.000Z</published>
    <updated>2026-01-24T18:06:26.070Z</updated>
    
    
    <summary type="html">&lt;p&gt;农夫约翰有 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt;&lt;/span&gt;
头奶牛正在过乱头发节。&lt;/p&gt;
&lt;p&gt;每一头牛都站在同一排面朝右，它们被从左到右依次编号为 &lt;span
class=&quot;math inline&quot;&gt;1, 2, ⋯, &lt;em&gt;N&lt;/em&gt;&lt;/span&gt;。编号为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt; 的牛身高为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;。第 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt;&lt;/span&gt; 头牛在最前面，而第 &lt;span
class=&quot;math inline&quot;&gt;1&lt;/span&gt; 头牛在最后面。&lt;/p&gt;
&lt;p&gt;对于第 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt;
头牛&lt;strong&gt;前面&lt;/strong&gt;的第 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;j&lt;/em&gt;&lt;/span&gt; 头牛，如果 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt; &amp;gt; &lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt; + 1&lt;/sub&gt;, &lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt; &amp;gt; &lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt; + 2&lt;/sub&gt;, ⋯, &lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt; &amp;gt; &lt;em&gt;h&lt;/em&gt;&lt;sub&gt;&lt;em&gt;j&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;，那么认为第
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt; 头牛可以看到第 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt; + 1&lt;/span&gt; 到第 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;j&lt;/em&gt;&lt;/span&gt; 头牛。&lt;/p&gt;
&lt;p&gt;定义 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;C&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;
为第 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt;
头牛所能看到的牛的数量。请帮助农夫约翰求出 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;C&lt;/em&gt;&lt;sub&gt;1&lt;/sub&gt; + &lt;em&gt;C&lt;/em&gt;&lt;sub&gt;2&lt;/sub&gt; + ⋯ + &lt;em&gt;C&lt;/em&gt;&lt;sub&gt;&lt;em&gt;N&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="Python" scheme="https://www.ptoe.cc/tags/python/"/>
    
    <category term="单调栈" scheme="https://www.ptoe.cc/tags/monotonic-stack/"/>
    
  </entry>
  
  <entry>
    <title>[Python] P6503 [COCI 2010/2011 #3] DIFERENCIJA</title>
    <link href="https://www.ptoe.cc/2025/07/25/p6503.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p6503.html</id>
    <published>2025-07-25T07:03:48.000Z</published>
    <updated>2026-01-24T18:06:26.074Z</updated>
    
    
    <summary type="html">&lt;p&gt;给出一个长度为 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt; 的序列
&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;，求出下列式子的值：&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;math display&quot;&gt;$$&#92;sum_{i=1}^{n} &#92;sum_{j=i}^{n}
(&#92;max_{i&#92;le k&#92;le j} a_k-&#92;min_{i&#92;le k&#92;le j} a_k)$$&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;即定义一个子序列的权值为序列内最大值与最小值的差。求出所有连续子序列的权值和。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="数学" scheme="https://www.ptoe.cc/tags/mathematics/"/>
    
    <category term="Python" scheme="https://www.ptoe.cc/tags/python/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
    <category term="排序算法" scheme="https://www.ptoe.cc/tags/sorting-algorithm/"/>
    
    <category term="贪心算法" scheme="https://www.ptoe.cc/tags/greedy-algorithm/"/>
    
    <category term="单调栈" scheme="https://www.ptoe.cc/tags/monotonic-stack/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P1099 [NOIP 2007 提高组] 树网的核</title>
    <link href="https://www.ptoe.cc/2025/07/25/p1099.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p1099.html</id>
    <published>2025-07-25T06:35:31.000Z</published>
    <updated>2026-01-24T18:06:26.067Z</updated>
    
    
    <summary type="html">&lt;p&gt;设 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt; = (&lt;em&gt;V&lt;/em&gt;, &lt;em&gt;E&lt;/em&gt;, &lt;em&gt;W&lt;/em&gt;)&lt;/span&gt;
是一个无圈且连通的无向图（也称为无根树），每条边都有正整数的权，我们称
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt;&lt;/span&gt;
为树网（&lt;code&gt;treenetwork&lt;/code&gt;），其中 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;V&lt;/em&gt;&lt;/span&gt;，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;E&lt;/em&gt;&lt;/span&gt; 分别表示结点与边的集合，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;W&lt;/em&gt;&lt;/span&gt; 表示各边长度的集合，并设 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt;&lt;/span&gt; 有 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt; 个结点。&lt;/p&gt;
&lt;p&gt;路径：树网中任何两结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;&lt;/span&gt;，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;b&lt;/em&gt;&lt;/span&gt; 都存在唯一的一条简单路径，用 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;d&lt;/em&gt;(&lt;em&gt;a&lt;/em&gt;, &lt;em&gt;b&lt;/em&gt;)&lt;/span&gt; 表示以
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;, &lt;em&gt;b&lt;/em&gt;&lt;/span&gt;
为端点的路径的长度，它是该路径上各边长度之和。我们称 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;d&lt;/em&gt;(&lt;em&gt;a&lt;/em&gt;, &lt;em&gt;b&lt;/em&gt;)&lt;/span&gt; 为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;, &lt;em&gt;b&lt;/em&gt;&lt;/span&gt; 两结点间的距离。&lt;/p&gt;
&lt;p&gt;&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;D&lt;/em&gt;(&lt;em&gt;v&lt;/em&gt;, &lt;em&gt;P&lt;/em&gt;) = min {&lt;em&gt;d&lt;/em&gt;(&lt;em&gt;v&lt;/em&gt;, &lt;em&gt;u&lt;/em&gt;)}&lt;/span&gt;,
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;u&lt;/em&gt;&lt;/span&gt; 为路径 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;P&lt;/em&gt;&lt;/span&gt; 上的结点。&lt;/p&gt;
&lt;p&gt;树网的直径：树网中最长的路径称为树网的直径。对于给定的树网 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt;&lt;/span&gt;，直径不一定是唯一的，但可以证明：各直径的中点（不一定恰好是某个结点，可能在某条边的内部）是唯一的，我们称该点为树网的中心。&lt;/p&gt;
&lt;p&gt;偏心距 &lt;span class=&quot;math inline&quot;&gt;ECC(&lt;em&gt;F&lt;/em&gt;)&lt;/span&gt;：树网 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt;&lt;/span&gt; 中距路径 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;F&lt;/em&gt;&lt;/span&gt; 最远的结点到路径 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;F&lt;/em&gt;&lt;/span&gt; 的距离，即&lt;/p&gt;
&lt;p&gt;&lt;span
class=&quot;math display&quot;&gt;ECC(&lt;em&gt;F&lt;/em&gt;) = max {&lt;em&gt;D&lt;/em&gt;(&lt;em&gt;v&lt;/em&gt;, &lt;em&gt;F&lt;/em&gt;), &lt;em&gt;v&lt;/em&gt; ∈ &lt;em&gt;V&lt;/em&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;任务：对于给定的树网 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt; = (&lt;em&gt;V&lt;/em&gt;, &lt;em&gt;E&lt;/em&gt;, &lt;em&gt;W&lt;/em&gt;)&lt;/span&gt;
和非负整数 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt;&lt;/span&gt;，求一个路径 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;F&lt;/em&gt;&lt;/span&gt;，他是某直径上的一段路径（该路径两端均为树网中的结点），其长度不超过
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt;&lt;/span&gt;（可以等于 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt;&lt;/span&gt;），使偏心距 &lt;span
class=&quot;math inline&quot;&gt;ECC(&lt;em&gt;F&lt;/em&gt;)&lt;/span&gt; 最小。我们称这个路径为树网
&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;T&lt;/em&gt; = (&lt;em&gt;V&lt;/em&gt;, &lt;em&gt;E&lt;/em&gt;, &lt;em&gt;W&lt;/em&gt;)&lt;/span&gt;
的核（&lt;code&gt;Core&lt;/code&gt;）。必要时，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;F&lt;/em&gt;&lt;/span&gt;
可以退化为某个结点。一般来说，在上述定义下，核不一定只有一个，但最小偏心距是唯一的。&lt;/p&gt;
&lt;p&gt;下面的图给出了树网的一个实例。图中，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;A&lt;/em&gt; − &lt;em&gt;B&lt;/em&gt;&lt;/span&gt; 与 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;A&lt;/em&gt; − &lt;em&gt;C&lt;/em&gt;&lt;/span&gt; 是两条直径，长度均为
&lt;span class=&quot;math inline&quot;&gt;20&lt;/span&gt;。点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;W&lt;/em&gt;&lt;/span&gt; 是树网的中心，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;E&lt;/em&gt;&lt;em&gt;F&lt;/em&gt;&lt;/span&gt; 边的长度为 &lt;span
class=&quot;math inline&quot;&gt;5&lt;/span&gt;。如果指定 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt; = 11&lt;/span&gt;，则树网的核为路径&lt;code&gt;DEFG&lt;/code&gt;（也可以取为路径&lt;code&gt;DEF&lt;/code&gt;），偏心距为
&lt;span class=&quot;math inline&quot;&gt;8&lt;/span&gt;。如果指定 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt; = 0&lt;/span&gt;（或 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt; = 1&lt;/span&gt;、&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;s&lt;/em&gt; = 2&lt;/span&gt;），则树网的核为结点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;F&lt;/em&gt;&lt;/span&gt;，偏心距为 &lt;span
class=&quot;math inline&quot;&gt;12&lt;/span&gt;。&lt;/p&gt;
&lt;p&gt;&lt;img data-src=&quot;https://cdn.luogu.com.cn/upload/image_hosting/oms5c6rq.png&quot; /&gt;&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="最短路" scheme="https://www.ptoe.cc/tags/shortest-path/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="树" scheme="https://www.ptoe.cc/tags/tree/"/>
    
    <category term="深度优先搜索" scheme="https://www.ptoe.cc/tags/depth-first-search/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
    <category term="NOIP" scheme="https://www.ptoe.cc/tags/noip/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P2114 [NOI2014] 起床困难综合症</title>
    <link href="https://www.ptoe.cc/2025/07/25/p2114.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p2114.html</id>
    <published>2025-07-25T06:21:22.000Z</published>
    <updated>2026-01-24T18:06:26.069Z</updated>
    
    
    <summary type="html">&lt;p&gt;&lt;span class=&quot;math inline&quot;&gt;21&lt;/span&gt;
世纪，许多人得了一种奇怪的病：起床困难综合症，其临床表现为：起床难，起床后精神不佳。作为一名青春阳光好少年，atm
一直坚持与起床困难综合症作斗争。通过研究相关文献，他找到了该病的发病原因：在深邃的太平洋海底中，出现了一条名为
drd 的巨龙，它掌握着睡眠之精髓，能随意延长大家的睡眠时间。正是由于 drd
的活动，起床困难综合症愈演愈烈，以惊人的速度在世界上传播。为了彻底消灭这种病，atm
决定前往海底，消灭这条恶龙。历经千辛万苦，atm 终于来到了 drd
所在的地方，准备与其展开艰苦卓绝的战斗。drd
有着十分特殊的技能，他的防御战线能够使用一定的运算来改变他受到的伤害。具体说来，drd
的防御战线由 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt;
扇防御门组成。每扇防御门包括一个运算 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;o&lt;/em&gt;&lt;em&gt;p&lt;/em&gt;&lt;/span&gt; 和一个参数 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;t&lt;/em&gt;&lt;/span&gt;，其中运算一定是 &lt;span
class=&quot;math inline&quot;&gt;OR, XOR, AND&lt;/span&gt;
中的一种，参数则一定为非负整数。如果还未通过防御门时攻击力为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;x&lt;/em&gt;&lt;/span&gt;，则其通过这扇防御门后攻击力将变为
&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;x&lt;/em&gt; &lt;em&gt;o&lt;/em&gt;&lt;em&gt;p&lt;/em&gt; &lt;em&gt;t&lt;/em&gt;&lt;/span&gt;。最终
drd 受到的伤害为对方初始攻击力 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;x&lt;/em&gt;&lt;/span&gt; 依次经过所有 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt; 扇防御门后转变得到的攻击力。&lt;/p&gt;
&lt;p&gt;由于 atm 水平有限，他的初始攻击力只能为 &lt;span
class=&quot;math inline&quot;&gt;0&lt;/span&gt; 到 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt;
之间的一个整数（即他的初始攻击力只能在 &lt;span
class=&quot;math inline&quot;&gt;0, 1, …, &lt;em&gt;m&lt;/em&gt;&lt;/span&gt;
中任选，但在通过防御门之后的攻击力不受 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt;
的限制）。为了节省体力，他希望通过选择合适的初始攻击力使得他的攻击能让
drd 受到最大的伤害，请你帮他计算一下，他的一次攻击最多能使 drd
受到多少伤害。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="位运算" scheme="https://www.ptoe.cc/tags/bit-manipulation/"/>
    
    <category term="NOIP" scheme="https://www.ptoe.cc/tags/noip/"/>
    
  </entry>
  
  <entry>
    <title>[C++] 多线程计算π</title>
    <link href="https://www.ptoe.cc/2025/07/25/cal-pi.html"/>
    <id>https://www.ptoe.cc/2025/07/25/cal-pi.html</id>
    <published>2025-07-25T06:18:59.000Z</published>
    <updated>2026-01-24T18:06:26.063Z</updated>
    
    
    <summary type="html">&lt;p&gt;让 AI 写了个多线程计算 π 的程序，非常适合跑分（（（&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="数学" scheme="https://www.ptoe.cc/tags/mathematics/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P11378 [GESP202412 七级] 燃烧</title>
    <link href="https://www.ptoe.cc/2025/07/25/p11378.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p11378.html</id>
    <published>2025-07-25T06:11:41.000Z</published>
    <updated>2026-01-24T18:06:26.069Z</updated>
    
    
    <summary type="html">&lt;p&gt;小杨有一棵包含 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt;
个节点的树，其中节点的编号从 &lt;span class=&quot;math inline&quot;&gt;1&lt;/span&gt; 到 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt;。节点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;i&lt;/em&gt;&lt;/span&gt; 的权值为 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;&lt;sub&gt;&lt;em&gt;i&lt;/em&gt;&lt;/sub&gt;&lt;/span&gt;。&lt;/p&gt;
&lt;p&gt;小杨可以选择一个初始节点引燃，每个燃烧的节点会将其相邻节点中权值&lt;strong&gt;严格小于&lt;/strong&gt;自身权值的在节点间扩散直到不会有新的节点被引燃。&lt;/p&gt;
&lt;p&gt;小杨想知道在合理选择初始节点的情况下，最多可以燃烧多少个节点。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="GESP" scheme="https://www.ptoe.cc/tags/gesp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="树" scheme="https://www.ptoe.cc/tags/tree/"/>
    
    <category term="深度优先搜索" scheme="https://www.ptoe.cc/tags/depth-first-search/"/>
    
  </entry>
  
  <entry>
    <title>[C++] B3874 [GESP202309 六级] 小杨的握手问题</title>
    <link href="https://www.ptoe.cc/2025/07/25/b3874.html"/>
    <id>https://www.ptoe.cc/2025/07/25/b3874.html</id>
    <published>2025-07-25T05:44:10.000Z</published>
    <updated>2026-01-24T18:06:26.061Z</updated>
    
    
    <summary type="html">&lt;p&gt;小杨的班级里共有 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt;&lt;/span&gt;
名同学，学号从 &lt;span class=&quot;math inline&quot;&gt;0&lt;/span&gt; 至 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt; − 1&lt;/span&gt;。&lt;/p&gt;
&lt;p&gt;某节课上，老师安排全班同学进行一次握手游戏，具体规则如下：老师安排了一个顺序，让全班
&lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt;&lt;/span&gt;
名同学依次进入教室。每位同学进入教室时，需要和
&lt;strong&gt;已经在教室内&lt;/strong&gt; 且 &lt;strong&gt;学号小于自己&lt;/strong&gt;
的同学握手。&lt;/p&gt;
&lt;p&gt;现在，小杨想知道，整个班级总共会进行多少次握手。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;提示：可以考虑使用归并排序进行降序排序，并在此过程中求解。&lt;/strong&gt;&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="GESP" scheme="https://www.ptoe.cc/tags/gesp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="动态规划" scheme="https://www.ptoe.cc/tags/dynamic-programming/"/>
    
    <category term="排序算法" scheme="https://www.ptoe.cc/tags/sorting-algorithm/"/>
    
    <category term="归并排序" scheme="https://www.ptoe.cc/tags/merge-sort/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P3366 【模板】最小生成树</title>
    <link href="https://www.ptoe.cc/2025/07/25/p3366.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p3366.html</id>
    <published>2025-07-25T04:00:31.000Z</published>
    <updated>2026-01-24T18:06:26.073Z</updated>
    
    
    <summary type="html">&lt;p&gt;如题，给出一个无向图，求出最小生成树，如果该图不连通，则输出
&lt;code&gt;orz&lt;/code&gt;。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P1000 超级玛丽游戏</title>
    <link href="https://www.ptoe.cc/2025/07/25/p1000.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p1000.html</id>
    <published>2025-07-25T03:59:25.000Z</published>
    <updated>2026-01-24T18:06:26.064Z</updated>
    
    
    <summary type="html">&lt;p&gt;本题是洛谷的试机题目，可以帮助了解洛谷的使用。&lt;/p&gt;
&lt;p&gt;建议完成本题目后继续尝试 &lt;a
href=&quot;https://www.luogu.com.cn/problem/P1001&quot;&gt;P1001&lt;/a&gt;、&lt;a
href=&quot;https://www.luogu.com.cn/problem/P1008&quot;&gt;P1008&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;另外强烈推荐&lt;a
href=&quot;https://www.luogu.com.cn/discuss/show/241461&quot;&gt;新用户必读帖&lt;/a&gt;。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="模拟" scheme="https://www.ptoe.cc/tags/simulation/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P1001 A+B Problem</title>
    <link href="https://www.ptoe.cc/2025/07/25/p1001.html"/>
    <id>https://www.ptoe.cc/2025/07/25/p1001.html</id>
    <published>2025-07-25T03:02:21.000Z</published>
    <updated>2026-01-24T18:06:26.066Z</updated>
    
    
    <summary type="html">&lt;p&gt;输入两个整数 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;a&lt;/em&gt;, &lt;em&gt;b&lt;/em&gt;&lt;/span&gt;，输出它们的和（&lt;span
class=&quot;math inline&quot;&gt;|&lt;em&gt;a&lt;/em&gt;|,|&lt;em&gt;b&lt;/em&gt;| ≤ 10&lt;sup&gt;9&lt;/sup&gt;&lt;/span&gt;）。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
  </entry>
  
  <entry>
    <title>[C++] 二进制减法</title>
    <link href="https://www.ptoe.cc/2025/07/24/binary-minus.html"/>
    <id>https://www.ptoe.cc/2025/07/24/binary-minus.html</id>
    <published>2025-07-24T14:34:44.000Z</published>
    <updated>2026-01-24T18:06:26.052Z</updated>
    
    
    <summary type="html">&lt;p&gt;闲着没事研究了下二进制减法。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="位运算" scheme="https://www.ptoe.cc/tags/bit-manipulation/"/>
    
    <category term="数学" scheme="https://www.ptoe.cc/tags/mathematics/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P1008 [NOIP 1998 普及组] 三连击</title>
    <link href="https://www.ptoe.cc/2025/07/24/p1008.html"/>
    <id>https://www.ptoe.cc/2025/07/24/p1008.html</id>
    <published>2025-07-24T14:29:45.000Z</published>
    <updated>2026-01-24T18:06:26.054Z</updated>
    
    
    <summary type="html">&lt;p&gt;洛谷签到题（真·签到）&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="递归" scheme="https://www.ptoe.cc/tags/recursion/"/>
    
    <category term="NOIP" scheme="https://www.ptoe.cc/tags/noip/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P3916 图的遍历</title>
    <link href="https://www.ptoe.cc/2025/07/24/p3916.html"/>
    <id>https://www.ptoe.cc/2025/07/24/p3916.html</id>
    <published>2025-07-24T14:11:08.000Z</published>
    <updated>2026-01-24T18:06:26.058Z</updated>
    
    
    <summary type="html">&lt;p&gt;给出 &lt;span class=&quot;math inline&quot;&gt;&lt;em&gt;N&lt;/em&gt;&lt;/span&gt; 个点，&lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;M&lt;/em&gt;&lt;/span&gt; 条边的有向图，对于每个点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;v&lt;/em&gt;&lt;/span&gt;，令 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;A&lt;/em&gt;(&lt;em&gt;v&lt;/em&gt;)&lt;/span&gt; 表示从点 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;v&lt;/em&gt;&lt;/span&gt;
出发，能到达的编号最大的点。现在请求出 &lt;span
class=&quot;math inline&quot;&gt;&lt;em&gt;A&lt;/em&gt;(1), &lt;em&gt;A&lt;/em&gt;(2), …, &lt;em&gt;A&lt;/em&gt;(&lt;em&gt;N&lt;/em&gt;)&lt;/span&gt;
的值。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="图论" scheme="https://www.ptoe.cc/tags/graph-theory/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="深度优先搜索" scheme="https://www.ptoe.cc/tags/depth-first-search/"/>
    
  </entry>
  
  <entry>
    <title>[C++] P7910 [CSP-J 2021] 插入排序</title>
    <link href="https://www.ptoe.cc/2025/07/24/p7910.html"/>
    <id>https://www.ptoe.cc/2025/07/24/p7910.html</id>
    <published>2025-07-24T14:07:54.000Z</published>
    <updated>2026-01-24T18:06:26.060Z</updated>
    
    
    <summary type="html">&lt;p&gt;插入排序是一种非常常见且简单的排序算法。小 Z 是一名大一的新生，今天 H
老师刚刚在上课的时候讲了插入排序算法。&lt;/p&gt;</summary>
    
    
    
    <category term="编程" scheme="https://www.ptoe.cc/categories/programming/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/categories/programming/algorithm/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/categories/programming/algorithm/data-structure/"/>
    
    
    <category term="C++" scheme="https://www.ptoe.cc/tags/cpp/"/>
    
    <category term="数据结构" scheme="https://www.ptoe.cc/tags/data-structure/"/>
    
    <category term="算法" scheme="https://www.ptoe.cc/tags/algorithm/"/>
    
    <category term="编程" scheme="https://www.ptoe.cc/tags/programming/"/>
    
    <category term="排序算法" scheme="https://www.ptoe.cc/tags/sorting-algorithm/"/>
    
    <category term="CSP-J" scheme="https://www.ptoe.cc/tags/csp-j/"/>
    
    <category term="插入排序" scheme="https://www.ptoe.cc/tags/insertion-sort/"/>
    
  </entry>
  
</feed>
