{"id":216873,"date":"2020-11-26T21:40:36","date_gmt":"2020-11-26T13:40:36","guid":{"rendered":"http:\/\/4563.org\/?p=216873"},"modified":"2020-11-26T21:40:36","modified_gmt":"2020-11-26T13:40:36","slug":"%e6%95%b0%e7%bb%84%e4%b8%aa%e6%95%b0%e4%b8%8d%e7%a1%ae%e5%ae%9a%ef%bc%8c%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e5%b7%ae%e5%bc%82%e5%80%bc","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=216873","title":{"rendered":"\u6570\u7ec4\u4e2a\u6570\u4e0d\u786e\u5b9a\uff0c\u5982\u4f55\u83b7\u53d6\u5dee\u5f02\u503c"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6570\u7ec4\u4e2a\u6570\u4e0d\u786e\u5b9a\uff0c\u5982\u4f55\u83b7\u53d6\u5dee\u5f02\u503c               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : s609926202 <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5047\u8bbe\uff0c\u6709\u6570\u7ec4$arr\uff0c$arr \u6709 n \uff08 n&gt;=2 \uff09\u4e2a key =&gt; value \uff08 value \u662f\u6570\u7ec4\uff09\uff0c\u672c\u4f8b\u53d6 3 \u4e2a:<\/p>\n<pre><code>$arr = [     'A' =&gt; [1, 2, 4, 5],     'B' =&gt; [2, 3, 4, 5, 6],     'C' =&gt; [1, 2, 3, 4, 5, 6], ]; <\/code><\/pre>\n<p>\u83b7\u53d6\u5dee\u5f02\u6570\u7ec4\u7ed3\u679c\u4e3a\uff1a<\/p>\n<pre><code>$arr = [     'A' =&gt; [1],     'B' =&gt; [3, 6],     'C' =&gt; [1, 3, 6], ]; <\/code><\/pre>\n<p>\u5373\uff0c$arr \u6570\u7ec4\u4e0b n \u4e2a key \u5bf9\u5e94\u6570\u7ec4\u53d6\u4ea4\u96c6\uff0c\u518d\u548c\u5f53\u524d key \u5bf9\u5e94\u6570\u7ec4\u5bf9\u6bd4\u53d6\u4e0d\u540c\u3002\u4f46\u662f n \u5f97\u6570\u91cf\u4e0d\u786e\u5b9a\u3002<br \/> \u8bf7\u95ee\u5982\u4f55\u5b9e\u73b0\uff1f\u8c22\u8c22\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4405553\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gstqc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a\u5b50\u6570\u7ec4\u6784\u6210 set<br \/>\u7136\u540e\u6c42\u591a\u4e2a set \u7684\u4ea4\u96c6<br \/>\u6700\u540e\u628a\u4ea4\u96c6\u5728\u5b50\u6570\u7ec4\u91cc\u5220\u6389                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4405554\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jmc891205 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u7528 divide and conquer \u6765\u8bbe\u8ba1\u5427<br \/>n \u4e2a\u6570\u7ec4\u7684\u4ea4\u96c6\uff0c\u80af\u5b9a\u662f\u524d n\/2 \u4e2a\u6570\u7ec4\u7684\u4ea4\u96c6\u548c\u540e n\/2 \u4e2a\u6570\u7ec4\u7684\u4ea4\u96c6\u7684\u4ea4\u96c6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4405555\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Ct1L <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &lt;?php<\/p>\n<p>$arr = [<br \/> &#8216;A&#8217; =&gt; [1, 2, 4, 5],<br \/> &#8216;B&#8217; =&gt; [2, 3, 4, 5, 6],<br \/> &#8216;C&#8217; =&gt; [1, 2, 3, 4, 5, 6]<br \/>];<\/p>\n<p>\/\/ \u6c42\u5168\u90e8\u5143\u7d20\u7684\u4ea4\u96c6<br \/>array_walk($arr,function ($v)use(&amp;$temp){<br \/> if (empty($temp)) {<br \/> $temp = $v;<br \/> }else{<br \/> $temp = array_intersect($temp,$v); <br \/> }<br \/>});<\/p>\n<p>\/\/ \u5bf9\u5185\u90e8\u6bcf\u4e2a\u5143\u7d20\u53d6\u5dee\u96c6<br \/>$res = array_map(function ($v)use($temp){<br \/> return array_diff($v,$temp);<br \/>},$arr);<\/p>\n<p>var_export($res);                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u7ec4\u4e2a\u6570\u4e0d\u786e\u5b9a\uff0c\u5982\u4f55\u83b7\u53d6\u5dee\u5f02\u503c \u8cc7&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/216873"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216873"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/216873\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216873"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}