{"id":277,"date":"2010-06-06T15:06:00","date_gmt":"2010-06-06T07:06:00","guid":{"rendered":"http:\/\/localhost\/?p=277"},"modified":"2010-06-06T15:06:00","modified_gmt":"2010-06-06T07:06:00","slug":"hnoi2008_magic_kingdom","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=277","title":{"rendered":"[HNOI2008]\u795e\u5947\u7684\u56fd\u5ea6"},"content":{"rendered":"\n<p>[HNOI2008]\u795e\u5947\u7684\u56fd\u5ea6<\/p>\n<p>Time Limit:20000MS  Memory Limit:165536K<br \/>Total Submit:150 Accepted:41 <br \/>Case Time Limit:5000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p>K\u56fd\u662f\u4e00\u4e2a\u70ed\u8877\u4e09\u89d2\u5f62\u7684\u56fd\u5ea6,\u8fde\u4eba\u7684\u4ea4\u5f80\u4e5f\u53ea\u559c\u6b22\u4e09\u89d2\u539f\u5219.\u4ed6\u4eec\u8ba4\u4e3a\u4e09\u89d2\u5173\u7cfb:\u5373AB\u76f8\u4e92\u8ba4\u8bc6,BC\u76f8\u4e92\u8ba4\u8bc6,CA\u76f8\u4e92\u8ba4\u8bc6,\u662f\u7b80\u6d01\u9ad8\u6548\u7684.\u4e3a\u4e86\u5de9\u56fa\u4e09\u89d2\u5173\u7cfb,K\u56fd\u7981\u6b62\u56db\u8fb9\u5173\u7cfb,\u4e94\u8fb9\u5173\u7cfb\u7b49\u7b49\u7684\u5b58\u5728.\u6240\u8c13N\u8fb9\u5173\u7cfb,\u662f\u6307N\u4e2a\u4eba <br \/>A1A2&#8230;An\u4e4b\u95f4\u4ec5\u5b58\u5728N\u5bf9\u8ba4\u8bc6\u5173\u7cfb:(A1A2)(A2A3)&#8230;(AnA1),\u800c\u6ca1\u6709\u5176\u5b83\u8ba4\u8bc6\u5173\u7cfb.\u6bd4\u5982\u56db\u8fb9\u5173\u7cfb\u6307ABCD\u56db\u4e2a\u4eba <br \/>AB,BC,CD,DA\u76f8\u4e92\u8ba4\u8bc6,\u800cAC,BD\u4e0d\u8ba4\u8bc6.\u5168\u6c11\u6bd4\u8d5b\u65f6,\u4e3a\u4e86\u9632\u6b62\u505a\u5f0a\uff0c\u89c4\u5b9a\u4efb\u610f\u4e00\u5bf9\u76f8\u4e92\u8ba4\u8bc6\u7684\u4eba\u4e0d\u5f97\u5728\u4e00\u961f\uff0c\u56fd\u738b\u76f8\u77e5\u9053\uff0c\u6700\u5c11\u53ef\u4ee5\u5206\u591a\u5c11\u652f\u961f\u3002 <\/p>\n<p><strong>Input <\/strong><\/p>\n<p>\u7b2c\u4e00\u884c\u4e24\u4e2a\u6574\u6570N\uff0cM\u30021&lt;=N&lt;=10000,1&lt;=M&lt;=1000000.\u8868\u793a\u6709N\u4e2a\u4eba\uff0cM\u5bf9\u8ba4\u8bc6\u5173\u7cfb. <br \/>\u63a5\u4e0b\u6765M\u884c\u6bcf\u884c\u8f93\u5165\u4e00\u5bf9\u670b\u53cb <\/p>\n<p><strong>Output <\/strong><\/p>\n<p>\u8f93\u51fa\u4e00\u4e2a\u6574\u6570\uff0c\u6700\u5c11\u53ef\u4ee5\u5206\u591a\u5c11\u961f <\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<\/p>\n<p><strong>Hint <\/strong><\/p>\n<p>\u4e00\u79cd\u65b9\u6848(1,3)(2)(4)<\/p>\n<p><strong>Source <br \/>\u54ce\u3002\u3002\u603b\u7b97\u5dee\u4e0d\u591a\u505a\u5b8cHNOI2008\u4e86\u3002\u3002\u6211\u771f\u662f\u4e2a\u50bb\u53c9\u554a\u3002\u3002<br \/>\u8fd9\u9898\u5f53\u65f6\u5c31\u628a\u6211\u9707\u60ca\u4e86\u3002\u3002\u4e00\u70b9\u601d\u8def\u90fd\u6ca1\u6709\u3002\u3002\u6700\u5c0f\u67d3\u8272\u6570\u4e0d\u662fNP\u95ee\u9898\u4e48\uff1f<br \/>\u540e\u6765\u770b\u4e86<\/strong><a href=\"http:\/\/61.187.179.132:8080\/JudgeOnline\/userstatus?user_id=AekdyCoin\"><strong>AekdyCoin<\/strong><\/a><strong>\u795e\u725b\u7684\u9898\u89e3\u624d\u660e\u767d\u8fd9\u662f\u4e2a\u5f26\u56fe\u3002\u3002\u6240\u4ee5\u6709\u4e13\u95e8\u7684\u7b97\u6cd5\u3002\u3002<br \/>\u795e\u725b\u5df2\u7ecf\u8bf4\u7684\u5f88\u6e05\u695a\u4e86\u3002\u3002Orz\uff01\uff01\uff01\uff01\uff01\uff01\uff01<br \/>Code\uff1a<br \/>#include &lt;vector&gt;<\/strong><br \/>#include &lt;cstdio&gt;<br \/>#include &lt;iostream&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>#define tr(e,x) for(it e=x.begin();e!=x.end();e++)<br \/>const int maxn=10000+10;<br \/>using namespace std;<br \/>typedef vector&lt;int&gt;::iterator it;<br \/>int n,m,cnt[maxn]={},c[maxn]={},hash[maxn]={};<br \/>bool v[maxn]={};<br \/>vector&lt;int&gt; E[maxn],ord;<br \/>int main()<br \/>{<br \/>&nbsp;&nbsp;&nbsp;  \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>&nbsp;&nbsp;&nbsp;  scanf(&quot;%d%d&quot;,&amp;n,&amp;m);int s,t;<br \/>&nbsp;&nbsp;&nbsp;  while(m&#8211;)scanf(&quot;%d%d&quot;,&amp;s,&amp;t),&#8211;s,&#8211;t,E[s].pb(t),E[t].pb(s);<br \/>&nbsp;&nbsp;&nbsp;  rep(i,n)<br \/>&nbsp;&nbsp;&nbsp;  {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  int max=-1,t;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  rep(j,n)if(!v[j]&amp;&amp;cnt[j]&gt;max)max=cnt[j],t=j;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  v[t]=true;tr(e,E[t])cnt[*e]++;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ord.pb(t);<br \/>&nbsp;&nbsp;&nbsp;  }<br \/>&nbsp;&nbsp;&nbsp;  c[ord[0]]=1;<br \/>&nbsp;&nbsp;&nbsp;  for(int id=1;id&lt;=n-1;id++)<br \/>&nbsp;&nbsp;&nbsp;  {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  int t=ord[id];<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  tr(e,E[t])hash]=id;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  rep(i,n)if(hash[i+1]!=id){c[t]=i+1;break;}<br \/>&nbsp;&nbsp;&nbsp;  }<br \/>&nbsp;&nbsp;&nbsp;  int ans=0;rep(i,n)ans&gt;?=c[i];<br \/>&nbsp;&nbsp;&nbsp;  printf(&quot;%dn&quot;,ans);<br \/>}<\/p>\n<p>34 51 21 42 42 33 4 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[HNOI2008]\u795e\u5947\u7684\u56fd\u5ea6 Time Limit:20000MS Memory Limit:165536KTotal Submit:150 Accepted:41 Case Time Limit:5000MS Description K\u56fd\u662f\u4e00\u4e2a\u70ed\u8877\u4e09\u89d2\u5f62\u7684\u56fd\u5ea6,\u8fde\u4eba\u7684\u4ea4\u5f80\u4e5f\u53ea\u559c\u6b22\u4e09\u89d2\u539f\u5219.\u4ed6\u4eec\u8ba4\u4e3a\u4e09\u89d2\u5173\u7cfb:\u5373AB\u76f8\u4e92\u8ba4\u8bc6,BC\u76f8\u4e92\u8ba4\u8bc6,CA\u76f8\u4e92\u8ba4\u8bc6,\u662f\u7b80\u6d01\u9ad8\u6548\u7684.\u4e3a\u4e86\u5de9\u56fa\u4e09\u89d2\u5173\u7cfb,K\u56fd\u7981\u6b62\u56db\u8fb9\u5173\u7cfb,\u4e94\u8fb9\u5173\u7cfb\u7b49\u7b49\u7684\u5b58\u5728.\u6240\u8c13N\u8fb9\u5173\u7cfb,\u662f\u6307N\u4e2a\u4eba A1A2&#8230;An\u4e4b\u95f4\u4ec5\u5b58\u5728N\u5bf9\u8ba4\u8bc6\u5173\u7cfb:(A1A2)(A2A3)&#8230;(AnA1),\u800c\u6ca1\u6709\u5176\u5b83\u8ba4\u8bc6\u5173\u7cfb.\u6bd4\u5982\u56db\u8fb9\u5173\u7cfb\u6307ABCD\u56db\u4e2a\u4eba AB,BC,CD,DA\u76f8\u4e92\u8ba4\u8bc6,\u800cAC,BD\u4e0d\u8ba4\u8bc6.\u5168\u6c11\u6bd4\u8d5b\u65f6,\u4e3a\u4e86\u9632\u6b62\u505a\u5f0a\uff0c\u89c4\u5b9a\u4efb\u610f\u4e00\u5bf9\u76f8\u4e92\u8ba4\u8bc6\u7684\u4eba\u4e0d\u5f97\u5728\u4e00\u961f\uff0c\u56fd\u738b\u76f8\u77e5\u9053\uff0c\u6700\u5c11\u53ef\u4ee5\u5206\u591a\u5c11\u652f\u961f\u3002 Input \u7b2c\u4e00\u884c\u4e24\u4e2a\u6574\u6570N\uff0cM\u30021&lt;=N&lt;=10000,1&lt;=M&lt;=1000000.\u8868\u793a\u6709N\u4e2a\u4eba\uff0cM\u5bf9\u8ba4\u8bc6\u5173\u7cfb. \u63a5\u4e0b\u6765M\u884c\u6bcf\u884c\u8f93\u5165\u4e00\u5bf9\u670b\u53cb Output \u8f93\u51fa\u4e00\u4e2a\u6574\u6570\uff0c\u6700\u5c11\u53ef\u4ee5\u5206\u591a\u5c11\u961f Sample Input Sample Output Hint \u4e00\u79cd\u65b9\u6848(1,3)(2)(4) Source \u54ce\u3002\u3002\u603b\u7b97\u5dee\u4e0d\u591a\u505a\u5b8cHNOI2008\u4e86\u3002\u3002\u6211\u771f\u662f\u4e2a\u50bb\u53c9\u554a\u3002\u3002\u8fd9\u9898\u5f53\u65f6\u5c31\u628a\u6211\u9707\u60ca\u4e86\u3002\u3002\u4e00\u70b9\u601d\u8def\u90fd\u6ca1\u6709\u3002\u3002\u6700\u5c0f\u67d3\u8272\u6570\u4e0d\u662fNP\u95ee\u9898\u4e48\uff1f\u540e\u6765\u770b\u4e86AekdyCoin\u795e\u725b\u7684\u9898\u89e3\u624d\u660e\u767d\u8fd9\u662f\u4e2a\u5f26\u56fe\u3002\u3002\u6240\u4ee5\u6709\u4e13\u95e8\u7684\u7b97\u6cd5\u3002\u3002\u795e\u725b\u5df2\u7ecf\u8bf4\u7684\u5f88\u6e05\u695a\u4e86\u3002\u3002Orz\uff01\uff01\uff01\uff01\uff01\uff01\uff01Code\uff1a#include &lt;vector&gt;#include &lt;cstdio&gt;#include &lt;iostream&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)#define pb push_back#define tr(e,x) for(it e=x.begin();e!=x.end();e++)const int maxn=10000+10;using namespace std;typedef vector&lt;int&gt;::iterator it;int n,m,cnt[maxn]={},c[maxn]={},hash[maxn]={};bool v[maxn]={};vector&lt;int&gt; E[maxn],ord;int main(){&nbsp;&nbsp;&nbsp; \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);&nbsp;&nbsp;&nbsp; scanf(&quot;%d%d&quot;,&amp;n,&amp;m);int s,t;&nbsp;&nbsp;&nbsp; while(m&#8211;)scanf(&quot;%d%d&quot;,&amp;s,&amp;t),&#8211;s,&#8211;t,E[s].pb(t),E[t].pb(s);&nbsp;&nbsp;&nbsp; rep(i,n)&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/277"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}