{"id":273,"date":"2016-11-24T20:00:40","date_gmt":"2016-11-24T12:00:40","guid":{"rendered":"http:\/\/kylelv.com\/?p=273"},"modified":"2017-12-13T13:22:49","modified_gmt":"2017-12-13T05:22:49","slug":"bzoj-1191-hnoi2006%e8%b6%85%e7%ba%a7%e8%8b%b1%e9%9b%84hero","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=273","title":{"rendered":"bzoj 1191: [HNOI2006]\u8d85\u7ea7\u82f1\u96c4Hero"},"content":{"rendered":"<p><center><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef600539f\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef600539f\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#1191_HNOI2006%E8%B6%85%E7%BA%A7%E8%8B%B1%E9%9B%84Hero\" title=\"1191: [HNOI2006]\u8d85\u7ea7\u82f1\u96c4Hero\">1191: [HNOI2006]\u8d85\u7ea7\u82f1\u96c4Hero<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=273\/#HINT\" title=\"HINT\">HINT<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"1191_HNOI2006%E8%B6%85%E7%BA%A7%E8%8B%B1%E9%9B%84Hero\"><\/span>1191: [HNOI2006]\u8d85\u7ea7\u82f1\u96c4Hero<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a010 Sec\u00a0\u00a0Memory Limit:\u00a0162 MB<\/span><\/center><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u73b0\u5728\u7535\u89c6\u53f0\u6709\u4e00\u79cd\u8282\u76ee\u53eb\u505a\u8d85\u7ea7\u82f1\u96c4,\u5927\u6982\u7684\u6d41\u7a0b\u5c31\u662f\u6bcf\u4f4d\u9009\u624b\u5230\u53f0\u4e0a\u56de\u7b54\u4e3b\u6301\u4eba\u7684\u51e0\u4e2a\u95ee\u9898,\u7136\u540e\u6839\u636e\u56de\u7b54\u95ee\u9898\u7684\u591a\u5c11\u83b7\u5f97\u4e0d\u540c\u6570\u76ee\u7684\u5956\u54c1\u6216\u5956\u91d1\u3002\u4e3b\u6301\u4eba\u95ee\u9898\u51c6\u5907\u4e86\u82e5\u5e72\u9053\u9898\u76ee\uff0c\u53ea\u6709\u5f53\u9009\u624b\u6b63\u786e\u56de\u7b54\u4e00\u9053\u9898\u540e\uff0c\u624d\u80fd\u8fdb\u5165\u4e0b\u4e00\u9898\uff0c\u5426\u5219\u5c31\u88ab\u6dd8\u6c70\u3002\u4e3a\u4e86\u589e\u52a0\u8282\u76ee\u7684\u8da3\u5473\u6027\u5e76\u9002\u5f53\u964d\u4f4e\u96be\u5ea6\uff0c\u4e3b\u6301\u4eba\u603b\u63d0\u4f9b\u7ed9\u9009\u624b\u51e0\u4e2a\u201c\u9526\u56ca\u5999\u8ba1\u201d\uff0c\u6bd4\u5982\u6c42\u52a9\u73b0\u573a\u89c2\u4f17\uff0c\u6216\u8005\u53bb\u6389\u82e5\u5e72\u4e2a\u9519\u8bef\u7b54\u6848\uff08\u9009\u62e9\u9898\uff09\u7b49\u7b49\u3002 \u8fd9\u91cc\uff0c\u6211\u4eec\u628a\u89c4\u5219\u7a0d\u5fae\u6539\u53d8\u4e00\u4e0b\u3002\u5047\u8bbe\u4e3b\u6301\u4eba\u603b\u5171\u6709m\u9053\u9898\uff0c\u9009\u624b\u6709n\u79cd\u4e0d\u540c\u7684\u201c\u9526\u56ca\u5999\u8ba1\u201d\u3002\u4e3b\u6301\u4eba\u89c4\u5b9a\uff0c\u6bcf\u9053\u9898\u90fd\u53ef\u4ee5\u4ece\u4e24\u79cd\u201c\u9526\u56ca\u5999\u8ba1\u201d\u4e2d\u9009\u62e9\u4e00\u79cd\uff0c\u800c\u6bcf\u79cd\u201c\u9526\u56ca\u5999\u8ba1\u201d\u53ea\u80fd\u7528\u4e00\u6b21\u3002\u6211\u4eec\u53c8\u5047\u8bbe\u4e00\u9053\u9898\u4f7f\u7528\u4e86\u5b83\u5141\u8bb8\u7684\u9526\u56ca\u5999\u8ba1\u540e\uff0c\u5c31\u4e00\u5b9a\u80fd\u6b63\u786e\u56de\u7b54\uff0c\u987a\u5229\u8fdb\u5165\u4e0b\u4e00\u9898\u3002\u73b0\u5728\u6211\u6765\u5230\u4e86\u8282\u76ee\u73b0\u573a\uff0c\u53ef\u662f\u6211\u5b9e\u5728\u662f\u592a\u7b28\u4e86\uff0c\u4ee5\u81f3\u4e8e\u4e00\u9053\u9898\u4e5f\u4e0d\u4f1a\u505a\uff0c\u6bcf\u9053\u9898\u53ea\u597d\u501f\u52a9\u4f7f\u7528\u201c\u9526\u56ca\u5999\u8ba1\u201d\u6765\u901a\u8fc7\u3002\u5982\u679c\u6211\u4e8b\u5148\u5c31\u77e5\u9053\u4e86\u6bcf\u9053\u9898\u80fd\u591f\u4f7f\u7528\u54ea\u4e24\u79cd\u201c\u9526\u56ca\u5999\u8ba1\u201d\uff0c\u90a3\u4e48\u4f60\u80fd\u544a\u8bc9\u6211\u600e\u6837\u9009\u62e9\u624d\u80fd\u901a\u8fc7\u6700\u591a\u7684\u9898\u6570\u5417\uff1f<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u8f93\u5165\u6587\u4ef6\u7684\u4e00\u884c\u662f\u4e24\u4e2a\u6b63\u6574\u6570n\u548cm(0 &lt; n &lt;1001,0 &lt; m &lt; 1001)\u8868\u793a\u603b\u5171\u6709n\u4e2d\u201c\u9526\u56ca\u5999\u8ba1\u201d\uff0c\u7f16\u53f7\u4e3a0~n-1\uff0c\u603b\u5171\u6709m\u4e2a\u95ee\u9898\u3002<br \/>\n\u4ee5\u4e0b\u7684m\u884c\uff0c\u6bcf\u884c\u4e24\u4e2a\u6570\uff0c\u5206\u522b\u8868\u793a\u7b2cm\u4e2a\u95ee\u9898\u53ef\u4ee5\u4f7f\u7528\u7684\u201c\u9526\u56ca\u5999\u8ba1\u201d\u7684\u7f16\u53f7\u3002<br \/>\n\u6ce8\u610f\uff0c\u6bcf\u79cd\u7f16\u53f7\u7684\u201c\u9526\u56ca\u5999\u8ba1\u201d\u53ea\u80fd\u4f7f\u7528\u4e00\u6b21\uff0c\u540c\u4e00\u4e2a\u95ee\u9898\u7684\u4e24\u4e2a\u201c\u9526\u56ca\u5999\u8ba1\u201d\u53ef\u80fd\u4e00\u6837\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u7b2c\u4e00\u884c\u4e3a\u6700\u591a\u80fd\u901a\u8fc7\u7684\u9898\u6570p<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">5 6<br \/>\n3 2<br \/>\n2 0<br \/>\n0 3<br \/>\n0 4<br \/>\n3 2<br \/>\n3 2<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">4<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4e8c\u5206\u56fe\u5339\u914d\u3002\u3002\u3002<\/p>\n<pre class=\"lang:c++ decode:true \">#include&lt;cstdio&gt;\r\nint sum,n,m,a[1010][2],fa[1010];\r\nbool tr[1010];\r\nbool findf(int x)\r\n{\r\n    for(int i=0;i&lt;2;i++)\r\n    {\r\n        int y=a[x][i];\r\n        if(!tr[y])\r\n        {\r\n            tr[y]=1;\r\n            if(!fa[y]||findf(fa[y])){fa[y]=x;return 1;}\r\n        }\r\n    }\r\n    return 0;\r\n}\r\nint main()\r\n{\r\n    scanf(\"%d%d\",&amp;n,&amp;m);\r\n    for(int i=1;i&lt;=n;i++) scanf(\"%d%d\",&amp;a[i][0],&amp;a[i][1]);\r\n    for(int i=1;i&lt;=m;i++)\r\n    {\r\n        for(int j=0;j&lt;=m;j++) tr[j]=0;\r\n        if(findf(i)) sum++;\r\n        else break;\r\n    }\r\n    printf(\"%d\",sum);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1191: [HNOI2006]\u8d85\u7ea7\u82f1\u96c4Hero Time Limit:\u00a010 Sec\u00a0\u00a0Memory Lim [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12],"class_list":["post-273","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-12"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/273\/revisions\/274"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}