<?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=10-%E6%90%9C%E7%B4%A2%2F02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2</id>
	<title>10-搜索/02-广度优先搜索 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=10-%E6%90%9C%E7%B4%A2%2F02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;action=history"/>
	<updated>2026-05-20T22:29:30Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;diff=437&amp;oldid=prev</id>
		<title>33DAI：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;diff=437&amp;oldid=prev"/>
		<updated>2026-05-20T18:24:04Z</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日 (三) 18:24的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l91&quot;&gt;第91行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第91行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:搜索]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:搜索]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:三三文档]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:三三文档]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key my_wiki:diff:1.41:old-405:rev-437:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;diff=405&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;diff=405&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:20Z</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-404:rev-405 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;diff=404&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=10-%E6%90%9C%E7%B4%A2/02-%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E6%90%9C%E7%B4%A2&amp;diff=404&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</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;
== 广度优先搜索（BFS） ==&lt;br /&gt;
&lt;br /&gt;
BFS 从起点出发，&amp;#039;&amp;#039;&amp;#039;逐层向外扩展&amp;#039;&amp;#039;&amp;#039;。使用队列实现，保证第一次访问到的路径是最短路径（边权为 &amp;lt;math&amp;gt;1&amp;lt;/math&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;
struct Node&lt;br /&gt;
{&lt;br /&gt;
    int x, y, step;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int bfs(int sx, int sy, int tx, int ty)&lt;br /&gt;
{&lt;br /&gt;
    queue&amp;lt;Node&amp;gt; q;&lt;br /&gt;
    q.push({sx, sy, 0});&lt;br /&gt;
    vis[sx][sy] = true;&lt;br /&gt;
&lt;br /&gt;
    int dx[] = {0, 0, 1, -1};&lt;br /&gt;
    int dy[] = {1, -1, 0, 0};&lt;br /&gt;
&lt;br /&gt;
    while (!q.empty())&lt;br /&gt;
    {&lt;br /&gt;
        auto [x, y, step] = q.front();&lt;br /&gt;
        q.pop();&lt;br /&gt;
&lt;br /&gt;
        if (x == tx &amp;amp;&amp;amp; y == ty)&lt;br /&gt;
            return step;&lt;br /&gt;
&lt;br /&gt;
        for (int i = 0; i &amp;lt; 4; i++)&lt;br /&gt;
        {&lt;br /&gt;
            int nx = x + dx[i];&lt;br /&gt;
            int ny = y + dy[i];&lt;br /&gt;
            if (nx &amp;lt; 1 || nx &amp;gt; n || ny &amp;lt; 1 || ny &amp;gt; m) continue;&lt;br /&gt;
            if (vis[nx][ny] || g[nx][ny] == &amp;#039;#&amp;#039;) continue;&lt;br /&gt;
            vis[nx][ny] = true;&lt;br /&gt;
            q.push({nx, ny, step + 1});&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    return -1; // 不可达&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== BFS 求最少步数 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// 从 start 到 target 的最少变化次数&lt;br /&gt;
queue&amp;lt;string&amp;gt; q;&lt;br /&gt;
map&amp;lt;string, int&amp;gt; dist;&lt;br /&gt;
&lt;br /&gt;
q.push(start);&lt;br /&gt;
dist[start] = 0;&lt;br /&gt;
&lt;br /&gt;
while (!q.empty())&lt;br /&gt;
{&lt;br /&gt;
    string u = q.front();&lt;br /&gt;
    q.pop();&lt;br /&gt;
&lt;br /&gt;
    if (u == target)&lt;br /&gt;
        return dist[u];&lt;br /&gt;
&lt;br /&gt;
    for (string v : get_next(u))&lt;br /&gt;
    {&lt;br /&gt;
        if (!dist.count(v))&lt;br /&gt;
        {&lt;br /&gt;
            dist[v] = dist[u] + 1;&lt;br /&gt;
            q.push(v);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 多源 BFS ===&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;
queue&amp;lt;pair&amp;lt;int, int&amp;gt;&amp;gt; q;&lt;br /&gt;
for (int i = 1; i &amp;lt;= n; i++)&lt;br /&gt;
    for (int j = 1; j &amp;lt;= m; j++)&lt;br /&gt;
        if (g[i][j] == &amp;#039;S&amp;#039;) // 所有起点入队&lt;br /&gt;
        {&lt;br /&gt;
            q.push({i, j});&lt;br /&gt;
            vis[i][j] = true;&lt;br /&gt;
            dis[i][j] = 0;&lt;br /&gt;
        }&lt;br /&gt;
// BFS 过程同上&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:搜索]]&lt;br /&gt;
[[Category:三三文档]]&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>