{"id":85748,"date":"2026-07-27T21:57:32","date_gmt":"2026-07-27T13:57:32","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/85748.html"},"modified":"2026-07-27T21:57:32","modified_gmt":"2026-07-27T13:57:32","slug":"gesp6%e7%ba%a7c%e8%80%83%e8%af%95%e8%af%ad%e6%b3%95%e7%9f%a5%e8%af%86%ef%bc%88%e6%b3%9b%e6%b4%aa%e7%ae%97%e6%b3%95%ef%bc%88flood-fill%ef%bc%89%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/85748.html","title":{"rendered":"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260727135730-6a6763ca5bdf4.png\" \/><\/p>\n<hr \/>\n<h2>\u56fe\u50cf\u91cc\u7684\u9b54\u6cd5\u2014\u2014\u6cdb\u6d2a\u7b97\u6cd5&#xff08;Flood Fill&#xff09;<\/h2>\n<hr \/>\n<h3>\u4e00\u3001\u5148\u8bb2\u4e00\u4e2a\u751f\u6d3b\u4e2d\u7684\u6545\u4e8b<\/h3>\n<p>\u5c0f\u660e\u6709\u4e00\u5f20\u9ed1\u767d\u5730\u56fe&#xff1a;<\/p>\n<p>########<br \/>\n#&#8230;&#8230;#<br \/>\n#.####.#<br \/>\n#.#..#.#<br \/>\n#&#8230;&#8230;#<br \/>\n########<\/p>\n<p>\u5176\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\n<p># \u8868\u793a\u5899<\/p>\n<\/li>\n<li>\n<p>. \u8868\u793a\u7a7a\u5730<\/p>\n<\/li>\n<\/ul>\n<p>\u73b0\u5728\u5c0f\u660e\u62ff\u7740\u4e00\u6876\u989c\u6599&#xff1a;<\/p>\n<p>\u70b9\u51fb\u4e00\u4e2a\u5730\u65b9<br \/>\n\u2193<\/p>\n<p>\u628a\u548c\u5b83\u8fde\u5728\u4e00\u8d77\u7684\u6240\u6709\u7a7a\u5730\u67d3\u6210\u7ea2\u8272<\/p>\n<p>\u8fd9\u662f\u4e0d\u662f\u5f88\u50cf&#xff1a;<\/p>\n<p>\u753b\u56fe\u8f6f\u4ef6\u91cc\u7684\u201c\u6cb9\u6f06\u6876\u5de5\u5177\u201d&#xff1f;<\/p>\n<p>\u6bd4\u5982&#xff1a;<\/p>\n<p>\u4f60\u70b9\u51fb\u4e00\u4e2a\u533a\u57df&#xff1a;<\/p>\n<p>&#8230;&#8230;..<br \/>\n..####..<br \/>\n..#..#..<br \/>\n..####..<br \/>\n&#8230;&#8230;..<\/p>\n<p>\u6cb9\u6f06\u4f1a\u81ea\u52a8\u6269\u6563&#xff1a;<\/p>\n<p>RRRRRRRR<br \/>\nRR####RR<br \/>\nRR#..#RR<br \/>\nRR####RR<br \/>\nRRRRRRRR<\/p>\n<p>\u8fd9\u4e2a\u8fc7\u7a0b&#xff0c;\u5c31\u662f&#xff1a;<\/p>\n<h2>Flood Fill&#xff08;\u6cdb\u6d2a\u7b97\u6cd5&#xff09;<\/h2>\n<hr \/>\n<h2>\u4e8c\u3001\u6cdb\u6d2a\u7b97\u6cd5\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898&#xff1f;<\/h2>\n<p>\u4e00\u53e5\u8bdd&#xff1a;<\/p>\n<p>\u4ece\u4e00\u4e2a\u70b9\u51fa\u53d1&#xff0c;\u628a\u6240\u6709\u201c\u8fde\u901a\u201d\u7684\u76f8\u540c\u533a\u57df\u627e\u51fa\u6765\u3002<\/p>\n<p>\u5173\u952e\u8bcd&#xff1a;<\/p>\n<h3>1. \u4ece\u4e00\u4e2a\u70b9\u5f00\u59cb<\/h3>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>(2,3)<\/p>\n<p>\u2193<\/p>\n<h3>2. \u5411\u56db\u5468\u6269\u6563<\/h3>\n<p>\u770b\u770b&#xff1a;<\/p>\n<p>\u4e0a<br \/>\n\u4e0b<br \/>\n\u5de6<br \/>\n\u53f3<\/p>\n<p>\u2193<\/p>\n<h3>3. \u5982\u679c\u7b26\u5408\u6761\u4ef6&#xff0c;\u7ee7\u7eed\u6269\u6563<\/h3>\n<p>\u50cf\u6c34\u6d41\u4e00\u6837&#xff1a;<\/p>\n<p>        \u2191<br \/>\n        |<br \/>\n\u2190 \u2190  \u8d77\u70b9  \u2192 \u2192<br \/>\n        |<br \/>\n        \u2193<\/p>\n<hr \/>\n<h2>\u4e09\u3001\u4e8c\u7ef4\u5730\u56fe\u600e\u4e48\u8868\u793a&#xff1f;<\/h2>\n<p>\u8ba1\u7b97\u673a\u91cc\u9762&#xff1a;<\/p>\n<p>\u5730\u56fe\u5c31\u662f\u4e8c\u7ef4\u6570\u7ec4\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>1 1 1 1 1<br \/>\n1 0 0 1 1<br \/>\n1 0 1 1 1<br \/>\n1 0 0 0 1<br \/>\n1 1 1 1 1<\/p>\n<p>C&#043;&#043;&#xff1a;<\/p>\n<p>int mp[5][5];<\/p>\n<p>\u8868\u793a&#xff1a;<\/p>\n<p>mp[\u884c][\u5217]<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>mp[2][3]<\/p>\n<p>\u5c31\u662f&#xff1a;<\/p>\n<p>\u7b2c2\u884c&#xff0c;\u7b2c3\u5217\u3002<\/p>\n<hr \/>\n<h2>\u56db\u3001\u6cdb\u6d2a\u7b97\u6cd5\u7684\u6838\u5fc3\u601d\u60f3<\/h2>\n<p>\u5047\u8bbe&#xff1a;<\/p>\n<p>0\u4ee3\u8868\u571f\u5730<\/p>\n<p>1\u4ee3\u8868\u969c\u788d<\/p>\n<p>\u5730\u56fe&#xff1a;<\/p>\n<p>0 0 0 1 1<br \/>\n0 0 1 1 1<br \/>\n0 0 0 0 1<br \/>\n1 1 0 0 0<\/p>\n<p>\u4ece&#xff1a;<\/p>\n<p>(0,0)<\/p>\n<p>\u5f00\u59cb\u3002<\/p>\n<p>\u6211\u4eec\u60f3&#xff1a;<\/p>\n<p>\u628a\u6240\u6709\u548c\u5b83\u8fde\u63a5\u76840\u53d8\u62102\u3002<\/p>\n<p>\u8fc7\u7a0b&#xff1a;<\/p>\n<h3>\u7b2c\u4e00\u6b65<\/h3>\n<p>\u67d3\u5f53\u524d\u4f4d\u7f6e&#xff1a;<\/p>\n<p>2 0 0 1 1<br \/>\n0 0 1 1 1<br \/>\n0 0 0 0 1<br \/>\n1 1 0 0 0<\/p>\n<p>\u7136\u540e\u68c0\u67e5&#xff1a;<\/p>\n<p>\u4e0a<br \/>\n\u4e0b<br \/>\n\u5de6<br \/>\n\u53f3<\/p>\n<hr \/>\n<h3>\u7b2c\u4e8c\u6b65<\/h3>\n<p>\u5411\u53f3&#xff1a;<\/p>\n<p>2 2 0 1 1<br \/>\n0 0 1 1 1<br \/>\n0 0 0 0 1<br \/>\n1 1 0 0 0<\/p>\n<p>\u7ee7\u7eed&#xff1a;<\/p>\n<p>2 2 2 1 1<br \/>\n0 0 1 1 1<br \/>\n0 0 0 0 1<br \/>\n1 1 0 0 0<\/p>\n<p>\u76f4\u5230\u6240\u6709\u8fde\u63a5\u533a\u57df\u5b8c\u6210\u3002<\/p>\n<hr \/>\n<h2>\u4e94\u3001DFS\u5b9e\u73b0\u6cdb\u6d2a\u7b97\u6cd5&#xff08;\u6700\u7ecf\u5178&#xff09;<\/h2>\n<h3>1. \u5b9a\u4e49\u65b9\u5411<\/h3>\n<p>\u56e0\u4e3a\u53ea\u80fd\u8d70&#xff1a;<\/p>\n<p>\u4e0a<br \/>\n\u4e0b<br \/>\n\u5de6<br \/>\n\u53f3<\/p>\n<p>\u6240\u4ee5&#xff1a;<\/p>\n<p>int dx[4]&#061;{-1,1,0,0};<br \/>\nint dy[4]&#061;{0,0,-1,1};<\/p>\n<p>\u89e3\u91ca&#xff1a;<\/p>\n<p>\u7b2c0\u79cd&#xff1a;<\/p>\n<p>x-1,y<\/p>\n<p>\u5411\u4e0a<\/p>\n<p>\u7b2c1\u79cd&#xff1a;<\/p>\n<p>x&#043;1,y<\/p>\n<p>\u5411\u4e0b<\/p>\n<p>\u7b2c2\u79cd&#xff1a;<\/p>\n<p>x,y-1<\/p>\n<p>\u5411\u5de6<\/p>\n<p>\u7b2c3\u79cd&#xff1a;<\/p>\n<p>x,y&#043;1<\/p>\n<p>\u5411\u53f3<\/p>\n<hr \/>\n<h2>\u516d\u3001\u5199DFS\u51fd\u6570<\/h2>\n<p>\u6a21\u677f&#xff1a;<\/p>\n<p>void dfs(int x,int y)<br \/>\n{<\/p>\n<p>}<\/p>\n<p>\u8868\u793a&#xff1a;<\/p>\n<p>\u73b0\u5728\u7ad9\u5728&#xff1a;<\/p>\n<p>(x,y)<\/p>\n<p>\u8fd9\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<hr \/>\n<h3>\u7b2c\u4e00\u6b65&#xff1a;\u67d3\u8272<\/h3>\n<p>\u4e3a\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u56e0\u4e3a&#xff1a;<\/p>\n<p>\u5982\u679c\u4e0d\u6807\u8bb0&#xff0c;<\/p>\n<p>\u4f1a\u65e0\u9650\u5faa\u73af\u3002<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>A -&gt; B<\/p>\n<p>B -&gt; A<\/p>\n<p>A -&gt; B<\/p>\n<p>&#8230;<\/p>\n<p>\u6240\u4ee5&#xff1a;<\/p>\n<p>\u8fdb\u5165\u4e00\u4e2a\u70b9&#xff1a;<\/p>\n<p>\u9a6c\u4e0a\u6807\u8bb0\u3002<\/p>\n<p>\u4ee3\u7801&#xff1a;<\/p>\n<p>mp[x][y]&#061;2;<\/p>\n<hr \/>\n<h3>\u7b2c\u4e8c\u6b65&#xff1a;\u5c1d\u8bd5\u56db\u4e2a\u65b9\u5411<\/h3>\n<p>for(int i&#061;0;i&lt;4;i&#043;&#043;)<br \/>\n{<\/p>\n<p>}<\/p>\n<hr \/>\n<h3>\u7b2c\u4e09\u6b65&#xff1a;\u8ba1\u7b97\u65b0\u5750\u6807<\/h3>\n<p>int nx&#061;x&#043;dx[i];<br \/>\nint ny&#061;y&#043;dy[i];<\/p>\n<p>\u6bd4\u5982&#xff1a;<\/p>\n<p>\u73b0\u5728&#xff1a;<\/p>\n<p>x&#061;3<br \/>\ny&#061;4<\/p>\n<p>\u5411\u4e0a&#xff1a;<\/p>\n<p>nx&#061;2<br \/>\nny&#061;4<\/p>\n<hr \/>\n<h3>\u7b2c\u56db\u6b65&#xff1a;\u5224\u65ad\u80fd\u4e0d\u80fd\u8d70<\/h3>\n<p>\u9700\u8981\u6ee1\u8db3&#xff1a;<\/p>\n<h4>\u6761\u4ef61&#xff1a;<\/h4>\n<p>\u4e0d\u80fd\u8d8a\u754c<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>-1\u884c<\/p>\n<p>\u4e0d\u5b58\u5728\u3002<\/p>\n<p>\u6240\u4ee5&#xff1a;<\/p>\n<p>nx&gt;&#061;0<\/p>\n<hr \/>\n<h4>\u6761\u4ef62&#xff1a;<\/h4>\n<p>\u5fc5\u987b\u662f\u76ee\u6807\u989c\u8272<\/p>\n<p>\u6bd4\u5982&#xff1a;<\/p>\n<p>\u53ea\u80fd\u8d700&#xff1a;<\/p>\n<p>mp[nx][ny]&#061;&#061;0<\/p>\n<hr \/>\n<p>\u5b8c\u6574&#xff1a;<\/p>\n<p>if(nx&gt;&#061;0&amp;&amp;nx&lt;n<br \/>\n&amp;&amp;ny&gt;&#061;0&amp;&amp;ny&lt;m<br \/>\n&amp;&amp;mp[nx][ny]&#061;&#061;0)<br \/>\n{<br \/>\n    dfs(nx,ny);<br \/>\n}<\/p>\n<hr \/>\n<h2>\u4e03\u3001\u5b8c\u6574C&#043;&#043;\u4ee3\u7801<\/h2>\n<p>\u9898\u76ee&#xff1a;<\/p>\n<p>\u628a\u548c\u8d77\u70b9\u8fde\u901a\u76840\u5168\u90e8\u53d8\u62102\u3002<\/p>\n<p>#include&lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>int n,m;<\/p>\n<p>int mp[100][100];<\/p>\n<p>int dx[4]&#061;{-1,1,0,0};<br \/>\nint dy[4]&#061;{0,0,-1,1};<\/p>\n<p>void dfs(int x,int y)<br \/>\n{<\/p>\n<p>    \/\/1.\u67d3\u8272<br \/>\n    mp[x][y]&#061;2;<\/p>\n<p>    \/\/2.\u5bfb\u627e\u56db\u4e2a\u65b9\u5411<br \/>\n    for(int i&#061;0;i&lt;4;i&#043;&#043;)<br \/>\n    {<\/p>\n<p>        int nx&#061;x&#043;dx[i];<br \/>\n        int ny&#061;y&#043;dy[i];<\/p>\n<p>        \/\/3.\u5224\u65ad\u662f\u5426\u53ef\u4ee5\u7ee7\u7eed<br \/>\n        if(nx&gt;&#061;0&amp;&amp;nx&lt;n<br \/>\n        &amp;&amp;ny&gt;&#061;0&amp;&amp;ny&lt;m<br \/>\n        &amp;&amp;mp[nx][ny]&#061;&#061;0)<br \/>\n        {<br \/>\n            dfs(nx,ny);<br \/>\n        }<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>int main()<br \/>\n{<\/p>\n<p>    cin&gt;&gt;n&gt;&gt;m;<\/p>\n<p>    for(int i&#061;0;i&lt;n;i&#043;&#043;)<br \/>\n    {<br \/>\n        for(int j&#061;0;j&lt;m;j&#043;&#043;)<br \/>\n        {<br \/>\n            cin&gt;&gt;mp[i][j];<br \/>\n        }<br \/>\n    }<\/p>\n<p>    int x,y;<\/p>\n<p>    cin&gt;&gt;x&gt;&gt;y;<\/p>\n<p>    dfs(x,y);<\/p>\n<p>    for(int i&#061;0;i&lt;n;i&#043;&#043;)<br \/>\n    {<br \/>\n        for(int j&#061;0;j&lt;m;j&#043;&#043;)<br \/>\n        {<br \/>\n            cout&lt;&lt;mp[i][j]&lt;&lt;&#034; &#034;;<br \/>\n        }<\/p>\n<p>        cout&lt;&lt;endl;<br \/>\n    }<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<hr \/>\n<h2>\u516b\u3001\u5b66\u751f\u6700\u5bb9\u6613\u72af\u76843\u4e2a\u9519\u8bef<\/h2>\n<h3>\u9519\u8bef1&#xff1a;\u5fd8\u8bb0\u6807\u8bb0<\/h3>\n<p>\u9519\u8bef&#xff1a;<\/p>\n<p>void dfs(int x,int y)<br \/>\n{<\/p>\n<p>    dfs(nx,ny);<\/p>\n<p>}<\/p>\n<p>\u6ca1\u6709&#xff1a;<\/p>\n<p>mp[x][y]&#061;2;<\/p>\n<p>\u7ed3\u679c&#xff1a;<\/p>\n<p>\u65e0\u9650\u9012\u5f52\u3002<\/p>\n<hr \/>\n<p>\u4e3a\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>A B<br \/>\nC D<\/p>\n<p>A\u8d70B&#xff1a;<\/p>\n<p>A\u2192B<\/p>\n<p>B\u53c8\u80fd\u8d70A&#xff1a;<\/p>\n<p>B\u2192A<\/p>\n<p>\u6b7b\u5faa\u73af\u3002<\/p>\n<hr \/>\n<h2>\u9519\u8bef2&#xff1a;\u65b9\u5411\u6570\u7ec4\u5199\u9519<\/h2>\n<p>\u5f88\u591a\u5b69\u5b50\u5199&#xff1a;<\/p>\n<p>int dx[4]&#061;{1,1,-1,-1};<\/p>\n<p>\u8fd9\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u53d8\u6210&#xff1a;<\/p>\n<p>\u2198<br \/>\n\u2199<br \/>\n\u2197<br \/>\n\u2196<\/p>\n<p>\u8d70\u659c\u7ebf\u3002<\/p>\n<p>\u5982\u679c\u9898\u76ee\u8981\u6c42\u4e0a\u4e0b\u5de6\u53f3&#xff1a;<\/p>\n<p>\u5fc5\u987b&#xff1a;<\/p>\n<p>int dx[4]&#061;{-1,1,0,0};<br \/>\nint dy[4]&#061;{0,0,-1,1};<\/p>\n<hr \/>\n<h2>\u9519\u8bef3&#xff1a;\u8fb9\u754c\u5fd8\u8bb0\u5224\u65ad<\/h2>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>\u7b2c0\u884c<\/p>\n<p>\u518d\u5411\u4e0a&#xff1a;<\/p>\n<p>-1\u884c<\/p>\n<p>\u6570\u7ec4&#xff1a;<\/p>\n<p>mp[-1][0]<\/p>\n<p>\u975e\u6cd5\u3002<\/p>\n<p>\u7a0b\u5e8f\u53ef\u80fd&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5d29\u6e83<\/p>\n<\/li>\n<li>\n<p>\u8f93\u51fa\u5947\u602a\u7ed3\u679c<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e5d\u3001DFS\u548cBFS\u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/h2>\n<p>\u6cdb\u6d2a\u7b97\u6cd5\u6709\u4e24\u79cd\u5199\u6cd5&#xff1a;<\/p>\n<h3>DFS<\/h3>\n<p>\u6df1\u5ea6\u4f18\u5148\u641c\u7d22&#xff1a;<\/p>\n<p>\u50cf\u4e00\u4e2a\u5c0f\u670b\u53cb\u63a2\u9669&#xff1a;<\/p>\n<p>\u4e00\u76f4\u8d70\u5230\u5e95<\/p>\n<p>\u8d70\u4e0d\u901a\u56de\u6765<\/p>\n<p>\u7279\u70b9&#xff1a;<\/p>\n<p>\u4ee3\u7801\u77ed\u3002<\/p>\n<p>\u9002\u5408&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u533a\u57df\u67d3\u8272<\/p>\n<\/li>\n<li>\n<p>\u8fde\u901a\u5757<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>BFS<\/h3>\n<p>\u5e7f\u5ea6\u4f18\u5148\u641c\u7d22&#xff1a;<\/p>\n<p>\u50cf\u6c34\u6ce2&#xff1a;<\/p>\n<p>\u7b2c\u4e00\u5708<\/p>\n<p>\u7b2c\u4e8c\u5708<\/p>\n<p>\u7b2c\u4e09\u5708<\/p>\n<p>\u4f7f\u7528&#xff1a;<\/p>\n<p>\u961f\u5217 queue\u3002<\/p>\n<p>\u9002\u5408&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6700\u77ed\u8ddd\u79bb<\/p>\n<\/li>\n<li>\n<p>\u8ff7\u5bab\u6700\u77ed\u8def<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u5341\u3001\u4fe1\u5965\u8d5b\u4e2d\u7684\u7ecf\u5178\u5e94\u7528<\/h2>\n<p>\u6cdb\u6d2a\u7b97\u6cd5\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<p>\u4ee5\u540e\u4f1a\u9047\u5230&#xff1a;<\/p>\n<hr \/>\n<h3>1. \u7edf\u8ba1\u5c9b\u5c7f\u6570\u91cf<\/h3>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>11000<br \/>\n11000<br \/>\n00100<br \/>\n00011<\/p>\n<p>\u6709\u51e0\u4e2a\u5c9b&#xff1f;<\/p>\n<p>\u7b54\u6848&#xff1a;<\/p>\n<p>\u6bcf\u627e\u5230\u4e00\u4e2a1&#xff1a;<\/p>\n<p>DFS\u67d3\u6389\u3002<\/p>\n<hr \/>\n<h3>2. \u8ff7\u5bab\u8fde\u901a\u6027<\/h3>\n<p>\u5224\u65ad&#xff1a;<\/p>\n<p>\u8d77\u70b9\u80fd\u4e0d\u80fd\u5230\u7ec8\u70b9<\/p>\n<hr \/>\n<h3>3. \u6700\u5927\u533a\u57df\u9762\u79ef<\/h3>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<p>0 1 1<br \/>\n1 1 0<br \/>\n1 0 0<\/p>\n<p>\u627e\u6700\u5927\u8fde\u901a\u5757\u3002<\/p>\n<hr \/>\n<h3>4. \u586b\u5145\u5730\u56fe<\/h3>\n<p>\u7c7b\u4f3c&#xff1a;<\/p>\n<p>\u753b\u56fe\u8f6f\u4ef6\u6cb9\u6f06\u6876<\/p>\n<hr \/>\n<h2>\u5341\u4e00\u3001\u7ed9\u540c\u5b66\u4eec\u603b\u7ed3\u4e00\u53e5\u8bdd<\/h2>\n<p>\u6cdb\u6d2a\u7b97\u6cd5\u5c31\u662f&#xff1a;<br \/>\n\u4ece\u4e00\u4e2a\u4f4d\u7f6e\u51fa\u53d1&#xff0c;\u50cf\u6c34\u4e00\u6837\u5411\u56db\u5468\u6d41\u52a8&#xff0c;\u628a\u6240\u6709\u80fd\u591f\u5230\u8fbe\u7684\u5730\u65b9\u5168\u90e8\u5904\u7406\u4e00\u904d\u3002<\/p>\n<p>\u8bb0\u4f4f\u4e09\u4e2a\u5173\u952e&#xff1a;<\/p>\n<h3>\u7b2c\u4e00&#xff1a;<\/h3>\n<p>\u4e8c\u7ef4\u6570\u7ec4\u8868\u793a\u5730\u56fe\u3002<\/p>\n<h3>\u7b2c\u4e8c&#xff1a;<\/h3>\n<p>DFS\/BFS\u8d1f\u8d23\u6269\u6563\u3002<\/p>\n<h3>\u7b2c\u4e09&#xff1a;<\/h3>\n<p>\u4e00\u5b9a\u8981&#xff1a;<\/p>\n<p>\u8d70\u4e00\u6b65&#xff0c;\u6807\u8bb0\u4e00\u6b65\u3002<\/p>\n<hr \/>\n<p>\u5bf9\u4e8e\u4fe1\u5965\u8d5b\u5b66\u751f\u6765\u8bf4&#xff0c;\u6cdb\u6d2a\u7b97\u6cd5\u5176\u5b9e\u662f\u8fdb\u5165 DFS\u641c\u7d22\u3001\u8fde\u901a\u5757\u3001\u56fe\u8bba \u7684\u7b2c\u4e00\u5ea7\u6865\u6881\u3002\u638c\u63e1\u5b83\u4ee5\u540e&#xff0c;\u540e\u9762\u7684 \u8ff7\u5bab\u95ee\u9898\u3001\u5c9b\u5c7f\u95ee\u9898\u3001\u56fe\u7684\u904d\u5386\u3001BFS\u6700\u77ed\u8def \u90fd\u4f1a\u987a\u7545\u5f88\u591a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56fe\u50cf\u91cc\u7684\u9b54\u6cd5\u2014\u2014\u6cdb\u6d2a\u7b97\u6cd5&#xff08;Flood Fill&#xff09;\u4e00\u3001\u5148\u8bb2\u4e00\u4e2a\u751f\u6d3b\u4e2d\u7684\u6545\u4e8b\u5c0f\u660e\u6709\u4e00\u5f20\u9ed1\u767d\u5730\u56fe&#xff1a;########<br \/>\n#&#8230;&#8230;#<br \/>\n#.####.#<br \/>\n#.#..#.#<br \/>\n#&#8230;&#8230;#<br \/>\n########\u5176\u4e2d&#xff1a;# \u8868\u793a\u5899. \u8868\u793a\u7a7a\u5730\u73b0\u5728\u5c0f\u660e\u62ff\u7740\u4e00\u6876\u989c\u6599&#xff1a;\u70b9\u51fb\u4e00\u4e2a\u5730\u65b9<br \/>\n\u2193\u628a\u548c\u5b83\u8fde\u5728\u4e00\u8d77\u7684\u6240\u6709\u7a7a\u5730\u67d3\u6210\u7ea2\u8272\u8fd9\u662f\u4e0d\u662f\u5f88\u50cf&#xff1a;\u753b\u56fe\u8f6f\u4ef6\u91cc\u7684\u201c\u6cb9\u6f06\u6876\u5de5\u5177\u201d&#xff1f;\u6bd4\u5982&#xff1a;\u4f60\u70b9\u51fb\u4e00\u4e2a\u533a\u57df&amp;#xff<\/p>\n","protected":false},"author":2,"featured_media":85747,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9638,55,1983,427],"topic":[],"class_list":["post-85748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-gesp6","tag-c","tag-1983","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/85748.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u56fe\u50cf\u91cc\u7684\u9b54\u6cd5\u2014\u2014\u6cdb\u6d2a\u7b97\u6cd5&#xff08;Flood Fill&#xff09;\u4e00\u3001\u5148\u8bb2\u4e00\u4e2a\u751f\u6d3b\u4e2d\u7684\u6545\u4e8b\u5c0f\u660e\u6709\u4e00\u5f20\u9ed1\u767d\u5730\u56fe&#xff1a;######## #......# #.####.# #.#..#.# #......# ########\u5176\u4e2d&#xff1a;# \u8868\u793a\u5899. \u8868\u793a\u7a7a\u5730\u73b0\u5728\u5c0f\u660e\u62ff\u7740\u4e00\u6876\u989c\u6599&#xff1a;\u70b9\u51fb\u4e00\u4e2a\u5730\u65b9 \u2193\u628a\u548c\u5b83\u8fde\u5728\u4e00\u8d77\u7684\u6240\u6709\u7a7a\u5730\u67d3\u6210\u7ea2\u8272\u8fd9\u662f\u4e0d\u662f\u5f88\u50cf&#xff1a;\u753b\u56fe\u8f6f\u4ef6\u91cc\u7684\u201c\u6cb9\u6f06\u6876\u5de5\u5177\u201d&#xff1f;\u6bd4\u5982&#xff1a;\u4f60\u70b9\u51fb\u4e00\u4e2a\u533a\u57df&amp;#xff\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/85748.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-27T13:57:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260727135730-6a6763ca5bdf4.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/85748.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/85748.html\",\"name\":\"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-27T13:57:32+00:00\",\"dateModified\":\"2026-07-27T13:57:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/85748.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/85748.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/85748.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/85748.html","og_locale":"zh_CN","og_type":"article","og_title":"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u56fe\u50cf\u91cc\u7684\u9b54\u6cd5\u2014\u2014\u6cdb\u6d2a\u7b97\u6cd5&#xff08;Flood Fill&#xff09;\u4e00\u3001\u5148\u8bb2\u4e00\u4e2a\u751f\u6d3b\u4e2d\u7684\u6545\u4e8b\u5c0f\u660e\u6709\u4e00\u5f20\u9ed1\u767d\u5730\u56fe&#xff1a;######## #......# #.####.# #.#..#.# #......# ########\u5176\u4e2d&#xff1a;# \u8868\u793a\u5899. \u8868\u793a\u7a7a\u5730\u73b0\u5728\u5c0f\u660e\u62ff\u7740\u4e00\u6876\u989c\u6599&#xff1a;\u70b9\u51fb\u4e00\u4e2a\u5730\u65b9 \u2193\u628a\u548c\u5b83\u8fde\u5728\u4e00\u8d77\u7684\u6240\u6709\u7a7a\u5730\u67d3\u6210\u7ea2\u8272\u8fd9\u662f\u4e0d\u662f\u5f88\u50cf&#xff1a;\u753b\u56fe\u8f6f\u4ef6\u91cc\u7684\u201c\u6cb9\u6f06\u6876\u5de5\u5177\u201d&#xff1f;\u6bd4\u5982&#xff1a;\u4f60\u70b9\u51fb\u4e00\u4e2a\u533a\u57df&amp;#xff","og_url":"https:\/\/www.wsisp.com\/helps\/85748.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-27T13:57:32+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260727135730-6a6763ca5bdf4.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/85748.html","url":"https:\/\/www.wsisp.com\/helps\/85748.html","name":"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-27T13:57:32+00:00","dateModified":"2026-07-27T13:57:32+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/85748.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/85748.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/85748.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"GESP6\u7ea7C++\u8003\u8bd5\u8bed\u6cd5\u77e5\u8bc6\uff08\u6cdb\u6d2a\u7b97\u6cd5\uff08Flood Fill\uff09\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/85748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=85748"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/85748\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/85747"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=85748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=85748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=85748"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=85748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}