<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%2F07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90</id>
	<title>04-数据结构/07-STL实用例子 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%2F07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;action=history"/>
	<updated>2026-05-20T22:20:05Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=343&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=343&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:10Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 18:12的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-342:rev-343 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=342&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=342&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:50的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-243:rev-342 --&gt;
&lt;/table&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=243&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=243&amp;oldid=prev"/>
		<updated>2026-05-20T16:25:29Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:25的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-242:rev-243 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=242&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/07-STL%E5%AE%9E%E7%94%A8%E4%BE%8B%E5%AD%90&amp;diff=242&amp;oldid=prev"/>
		<updated>2026-05-20T16:22:29Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== 明明的随机数 ==&lt;br /&gt;
&lt;br /&gt;
排序 + 去重。&lt;br /&gt;
&lt;br /&gt;
=== 使用 &amp;lt;code&amp;gt;sort&amp;lt;/code&amp;gt; + &amp;lt;code&amp;gt;unique&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;bits/stdc++.h&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int n;&lt;br /&gt;
vector&amp;lt;int&amp;gt; a;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    ios::sync_with_stdio(false);&lt;br /&gt;
    cin.tie(0);&lt;br /&gt;
    cin &amp;gt;&amp;gt; n;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        int x;&lt;br /&gt;
        cin &amp;gt;&amp;gt; x;&lt;br /&gt;
        a.push_back(x);&lt;br /&gt;
    }&lt;br /&gt;
    sort(a.begin(), a.end());&lt;br /&gt;
    int nn = unique(a.begin(), a.end()) - a.begin();&lt;br /&gt;
    cout &amp;lt;&amp;lt; nn &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
    for (int i = 0; i &amp;lt; nn; i++)&lt;br /&gt;
        cout &amp;lt;&amp;lt; a[i] &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 计数排序 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
const int MAXAI = 1000;&lt;br /&gt;
int cnt[MAXAI + 5];&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int n, ans = 0;&lt;br /&gt;
    cin &amp;gt;&amp;gt; n;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        int x;&lt;br /&gt;
        cin &amp;gt;&amp;gt; x;&lt;br /&gt;
        cnt[x]++;&lt;br /&gt;
        if (cnt[x] == 1)&lt;br /&gt;
            ans++;&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; ans &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= MAXAI; i++)&lt;br /&gt;
        if (cnt[i] &amp;gt;= 1)&lt;br /&gt;
            cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== bitset ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
const int MAXAI = 1000;&lt;br /&gt;
bitset&amp;lt;MAXAI + 1&amp;gt; cnt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int n;&lt;br /&gt;
    cin &amp;gt;&amp;gt; n;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        int x;&lt;br /&gt;
        cin &amp;gt;&amp;gt; x;&lt;br /&gt;
        cnt.set(x);&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; cnt.count() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= MAXAI; i++)&lt;br /&gt;
        if (cnt[i])&lt;br /&gt;
            cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 合并果子（priority_queue） ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;bits/stdc++.h&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    ios::sync_with_stdio(false);&lt;br /&gt;
    cin.tie(0);&lt;br /&gt;
    int n;&lt;br /&gt;
    cin &amp;gt;&amp;gt; n;&lt;br /&gt;
    priority_queue&amp;lt;int, vector&amp;lt;int&amp;gt;, greater&amp;lt;int&amp;gt;&amp;gt; pq;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    {&lt;br /&gt;
        int x;&lt;br /&gt;
        cin &amp;gt;&amp;gt; x;&lt;br /&gt;
        pq.push(x);&lt;br /&gt;
    }&lt;br /&gt;
    long long ans = 0;&lt;br /&gt;
    while (pq.size() &amp;gt; 1)&lt;br /&gt;
    {&lt;br /&gt;
        int a = pq.top(); pq.pop();&lt;br /&gt;
        int b = pq.top(); pq.pop();&lt;br /&gt;
        ans += a + b;&lt;br /&gt;
        pq.push(a + b);&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; ans;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 全排列（&amp;lt;code&amp;gt;next_permutation&amp;lt;/code&amp;gt;） ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int n;&lt;br /&gt;
int a[10];&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    cin &amp;gt;&amp;gt; n;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
        a[i] = i;&lt;br /&gt;
    do&lt;br /&gt;
    {&lt;br /&gt;
        for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
            cout &amp;lt;&amp;lt; &amp;quot;    &amp;quot; &amp;lt;&amp;lt; a[i];&lt;br /&gt;
        cout &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
    } while (next_permutation(a + 1, a + n + 1));&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 求第 k 大数（&amp;lt;code&amp;gt;nth_element&amp;lt;/code&amp;gt;） ==&lt;br /&gt;
&lt;br /&gt;
时间复杂度 &amp;lt;math&amp;gt;O(n)&amp;lt;/math&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int n, k;&lt;br /&gt;
int a[1000005];&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    cin &amp;gt;&amp;gt; n &amp;gt;&amp;gt; k;&lt;br /&gt;
    for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
        cin &amp;gt;&amp;gt; a[i];&lt;br /&gt;
    nth_element(a + 1, a + k, a + n + 1, greater&amp;lt;int&amp;gt;());&lt;br /&gt;
    cout &amp;lt;&amp;lt; a[k];&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== STL 算法速查 ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 算法 !! 说明&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sort(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 排序&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sort(begin, end, cmp)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 自定义排序&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;stable_sort(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 稳定排序&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;unique(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 去重（需先排序）&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;lower_bound(begin, end, x)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 第一个 &amp;lt;math&amp;gt;\ge x&amp;lt;/math&amp;gt; 的位置&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;upper_bound(begin, end, x)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 第一个 &amp;lt;math&amp;gt;&amp;gt; x&amp;lt;/math&amp;gt; 的位置&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;binary_search(begin, end, x)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 二分查找是否存在&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;next_permutation(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 下一个排列&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;reverse(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 反转&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;max_element(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 最大值位置&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;min_element(begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 最小值位置&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;count(begin, end, x)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 统计出现次数&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;fill(begin, end, x)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 填充&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;nth_element(begin, nth, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 找第 k 大&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;gt; 所有区间均为&amp;#039;&amp;#039;&amp;#039;左闭右开&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;[begin, end)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:数据结构]]&lt;br /&gt;
[[Category:三三文档]]&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>