{"id":27702,"date":"2024-10-27T14:43:13","date_gmt":"2024-10-27T14:43:13","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=27702"},"modified":"2024-11-26T07:16:01","modified_gmt":"2024-11-26T07:16:01","slug":"c-%ec%bd%94%eb%94%a9%ed%85%8c%ec%8a%a4%ed%8a%b8-%ea%b0%95%ec%a2%8c-%ec%9c%a0%eb%8b%88%ec%98%a8-%ed%8c%8c%ec%9d%b8%eb%93%9c-2","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/27702\/","title":{"rendered":"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc"},"content":{"rendered":"<p><body><\/p>\n<p>\uc54c\uace0\ub9ac\uc998 \ubb38\uc81c \ud574\uacb0\uc5d0 \uc788\uc5b4 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc790\ub8cc\uad6c\uc870\ub294 \ub9e4\uc6b0 \uc720\uc6a9\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc\uc758 \uac1c\ub150\uacfc C++\uc744 \uc0ac\uc6a9\ud55c \ubb38\uc81c \ud480\uc774 \uacfc\uc815\uc744 \uc0c1\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>\uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\ub780?<\/h2>\n<p>\uc720\ub2c8\uc628 \ud30c\uc778\ub4dc \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc54c\uace0\ub9ac\uc998\uc740 \ub370\uc774\ud130\uc758 \uc9d1\ud569\uc744 \ud6a8\uc728\uc801\uc73c\ub85c \uad00\ub9ac\ud558\ub294 \uc790\ub8cc\uad6c\uc870\uc785\ub2c8\ub2e4. \uc774 \uc790\ub8cc\uad6c\uc870\ub294 \uc11c\ub85c\uc18c \uc9d1\ud569(Disjoint Set)\uc73c\ub85c\ub3c4 \uc54c\ub824\uc838 \uc788\uc73c\uba70, \uc8fc\ub85c \ub2e4\uc74c \ub450 \uac00\uc9c0 \uc5f0\uc0b0\uc744 \uc9c0\uc6d0\ud569\ub2c8\ub2e4:<\/p>\n<ul>\n<li><strong>Find:<\/strong> \ud2b9\uc815 \uc6d0\uc18c\uac00 \uc5b4\ub5a4 \uc9d1\ud569\uc5d0 \uc18d\ud558\ub294\uc9c0\ub97c \ucc3e\ub294 \uc5f0\uc0b0\uc785\ub2c8\ub2e4. \uc774 \uc5f0\uc0b0\uc740 \uc9d1\ud569\uc758 \ub300\ud45c \uc6d0\uc18c(\ub8e8\ud2b8 \ub178\ub4dc)\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/li>\n<li><strong>Union:<\/strong> \ub450 \uac1c\uc758 \uc9d1\ud569\uc744 \ud1b5\ud569\ud558\ub294 \uc5f0\uc0b0\uc785\ub2c8\ub2e4. \uc774 \uc5f0\uc0b0\uc740 \ub450 \uc9d1\ud569\uc758 \ub8e8\ud2b8 \ub178\ub4dc\ub97c \uc5f0\uacb0\ud558\uc5ec \ud558\ub098\uc758 \uc9d1\ud569\uc73c\ub85c \ub9cc\ub4ed\ub2c8\ub2e4.<\/li>\n<\/ul>\n<p>\uc8fc\ub85c \uadf8\ub798\ud504 \uc774\ub860\uc5d0\uc11c \uc0ac\uc774\ud074\uc744 \ucc3e\uac70\ub098, \uc5f0\uacb0 \uc694\uc18c\ub97c \uac80\uc0ac\ud558\ub294 \ubb38\uc81c\uc5d0\uc11c \ub9ce\uc774 \uc0ac\uc6a9\ub429\ub2c8\ub2e4. \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\ub97c \ud6a8\uacfc\uc801\uc73c\ub85c \ud65c\uc6a9\ud558\uae30 \uc704\ud574 \ub450 \uac00\uc9c0 \ucd5c\uc801\ud654 \uae30\ubc95\uc774 \uc788\uc2b5\ub2c8\ub2e4:<\/p>\n<h3>1. \uacbd\ub85c \uc555\ucd95(Path Compression)<\/h3>\n<p>Find \uc5f0\uc0b0\uc744 \uc218\ud589\ud560 \ub54c, \uacbd\ub85c\ub97c \ub530\ub77c \ubaa8\ub4e0 \ub178\ub4dc\uc758 \ubd80\ubaa8\ub97c \ub8e8\ud2b8 \ub178\ub4dc\ub85c \uc5c5\ub370\uc774\ud2b8\ud558\uc5ec, \ub2e4\uc74c \ubc88\uc5d0 \ubcf4\ub2e4 \ube60\ub974\uac8c \ub8e8\ud2b8 \ub178\ub4dc\ub97c \ucc3e\uc744 \uc218 \uc788\ub3c4\ub85d \ud569\ub2c8\ub2e4.<\/p>\n<h3>2. \ub7ad\ud06c \uae30\ubc18 \uc720\ub2c8\uc628(Rank-based Union)<\/h3>\n<p>Union \uc5f0\uc0b0\uc744 \uc218\ud589\ud560 \ub54c, \ub450 \uc9d1\ud569\uc758 \ud06c\uae30\ub97c \ube44\uad50\ud558\uc5ec \ub354 \uc791\uc740 \uc9d1\ud569\uc744 \ub354 \ud070 \uc9d1\ud569\uc758 \uc790\uc2dd\uc73c\ub85c \uc5f0\uacb0\ud569\ub2c8\ub2e4. \uc774\ub807\uac8c \ud558\uba74 \ud2b8\ub9ac\uc758 \ub192\uc774\ub97c \uc904\uc77c \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>\ubb38\uc81c \uc124\uba85<\/h2>\n<p>\uc774\uc81c \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc \uc54c\uace0\ub9ac\uc998\uc744 \uc0ac\uc6a9\ud558\uc5ec \ud574\uacb0\ud560 \uc218 \uc788\ub294 \ubb38\uc81c\ub97c \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \uc544\ub798\uc758 \ubb38\uc81c\ub97c \ud480\uc5b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<h3>\ubb38\uc81c: \uce5c\uad6c \ub124\ud2b8\uc6cc\ud06c<\/h3>\n<p>\uc5ec\ub7ec \uce5c\uad6c\ub4e4\uc774 \uc11c\ub85c \uc5f0\uacb0\ub418\uc5b4 \uc788\ub294 \uce5c\uad6c \ub124\ud2b8\uc6cc\ud06c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uac01 \uce5c\uad6c\ub294 1\uc5d0\uc11c N\uae4c\uc9c0\uc758 \ubc88\ud638\ub85c \uc2dd\ubcc4\ub429\ub2c8\ub2e4. \ub450 \uce5c\uad6c\uac00 \uc11c\ub85c \uce5c\uad6c\ub77c\uace0 \ubd88\ub9ac\ub824\uba74 \uadf8\ub4e4\uc740 \uc9c1\uc811\uc801\uc778 \uce5c\uad6c\uc774\uac70\ub098 \uac04\uc811\uc801\uc73c\ub85c \uce5c\uad6c\uac00 \ub418\uc5b4\uc57c \ud569\ub2c8\ub2e4. \ub2f9\uc2e0\uc5d0\uac8c \uc8fc\uc5b4\uc9c4 \uce5c\uad6c\uc758 \uc30d (a, b)\uac00 \uc788\uc744 \ub54c, \uce5c\uad6c \ub124\ud2b8\uc6cc\ud06c\uc5d0\uc11c a\uc640 b\uac00 \uac19\uc740 \uce5c\uad6c \uadf8\ub8f9\uc5d0 \uc18d\ud558\ub294\uc9c0 \ud655\uc778\ud558\uc2dc\uc624.<\/p>\n<h4>\uc785\ub825 \ud615\uc2dd<\/h4>\n<ul>\n<li>\uccab\uc9f8 \uc904\uc5d0 \uce5c\uad6c\uc758 \uc218 N\uacfc \uce5c\uad6c \uad00\uacc4\uc758 \uc218 M\uc774 \uc8fc\uc5b4\uc9c4\ub2e4. (1 \u2264 N \u2264 100,000, 1 \u2264 M \u2264 100,000)<\/li>\n<li>\ub458\uc9f8 \uc904\ubd80\ud130 M\uac1c\uc758 \uc904\uc5d0 \uac78\uccd0 \uce5c\uad6c \uad00\uacc4 a, b \uc758 \uc30d\uc774 \uc8fc\uc5b4\uc9c4\ub2e4.<\/li>\n<li>\ub9c8\uc9c0\ub9c9 \uc904\uc5d0\ub294 \ucffc\ub9ac Q\uac00 \ub4e4\uc5b4\uc624\uba70, \uac01 \ucffc\ub9ac\uc5d0\ub294 \uce5c\uad6c \uc30d \uadf8\ub4e4 (x, y)\uac00 \uc8fc\uc5b4\uc9c4\ub2e4.<\/li>\n<\/ul>\n<h4>\ucd9c\ub825 \ud615\uc2dd<\/h4>\n<p>\uac01 \ucffc\ub9ac\uc5d0 \ub300\ud574, x\uc640 y\uac00 \uac19\uc740 \uce5c\uad6c \uadf8\ub8f9\uc5d0 \uc18d\ud558\uba74 &#8216;YES&#8217;, \uadf8\ub807\uc9c0 \uc54a\uc73c\uba74 &#8216;NO&#8217;\ub97c \ucd9c\ub825\ud558\uc2dc\uc624.<\/p>\n<h2>\uc54c\uace0\ub9ac\uc998 \uc811\uadfc \ubc29\ubc95<\/h2>\n<ol>\n<li>\uc720\ub2c8\uc628-\ud30c\uc778\ub4dc\ub97c \uc0ac\uc6a9\ud558\uc5ec \uce5c\uad6c \uad00\uacc4\ub97c \ucd08\uae30\ud654\ud558\uace0 \uc5f0\uacb0\ud569\ub2c8\ub2e4. <code>Union(a, b)<\/code> \ub97c \uc0ac\uc6a9\ud558\uc5ec a\uc640 b\ub97c \uac19\uc740 \uc9d1\ud569\uc73c\ub85c \uc5f0\uacb0\ud569\ub2c8\ub2e4.<\/li>\n<li>\ucffc\ub9ac\uc5d0 \ub300\ud574 <code>Find(x)<\/code>\uc640 <code>Find(y)<\/code>\ub97c \uc0ac\uc6a9\ud558\uc5ec \ub450 \uce5c\uad6c\uc758 \ub8e8\ud2b8 \ub178\ub4dc\ub97c \ud655\uc778\ud569\ub2c8\ub2e4. \ub458\uc774 \ub3d9\uc77c\ud55c \ub8e8\ud2b8 \ub178\ub4dc\ub97c \uac00\uc9c0\uba74 &#8216;YES&#8217;, \uadf8\ub807\uc9c0 \uc54a\uc73c\uba74 &#8216;NO&#8217;\ub97c \ucd9c\ub825\ud569\ub2c8\ub2e4.<\/li>\n<\/ol>\n<h2>C++ \ucf54\ub4dc \uad6c\ud604<\/h2>\n<p>\uc544\ub798\ub294 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc \uc54c\uace0\ub9ac\uc998\uc744 \uad6c\ud604\ud55c C++ \ucf54\ub4dc\uc785\ub2c8\ub2e4:<\/p>\n<pre><code>\n#include <iostream>\n#include <vector>\nusing namespace std;\n\nclass UnionFind {\npublic:\n    UnionFind(int n) {\n        parent.resize(n);\n        rank.resize(n, 0);\n        for (int i = 0; i &lt; n; ++i) {\n            parent[i] = i;\n        }\n    }\n\n    int find(int x) {\n        if (parent[x] != x) {\n            parent[x] = find(parent[x]); \/\/ \uacbd\ub85c \uc555\ucd95\n        }\n        return parent[x];\n    }\n\n    void unionSets(int x, int y) {\n        int rootX = find(x);\n        int rootY = find(y);\n\n        if (rootX != rootY) {\n            \/\/ \ub7ad\ud06c \uae30\ubc18 \uc720\ub2c8\uc628\n            if (rank[rootX] &gt; rank[rootY]) {\n                parent[rootY] = rootX;\n            } else if (rank[rootX] &lt; rank[rootY]) {\n                parent[rootX] = rootY;\n            } else {\n                parent[rootY] = rootX;\n                rank[rootX]++;\n            }\n        }\n    }\n\nprivate:\n    vector<int> parent;\n    vector<int> rank;\n};\n\nint main() {\n    int N, M;\n    cin &gt;&gt; N &gt;&gt; M;\n    UnionFind uf(N + 1);\n\n    for (int i = 0; i &lt; M; i++) {\n        int a, b;\n        cin &gt;&gt; a &gt;&gt; b;\n        uf.unionSets(a, b);\n    }\n\n    int Q;\n    cin &gt;&gt; Q;\n    for (int i = 0; i &lt; Q; i++) {\n        int x, y;\n        cin &gt;&gt; x &gt;&gt; y;\n        if (uf.find(x) == uf.find(y)) {\n            cout &lt;&lt; \"YES\" &lt;&lt; endl;\n        } else {\n            cout &lt;&lt; \"NO\" &lt;&lt; endl;\n        }\n    }\n\n    return 0;\n}\n<\/int><\/int><\/vector><\/iostream><\/code><\/pre>\n<h2>\ucf54\ub4dc \uc124\uba85<\/h2>\n<p>\uc704\uc758 C++ \ucf54\ub4dc\uc5d0\uc11c \uc6b0\ub9ac\ub294 \ub2e4\uc74c\uacfc \uac19\uc740 \uad6c\uc131 \uc694\uc18c\ub97c \uad6c\ud604\ud558\uc600\uc2b5\ub2c8\ub2e4:<\/p>\n<ul>\n<li><strong>UnionFind \ud074\ub798\uc2a4:<\/strong> \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc \uc54c\uace0\ub9ac\uc998\uc758 \uc8fc\uc694 \ub85c\uc9c1\uc744 \ud3ec\ud568\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. <code>find<\/code> \ud568\uc218\ub294 \ub8e8\ud2b8 \ub178\ub4dc\ub97c \ucc3e\uace0, <code>unionSets<\/code> \ud568\uc218\ub294 \ub450 \uc9d1\ud569\uc744 \ud1b5\ud569\ud569\ub2c8\ub2e4.<\/li>\n<li><strong>\uba54\uc778 \ud568\uc218:<\/strong> \uce5c\uad6c \uad00\uacc4\ub97c \uc785\ub825 \ubc1b\uc544 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc \uad6c\uc870\uc5d0 \uc800\uc7a5\ud558\uace0 \uc8fc\uc5b4\uc9c4 \ucffc\ub9ac\uc5d0 \ub300\ud55c \uacb0\uacfc\ub97c \ucd9c\ub825\ud569\ub2c8\ub2e4.<\/li>\n<\/ul>\n<h2>\uc2dc\uac04 \ubcf5\uc7a1\ub3c4<\/h2>\n<p>\uc720\ub2c8\uc628-\ud30c\uc778\ub4dc \uc54c\uace0\ub9ac\uc998\uc758 \uc2dc\uac04 \ubcf5\uc7a1\ub3c4\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<ul>\n<li>Find \uc5f0\uc0b0: \uac70\uc758 \uc0c1\uc218 \uc2dc\uac04 (\u03b1(N), \uc544\ucee4\ub9cc \ud568\uc218\uc758 \uc5ed\ud568\uc218\uc5d0 \ube44\ub840)<\/li>\n<li>Union \uc5f0\uc0b0: \uac70\uc758 \uc0c1\uc218 \uc2dc\uac04<\/li>\n<\/ul>\n<p>\ub530\ub77c\uc11c \uc804\uccb4 \uc54c\uace0\ub9ac\uc998\uc758 \uc2dc\uac04 \ubcf5\uc7a1\ub3c4\ub294 O(M * \u03b1(N)) \uc785\ub2c8\ub2e4. \uc5ec\uae30\uc11c M\uc740 \uce5c\uad6c \uad00\uacc4\uc758 \uc218\uc785\ub2c8\ub2e4.<\/p>\n<h2>\uacb0\ub860<\/h2>\n<p>\uc774\ubc88 \uac15\uc88c\uc5d0\uc11c\ub294 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc \uc790\ub8cc\uad6c\uc870\uc758 \uac1c\ub150\uacfc C++\uc744 \ud65c\uc6a9\ud55c \ubb38\uc81c \ud480\uc774 \uacfc\uc815\uc744 \uc790\uc138\ud788 \uc0b4\ud3b4\ubcf4\uc558\uc2b5\ub2c8\ub2e4. \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc\ub294 \ub2e4\uc591\ud55c \ubb38\uc81c\uc5d0\uc11c \ud6a8\uacfc\uc801\uc73c\ub85c \ud65c\uc6a9\ub420 \uc218 \uc788\ub294 \uac15\ub825\ud55c \ub3c4\uad6c\uc785\ub2c8\ub2e4. \uc55e\uc73c\ub85c\uc758 \ucf54\ub529 \ud14c\uc2a4\ud2b8\uc5d0\uc11c \ub9ce\uc740 \ub3c4\uc6c0\uc774 \ub418\uae30\ub97c \ubc14\ub78d\ub2c8\ub2e4.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc54c\uace0\ub9ac\uc998 \ubb38\uc81c \ud574\uacb0\uc5d0 \uc788\uc5b4 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc790\ub8cc\uad6c\uc870\ub294 \ub9e4\uc6b0 \uc720\uc6a9\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc\uc758 \uac1c\ub150\uacfc C++\uc744 \uc0ac\uc6a9\ud55c \ubb38\uc81c \ud480\uc774 \uacfc\uc815\uc744 \uc0c1\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\ub780? \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc54c\uace0\ub9ac\uc998\uc740 \ub370\uc774\ud130\uc758 \uc9d1\ud569\uc744 \ud6a8\uc728\uc801\uc73c\ub85c \uad00\ub9ac\ud558\ub294 \uc790\ub8cc\uad6c\uc870\uc785\ub2c8\ub2e4. \uc774 \uc790\ub8cc\uad6c\uc870\ub294 \uc11c\ub85c\uc18c \uc9d1\ud569(Disjoint Set)\uc73c\ub85c\ub3c4 \uc54c\ub824\uc838 \uc788\uc73c\uba70, \uc8fc\ub85c \ub2e4\uc74c \ub450 \uac00\uc9c0 \uc5f0\uc0b0\uc744 \uc9c0\uc6d0\ud569\ub2c8\ub2e4: Find: \ud2b9\uc815 \uc6d0\uc18c\uac00 \uc5b4\ub5a4 \uc9d1\ud569\uc5d0 \uc18d\ud558\ub294\uc9c0\ub97c \ucc3e\ub294 \uc5f0\uc0b0\uc785\ub2c8\ub2e4. \uc774 \uc5f0\uc0b0\uc740 \uc9d1\ud569\uc758 \ub300\ud45c &hellip; <a href=\"https:\/\/atmokpo.com\/w\/27702\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-27702","post","type-post","status-publish","format-standard","hentry","category-c---2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/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:\/\/atmokpo.com\/w\/27702\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"\uc54c\uace0\ub9ac\uc998 \ubb38\uc81c \ud574\uacb0\uc5d0 \uc788\uc5b4 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc790\ub8cc\uad6c\uc870\ub294 \ub9e4\uc6b0 \uc720\uc6a9\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc\uc758 \uac1c\ub150\uacfc C++\uc744 \uc0ac\uc6a9\ud55c \ubb38\uc81c \ud480\uc774 \uacfc\uc815\uc744 \uc0c1\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\ub780? \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc54c\uace0\ub9ac\uc998\uc740 \ub370\uc774\ud130\uc758 \uc9d1\ud569\uc744 \ud6a8\uc728\uc801\uc73c\ub85c \uad00\ub9ac\ud558\ub294 \uc790\ub8cc\uad6c\uc870\uc785\ub2c8\ub2e4. \uc774 \uc790\ub8cc\uad6c\uc870\ub294 \uc11c\ub85c\uc18c \uc9d1\ud569(Disjoint Set)\uc73c\ub85c\ub3c4 \uc54c\ub824\uc838 \uc788\uc73c\uba70, \uc8fc\ub85c \ub2e4\uc74c \ub450 \uac00\uc9c0 \uc5f0\uc0b0\uc744 \uc9c0\uc6d0\ud569\ub2c8\ub2e4: Find: \ud2b9\uc815 \uc6d0\uc18c\uac00 \uc5b4\ub5a4 \uc9d1\ud569\uc5d0 \uc18d\ud558\ub294\uc9c0\ub97c \ucc3e\ub294 \uc5f0\uc0b0\uc785\ub2c8\ub2e4. \uc774 \uc5f0\uc0b0\uc740 \uc9d1\ud569\uc758 \ub300\ud45c &hellip; \ub354 \ubcf4\uae30 &quot;C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/27702\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-27T14:43:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T07:16:01+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/27702\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/27702\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\",\"datePublished\":\"2024-10-27T14:43:13+00:00\",\"dateModified\":\"2024-11-26T07:16:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/27702\/\"},\"wordCount\":60,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/27702\/\",\"url\":\"https:\/\/atmokpo.com\/w\/27702\/\",\"name\":\"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-10-27T14:43:13+00:00\",\"dateModified\":\"2024-11-26T07:16:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/27702\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/27702\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/27702\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","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:\/\/atmokpo.com\/w\/27702\/","og_locale":"ko_KR","og_type":"article","og_title":"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"\uc54c\uace0\ub9ac\uc998 \ubb38\uc81c \ud574\uacb0\uc5d0 \uc788\uc5b4 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc790\ub8cc\uad6c\uc870\ub294 \ub9e4\uc6b0 \uc720\uc6a9\ud569\ub2c8\ub2e4. \uc774 \uae00\uc5d0\uc11c\ub294 \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc\uc758 \uac1c\ub150\uacfc C++\uc744 \uc0ac\uc6a9\ud55c \ubb38\uc81c \ud480\uc774 \uacfc\uc815\uc744 \uc0c1\uc138\ud788 \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\ub780? \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc \uc720\ub2c8\uc628-\ud30c\uc778\ub4dc(Union-Find) \uc54c\uace0\ub9ac\uc998\uc740 \ub370\uc774\ud130\uc758 \uc9d1\ud569\uc744 \ud6a8\uc728\uc801\uc73c\ub85c \uad00\ub9ac\ud558\ub294 \uc790\ub8cc\uad6c\uc870\uc785\ub2c8\ub2e4. \uc774 \uc790\ub8cc\uad6c\uc870\ub294 \uc11c\ub85c\uc18c \uc9d1\ud569(Disjoint Set)\uc73c\ub85c\ub3c4 \uc54c\ub824\uc838 \uc788\uc73c\uba70, \uc8fc\ub85c \ub2e4\uc74c \ub450 \uac00\uc9c0 \uc5f0\uc0b0\uc744 \uc9c0\uc6d0\ud569\ub2c8\ub2e4: Find: \ud2b9\uc815 \uc6d0\uc18c\uac00 \uc5b4\ub5a4 \uc9d1\ud569\uc5d0 \uc18d\ud558\ub294\uc9c0\ub97c \ucc3e\ub294 \uc5f0\uc0b0\uc785\ub2c8\ub2e4. \uc774 \uc5f0\uc0b0\uc740 \uc9d1\ud569\uc758 \ub300\ud45c &hellip; \ub354 \ubcf4\uae30 \"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc\"","og_url":"https:\/\/atmokpo.com\/w\/27702\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-10-27T14:43:13+00:00","article_modified_time":"2024-11-26T07:16:01+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"1\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/27702\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/27702\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc","datePublished":"2024-10-27T14:43:13+00:00","dateModified":"2024-11-26T07:16:01+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/27702\/"},"wordCount":60,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/27702\/","url":"https:\/\/atmokpo.com\/w\/27702\/","name":"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-10-27T14:43:13+00:00","dateModified":"2024-11-26T07:16:01+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/27702\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/27702\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/27702\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"C++ \ucf54\ub529\ud14c\uc2a4\ud2b8 \uac15\uc88c, \uc720\ub2c8\uc628 \ud30c\uc778\ub4dc"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/27702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=27702"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/27702\/revisions"}],"predecessor-version":[{"id":27703,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/27702\/revisions\/27703"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=27702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=27702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=27702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}