{"id":78138,"date":"2026-02-26T09:25:09","date_gmt":"2026-02-26T01:25:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/78138.html"},"modified":"2026-02-26T09:25:09","modified_gmt":"2026-02-26T01:25:09","slug":"%e5%b9%b6%e6%9f%a5%e9%9b%86%e7%ae%97%e6%b3%95%e7%ae%80%e4%bb%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/78138.html","title":{"rendered":"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb"},"content":{"rendered":"<p>\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u57fa\u672c\u7684\u6570\u7ec4\u64cd\u4f5c\u3001\u9012\u5f52\u601d\u60f3\u3002<\/p>\n<p>\u4f8b\u9898 on Luogu&#xff1a;<\/p>\n<ul>\n<li>P3367 \u3010\u6a21\u677f\u3011\u5e76\u67e5\u96c6<\/li>\n<\/ul>\n<h3>\u5e76\u67e5\u96c6\u7b80\u4ecb<\/h3>\n<p>\u5e76\u67e5\u96c6\u662f\u4e00\u79cd\u6811\u578b\u7684\u6570\u636e\u7ed3\u6784&#xff0c;\u7528\u4e8e\u5904\u7406\u4e00\u4e9b\u4e0d\u76f8\u4ea4\u96c6\u5408\u7684\u5408\u5e76\u53ca\u67e5\u8be2\u95ee\u9898\u3002\u5b83\u652f\u6301\u4e24\u79cd\u64cd\u4f5c&#xff1a;<\/p>\n<ul>\n<li>\u67e5\u8be2&#xff08;Find&#xff09;&#xff1a;\u67e5\u8be2\u67d0\u4e2a\u5143\u7d20\u5c5e\u4e8e\u54ea\u4e2a\u96c6\u5408<\/li>\n<li>\u5408\u5e76&#xff08;Union&#xff09;&#xff1a;\u5c06\u4e24\u4e2a\u96c6\u5408\u5408\u5e76\u6210\u4e00\u4e2a\u96c6\u5408<\/li>\n<\/ul>\n<p>\u5e76\u67e5\u96c6\u5728\u5224\u65ad\u56fe\u8fde\u901a\u6027\u3001\u6700\u5c0f\u751f\u6210\u6811&#xff08;Kruskal\u7b97\u6cd5&#xff09;\u7b49\u65b9\u9762\u6709\u5e7f\u6cdb\u5e94\u7528\u3002<\/p>\n<h3>\u5e76\u67e5\u96c6\u7ed3\u6784<\/h3>\n<p>\u5982\u56fe\u6240\u793a&#xff0c;\u5e76\u67e5\u96c6\u7528\u4e00\u68f5\u6811\u6765\u8868\u793a\u4e00\u4e2a\u96c6\u5408&#xff0c;\u6811\u4e2d\u7684\u6bcf\u4e2a\u8282\u70b9\u4ee3\u8868\u4e00\u4e2a\u5143\u7d20&#xff0c;\u6839\u8282\u70b9\u4f5c\u4e3a\u8fd9\u4e2a\u96c6\u5408\u7684\u4ee3\u8868\u3002<\/p>\n<p>\u521d\u59cb\u65f6&#xff0c;\u6bcf\u4e2a\u5143\u7d20\u81ea\u6210\u4e00\u68f5\u6811&#xff0c;\u5373\u6bcf\u4e2a\u5143\u7d20\u90fd\u662f\u81ea\u5df1\u7684\u6839\u8282\u70b9\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u6570\u7ec4 fa \u6765\u5b58\u50a8\u6bcf\u4e2a\u8282\u70b9\u7684\u7236\u8282\u70b9&#xff1a;<\/p>\n<ul>\n<li>fa[i] \u8868\u793a\u5143\u7d20 i \u7684\u7236\u8282\u70b9<\/li>\n<li>\u5982\u679c fa[i] &#061; i&#xff0c;\u5219 i \u662f\u6240\u5728\u96c6\u5408\u7684\u6839\u8282\u70b9<\/li>\n<\/ul>\n<h3>\u521d\u59cb\u5316<\/h3>\n<p>\u4e00\u5f00\u59cb&#xff0c;\u6bcf\u4e2a\u5143\u7d20\u90fd\u662f\u72ec\u7acb\u7684\u96c6\u5408&#xff0c;\u6240\u4ee5\u6bcf\u4e2a\u5143\u7d20\u7684\u7236\u8282\u70b9\u90fd\u662f\u81ea\u5df1\u3002<\/p>\n<p>void init(int n) { for(int i &#061; 1; i &lt;&#061; n; i&#043;&#043;) { fa[i] &#061; i; } }<\/p>\n<h3>\u67e5\u8be2\u64cd\u4f5c&#xff08;Find&#xff09;<\/h3>\n<p>\u67e5\u8be2\u64cd\u4f5c\u7684\u76ee\u6807\u662f\u627e\u5230\u5143\u7d20\u6240\u5728\u96c6\u5408\u7684\u6839\u8282\u70b9\u3002\u6700\u7b80\u5355\u7684\u5b9e\u73b0\u662f\u6cbf\u7740\u7236\u8282\u70b9\u4e00\u76f4\u5411\u4e0a\u627e&#xff0c;\u76f4\u5230\u627e\u5230\u6839\u8282\u70b9\u3002<\/p>\n<p>int find(int x) { while(fa[x] !&#061; x) \/\/ \u4e0d\u662f\u6839\u8282\u70b9\u5c31\u7ee7\u7eed\u5411\u4e0a { x &#061; fa[x]; } return x; }<\/p>\n<p>\u6216\u8005\u4f7f\u7528\u9012\u5f52\u5199\u6cd5&#xff1a;<\/p>\n<p>int find(int x) { if(fa[x] &#061;&#061; x) return x; return find(fa[x]); }<\/p>\n<h4>\u8def\u5f84\u538b\u7f29\u4f18\u5316<\/h4>\n<p>\u4e0a\u9762\u7684\u67e5\u8be2\u64cd\u4f5c\u5728\u6700\u574f\u60c5\u51b5\u4e0b&#xff08;\u6811\u9000\u5316\u6210\u94fe&#xff09;\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(n)\u3002\u8def\u5f84\u538b\u7f29\u53ef\u4ee5\u5728\u67e5\u8be2\u7684\u540c\u65f6&#xff0c;\u5c06\u8def\u5f84\u4e0a\u7684\u6240\u6709\u8282\u70b9\u76f4\u63a5\u6307\u5411\u6839\u8282\u70b9&#xff0c;\u4ece\u800c\u4f18\u5316\u540e\u7eed\u67e5\u8be2\u3002<\/p>\n<p>int find(int x) { if(fa[x] !&#061; x) { fa[x] &#061; find(fa[x]); \/\/ \u8def\u5f84\u538b\u7f29 } return fa[x]; }<\/p>\n<p>\u7ecf\u8fc7\u8def\u5f84\u538b\u7f29\u540e&#xff0c;\u67e5\u8be2\u64cd\u4f5c\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u63a5\u8fd1 O(1)\u3002<\/p>\n<h3>\u5408\u5e76\u64cd\u4f5c&#xff08;Union&#xff09;<\/h3>\n<p>\u5408\u5e76\u64cd\u4f5c\u5c06\u4e24\u4e2a\u5143\u7d20\u6240\u5728\u7684\u96c6\u5408\u5408\u5e76\u6210\u4e00\u4e2a\u96c6\u5408\u3002\u57fa\u672c\u601d\u8def\u662f&#xff1a;\u5148\u627e\u5230\u4e24\u4e2a\u5143\u7d20\u5404\u81ea\u7684\u6839\u8282\u70b9&#xff0c;\u7136\u540e\u5c06\u5176\u4e2d\u4e00\u4e2a\u6839\u8282\u70b9\u7684\u7236\u8282\u70b9\u6307\u5411\u53e6\u4e00\u4e2a\u6839\u8282\u70b9\u3002<\/p>\n<p>void unionSet(int x, int y) { int rootX &#061; find(x); int rootY &#061; find(y);<\/p>\n<p>if(rootX !&#061; rootY)  \/\/ \u4e0d\u5728\u540c\u4e00\u4e2a\u96c6\u5408\u624d\u9700\u8981\u5408\u5e76<br \/>\n{<br \/>\n    fa[rootX] &#061; rootY;  \/\/ \u5c06rootX\u7684\u7236\u8282\u70b9\u8bbe\u4e3arootY<br \/>\n}<\/p>\n<p>}<\/p>\n<h4>\u6309\u79e9\u5408\u5e76\u4f18\u5316<\/h4>\n<p>\u4e3a\u4e86\u907f\u514d\u6811\u7684\u9ad8\u5ea6\u589e\u957f\u8fc7\u5feb&#xff0c;\u53ef\u4ee5\u5f15\u5165&#034;\u79e9&#034;\u7684\u6982\u5ff5\u3002\u79e9\u901a\u5e38\u8868\u793a\u6811\u7684\u9ad8\u5ea6\u6216\u5927\u5c0f\u3002\u5408\u5e76\u65f6&#xff0c;\u5c06\u79e9\u8f83\u5c0f\u7684\u6811\u5408\u5e76\u5230\u79e9\u8f83\u5927\u7684\u6811\u4e0a&#xff0c;\u8fd9\u6837\u80fd\u63a7\u5236\u6811\u7684\u9ad8\u5ea6\u3002<\/p>\n<p>int rank[N]; \/\/ \u79e9\u6570\u7ec4&#xff0c;\u9700\u8981\u989d\u5916\u521d\u59cb\u5316&#xff08;\u5168\u90e8\u4e3a1\u62160&#xff09;<\/p>\n<p>void init(int n) { for(int i &#061; 1; i &lt;&#061; n; i&#043;&#043;) { fa[i] &#061; i; rank[i] &#061; 1; \/\/ \u521d\u59cb\u79e9\u4e3a1 } }<\/p>\n<p>void unionSet(int x, int y) { int rootX &#061; find(x); int rootY &#061; find(y);<\/p>\n<p>if(rootX &#061;&#061; rootY) return;<\/p>\n<p>\/\/ \u5c06\u79e9\u5c0f\u7684\u6811\u5408\u5e76\u5230\u79e9\u5927\u7684\u6811\u4e0a<br \/>\nif(rank[rootX] &lt; rank[rootY])<br \/>\n{<br \/>\n    fa[rootX] &#061; rootY;<br \/>\n}<br \/>\nelse if(rank[rootX] &gt; rank[rootY])<br \/>\n{<br \/>\n    fa[rootY] &#061; rootX;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n    fa[rootX] &#061; rootY;<br \/>\n    rank[rootY]&#043;&#043;;  \/\/ \u4e24\u6811\u79e9\u76f8\u7b49&#xff0c;\u5408\u5e76\u540e\u79e9\u52a01<br \/>\n}<\/p>\n<p>}<\/p>\n<h3>\u65f6\u95f4\u590d\u6742\u5ea6\u5206\u6790<\/h3>\n<ul>\n<li>\u53ea\u4f7f\u7528\u8def\u5f84\u538b\u7f29&#xff1a;\u5747\u644a\u65f6\u95f4\u590d\u6742\u5ea6 O(\u03b1(n))&#xff0c;\u03b1(n) \u662f\u963f\u514b\u66fc\u51fd\u6570\u7684\u53cd\u51fd\u6570&#xff0c;\u589e\u957f\u6781\u6162<\/li>\n<li>\u53ea\u4f7f\u7528\u6309\u79e9\u5408\u5e76&#xff1a;\u65f6\u95f4\u590d\u6742\u5ea6 O(log n)<\/li>\n<li>\u8def\u5f84\u538b\u7f29 &#043; \u6309\u79e9\u5408\u5e76&#xff1a;\u5747\u644a\u65f6\u95f4\u590d\u6742\u5ea6 O(\u03b1(n))&#xff0c;\u8fd1\u4e4e\u5e38\u6570\u65f6\u95f4<\/li>\n<\/ul>\n<h3>\u5b8c\u6574\u4ee3\u7801\u6a21\u677f<\/h3>\n<p>#include&lt;bits\/stdc&#043;&#043;.h&gt; using namespace std;<\/p>\n<p>const int N &#061; 10005;<\/p>\n<p>int fa[N]; int rank[N]; \/\/ \u6309\u79e9\u5408\u5e76\u7528<\/p>\n<p>\/\/ \u521d\u59cb\u5316 void init(int n) { for(int i &#061; 1; i &lt;&#061; n; i&#043;&#043;) { fa[i] &#061; i; rank[i] &#061; 1; } }<\/p>\n<p>\/\/ \u67e5\u8be2&#xff08;\u5e26\u8def\u5f84\u538b\u7f29&#xff09; int find(int x) { if(fa[x] !&#061; x) { fa[x] &#061; find(fa[x]); } return fa[x]; }<\/p>\n<p>\/\/ \u5408\u5e76&#xff08;\u5e26\u6309\u79e9\u5408\u5e76&#xff09; void unionSet(int x, int y) { int rootX &#061; find(x); int rootY &#061; find(y);<\/p>\n<p>if(rootX &#061;&#061; rootY) return;<\/p>\n<p>if(rank[rootX] &lt; rank[rootY])<br \/>\n{<br \/>\n    fa[rootX] &#061; rootY;<br \/>\n}<br \/>\nelse if(rank[rootX] &gt; rank[rootY])<br \/>\n{<br \/>\n    fa[rootY] &#061; rootX;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n    fa[rootX] &#061; rootY;<br \/>\n    rank[rootY]&#043;&#043;;<br \/>\n}<\/p>\n<p>}<\/p>\n<p>\/\/ \u5224\u65ad\u4e24\u4e2a\u5143\u7d20\u662f\u5426\u5728\u540c\u4e00\u96c6\u5408 bool isSame(int x, int y) { return find(x) &#061;&#061; find(y); }<\/p>\n<p>int main() { int n, m; cin &gt;&gt; n &gt;&gt; m;<\/p>\n<p>init(n);<\/p>\n<p>while(m&#8211;)<br \/>\n{<br \/>\n    int op, x, y;<br \/>\n    cin &gt;&gt; op &gt;&gt; x &gt;&gt; y;<\/p>\n<p>    if(op &#061;&#061; 1)  \/\/ \u5408\u5e76\u64cd\u4f5c<br \/>\n    {<br \/>\n        unionSet(x, y);<br \/>\n    }<br \/>\n    else  \/\/ \u67e5\u8be2\u64cd\u4f5c<br \/>\n    {<br \/>\n        if(isSame(x, y))<br \/>\n        {<br \/>\n            cout &lt;&lt; &#034;Y&#034; &lt;&lt; endl;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            cout &lt;&lt; &#034;N&#034; &lt;&lt; endl;<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>return 0;<\/p>\n<p>}<\/p>\n<h3>\u5e76\u67e5\u96c6\u7684\u5e94\u7528<\/h3>\n<h4>1. \u5224\u65ad\u56fe\u7684\u8fde\u901a\u6027<\/h4>\n<p>\u53ef\u4ee5\u7528\u5e76\u67e5\u96c6\u7ef4\u62a4\u56fe\u4e2d\u5404\u8fde\u901a\u5206\u91cf&#xff0c;\u5feb\u901f\u5224\u65ad\u4e24\u4e2a\u70b9\u662f\u5426\u8fde\u901a\u3002<\/p>\n<h4>2. Kruskal\u6700\u5c0f\u751f\u6210\u6811<\/h4>\n<p>\u6309\u8fb9\u6743\u4ece\u5c0f\u5230\u5927\u6392\u5e8f&#xff0c;\u4f9d\u6b21\u5c1d\u8bd5\u52a0\u5165\u8fb9&#xff0c;\u5982\u679c\u8fb9\u7684\u4e24\u7aef\u4e0d\u5728\u540c\u4e00\u96c6\u5408&#xff0c;\u5219\u52a0\u5165\u8be5\u8fb9\u5e76\u5408\u5e76\u4e24\u7aef\u70b9\u3002<\/p>\n<p>int kruskal() { int ans &#061; 0, cnt &#061; 0; sort(edges &#043; 1, edges &#043; m &#043; 1, cmp); \/\/ \u6309\u8fb9\u6743\u6392\u5e8f<\/p>\n<p>for(int i &#061; 1; i &lt;&#061; m; i&#043;&#043;)<br \/>\n{<br \/>\n    int u &#061; edges[i].u, v &#061; edges[i].v, w &#061; edges[i].w;<br \/>\n    if(!isSame(u, v))<br \/>\n    {<br \/>\n        unionSet(u, v);<br \/>\n        ans &#043;&#061; w;<br \/>\n        cnt&#043;&#043;;<br \/>\n        if(cnt &#061;&#061; n &#8211; 1) break;<br \/>\n    }<br \/>\n}<\/p>\n<p>if(cnt &#061;&#061; n &#8211; 1) return ans;<br \/>\nelse return -1;  \/\/ \u56fe\u4e0d\u8fde\u901a<\/p>\n<p>}<\/p>\n<h4>3. \u6c42\u8fde\u901a\u5757\u4e2a\u6570<\/h4>\n<p>\u904d\u5386\u6240\u6709\u8282\u70b9&#xff0c;\u7edf\u8ba1\u6839\u8282\u70b9\u7684\u4e2a\u6570\u5373\u53ef\u3002<\/p>\n<p>int countComponents(int n) { int cnt &#061; 0; for(int i &#061; 1; i &lt;&#061; n; i&#043;&#043;) { if(find(i) &#061;&#061; i) cnt&#043;&#043;; } return cnt; }<\/p>\n<h4>4. \u5e26\u6743\u5e76\u67e5\u96c6&#xff08;\u6269\u5c55\u57df&#xff09;<\/h4>\n<p>\u5728\u7ef4\u62a4\u96c6\u5408\u5173\u7cfb\u7684\u540c\u65f6&#xff0c;\u8fd8\u53ef\u4ee5\u7ef4\u62a4\u8282\u70b9\u4e0e\u6839\u8282\u70b9\u4e4b\u95f4\u7684\u67d0\u79cd\u5173\u7cfb&#xff08;\u5982\u8ddd\u79bb\u3001\u79cd\u7c7b\u7b49&#xff09;&#xff0c;\u8fd9\u5c31\u662f\u5e26\u6743\u5e76\u67e5\u96c6\u3002<\/p>\n<h3>\u5e38\u89c1\u6280\u5de7\u4e0e\u6ce8\u610f\u4e8b\u9879<\/h3>\n<li>\n<p>\u8def\u5f84\u538b\u7f29\u8981\u5199\u5bf9&#xff1a;fa[x] &#061; find(fa[x]) \u800c\u4e0d\u662f return find(fa[x])<\/p>\n<\/li>\n<li>\n<p>\u5408\u5e76\u524d\u5148\u5224\u65ad\u662f\u5426\u5df2\u5728\u540c\u4e00\u96c6\u5408&#xff0c;\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u64cd\u4f5c<\/p>\n<\/li>\n<li>\n<p>\u521d\u59cb\u5316\u5f88\u91cd\u8981&#xff0c;\u4e0d\u8981\u5fd8\u8bb0\u8c03\u7528 init<\/p>\n<\/li>\n<li>\n<p>\u5e76\u67e5\u96c6\u4e0d\u80fd\u5f88\u597d\u5730\u652f\u6301\u62c6\u5206\u64cd\u4f5c&#xff0c;\u5982\u679c\u9700\u8981\u62c6\u5206\u96c6\u5408&#xff0c;\u9700\u8981\u8003\u8651\u5176\u4ed6\u6570\u636e\u7ed3\u6784<\/p>\n<\/li>\n<li>\n<p>\u5728\u5faa\u73af\u4e2d\u9891\u7e41\u4f7f\u7528 find \u65f6&#xff0c;\u53ef\u4ee5\u8003\u8651\u5148\u4fdd\u5b58\u6839\u8282\u70b9&#xff0c;\u907f\u514d\u91cd\u590d\u67e5\u8be2<\/p>\n<\/li>\n<p>int rootX &#061; find(x); int rootY &#061; find(y); \/\/ \u540e\u7eed\u4f7f\u7528 rootX \u548c rootY \u800c\u4e0d\u662f\u91cd\u590d\u8c03\u7528 find<\/p>\n<p>\u606d\u559c\u4f60\u521d\u6b65\u5b66\u4f1a\u4e86\u5e76\u67e5\u96c6&#xff0c;\u53ef\u4ee5\u53bb\u63a8\u8350\u9898\u76ee\u4e2d\u8bd5\u8bd5\u54e6&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u57fa\u672c\u7684\u6570\u7ec4\u64cd\u4f5c\u3001\u9012\u5f52\u601d\u60f3\u3002<br \/>\n\u4f8b\u9898 on Luogu&#xff1a;<br \/>\nP3367 \u3010\u6a21\u677f\u3011\u5e76\u67e5\u96c6<br \/>\n\u5e76\u67e5\u96c6\u7b80\u4ecb<br \/>\n\u5e76\u67e5\u96c6\u662f\u4e00\u79cd\u6811\u578b\u7684\u6570\u636e\u7ed3\u6784&#xff0c;\u7528\u4e8e\u5904\u7406\u4e00\u4e9b\u4e0d\u76f8\u4ea4\u96c6\u5408\u7684\u5408\u5e76\u53ca\u67e5\u8be2\u95ee\u9898\u3002\u5b83\u652f\u6301\u4e24\u79cd\u64cd\u4f5c&#xff1a;<br \/>\n\u67e5\u8be2&#xff08;Find&#xff09;&#xff1a;\u67e5\u8be2\u67d0\u4e2a\u5143\u7d20\u5c5e\u4e8e\u54ea\u4e2a\u96c6\u5408\u5408\u5e76&#xff08;Union&#xff09;&#xff1a;\u5c06\u4e24\u4e2a\u96c6\u5408\u5408\u5e76\u6210\u4e00\u4e2a\u96c6\u5408<br \/>\n\u5e76\u67e5\u96c6\u5728\u5224\u65ad\u56fe\u8fde\u901a\u6027\u3001\u6700\u5c0f\u751f\u6210\u6811&#xff08;K<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,1984,427],"topic":[],"class_list":["post-78138","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-1984","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb - \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\/78138.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u57fa\u672c\u7684\u6570\u7ec4\u64cd\u4f5c\u3001\u9012\u5f52\u601d\u60f3\u3002 \u4f8b\u9898 on Luogu&#xff1a; P3367 \u3010\u6a21\u677f\u3011\u5e76\u67e5\u96c6 \u5e76\u67e5\u96c6\u7b80\u4ecb \u5e76\u67e5\u96c6\u662f\u4e00\u79cd\u6811\u578b\u7684\u6570\u636e\u7ed3\u6784&#xff0c;\u7528\u4e8e\u5904\u7406\u4e00\u4e9b\u4e0d\u76f8\u4ea4\u96c6\u5408\u7684\u5408\u5e76\u53ca\u67e5\u8be2\u95ee\u9898\u3002\u5b83\u652f\u6301\u4e24\u79cd\u64cd\u4f5c&#xff1a; \u67e5\u8be2&#xff08;Find&#xff09;&#xff1a;\u67e5\u8be2\u67d0\u4e2a\u5143\u7d20\u5c5e\u4e8e\u54ea\u4e2a\u96c6\u5408\u5408\u5e76&#xff08;Union&#xff09;&#xff1a;\u5c06\u4e24\u4e2a\u96c6\u5408\u5408\u5e76\u6210\u4e00\u4e2a\u96c6\u5408 \u5e76\u67e5\u96c6\u5728\u5224\u65ad\u56fe\u8fde\u901a\u6027\u3001\u6700\u5c0f\u751f\u6210\u6811&#xff08;K\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/78138.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-26T01:25:09+00:00\" \/>\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\/78138.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/78138.html\",\"name\":\"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-26T01:25:09+00:00\",\"dateModified\":\"2026-02-26T01:25:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/78138.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/78138.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/78138.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb\"}]},{\"@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":"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb - \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\/78138.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u7f6e\u77e5\u8bc6&#xff1a;\u57fa\u672c\u7684\u6570\u7ec4\u64cd\u4f5c\u3001\u9012\u5f52\u601d\u60f3\u3002 \u4f8b\u9898 on Luogu&#xff1a; P3367 \u3010\u6a21\u677f\u3011\u5e76\u67e5\u96c6 \u5e76\u67e5\u96c6\u7b80\u4ecb \u5e76\u67e5\u96c6\u662f\u4e00\u79cd\u6811\u578b\u7684\u6570\u636e\u7ed3\u6784&#xff0c;\u7528\u4e8e\u5904\u7406\u4e00\u4e9b\u4e0d\u76f8\u4ea4\u96c6\u5408\u7684\u5408\u5e76\u53ca\u67e5\u8be2\u95ee\u9898\u3002\u5b83\u652f\u6301\u4e24\u79cd\u64cd\u4f5c&#xff1a; \u67e5\u8be2&#xff08;Find&#xff09;&#xff1a;\u67e5\u8be2\u67d0\u4e2a\u5143\u7d20\u5c5e\u4e8e\u54ea\u4e2a\u96c6\u5408\u5408\u5e76&#xff08;Union&#xff09;&#xff1a;\u5c06\u4e24\u4e2a\u96c6\u5408\u5408\u5e76\u6210\u4e00\u4e2a\u96c6\u5408 \u5e76\u67e5\u96c6\u5728\u5224\u65ad\u56fe\u8fde\u901a\u6027\u3001\u6700\u5c0f\u751f\u6210\u6811&#xff08;K","og_url":"https:\/\/www.wsisp.com\/helps\/78138.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-26T01:25:09+00:00","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\/78138.html","url":"https:\/\/www.wsisp.com\/helps\/78138.html","name":"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-26T01:25:09+00:00","dateModified":"2026-02-26T01:25:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/78138.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/78138.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/78138.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5e76\u67e5\u96c6\u7b97\u6cd5\u7b80\u4ecb"}]},{"@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\/78138","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=78138"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/78138\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=78138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=78138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=78138"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=78138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}