{"id":643,"date":"2020-03-02T23:05:20","date_gmt":"2020-03-02T15:05:20","guid":{"rendered":"http:\/\/kylelv.com\/?p=643"},"modified":"2020-03-10T00:03:12","modified_gmt":"2020-03-09T16:03:12","slug":"%e9%ad%94%e5%85%bd%e4%b8%96%e7%95%8c%e4%b9%8b%e4%b8%80%ef%bc%9a%e5%a4%87%e6%88%98-%e7%b1%bb%e5%92%8c%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=643","title":{"rendered":"\u9b54\u517d\u4e16\u754c\u4e4b\u4e00\uff1a\u5907\u6218 &#8212; \u7c7b\u548c\u5bf9\u8c61"},"content":{"rendered":"\n<h2 class=\"has-text-align-center wp-block-heading\">\u9b54\u517d\u4e16\u754c\u4e4b\u4e00\uff1a\u5907\u6218<\/h2>\n\n\n\n<p class=\"has-text-align-center\">\u603b\u65f6\u95f4\u9650\u5236:\u00a01000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB<\/p>\n\n\n\n<p class=\"has-text-align-left\">\u63cf\u8ff0<\/p>\n\n\n\n<p>\u9b54\u517d\u4e16\u754c\u7684\u897f\u9762\u662f\u7ea2\u9b54\u519b\u7684\u53f8\u4ee4\u90e8\uff0c\u4e1c\u9762\u662f\u84dd\u9b54\u519b\u7684\u53f8\u4ee4\u90e8\u3002\u4e24\u4e2a\u53f8\u4ee4\u90e8\u4e4b\u95f4\u662f\u4f9d\u6b21\u6392\u5217\u7684\u82e5\u5e72\u57ce\u5e02\u3002<br>\u7ea2\u53f8\u4ee4\u90e8\uff0cCity 1\uff0cCity 2\uff0c\u2026\u2026\uff0cCity n\uff0c\u84dd\u53f8\u4ee4\u90e8<br><br>\u4e24\u519b\u7684\u53f8\u4ee4\u90e8\u90fd\u4f1a\u5236\u9020\u6b66\u58eb\u3002\u6b66\u58eb\u4e00\u5171\u6709 dragon \u3001ninja\u3001iceman\u3001lion\u3001wolf \u4e94\u79cd\u3002\u6bcf\u79cd\u6b66\u58eb\u90fd\u6709\u7f16\u53f7\u3001\u751f\u547d\u503c\u3001\u653b\u51fb\u529b\u8fd9\u4e09\u79cd\u5c5e\u6027\u3002<br><br>\u53cc\u65b9\u7684\u6b66\u58eb\u7f16\u53f7\u90fd\u662f\u4ece1\u5f00\u59cb\u8ba1\u7b97\u3002\u7ea2\u65b9\u5236\u9020\u51fa\u6765\u7684\u7b2cn\u4e2a\u6b66\u58eb\uff0c\u7f16\u53f7\u5c31\u662fn\u3002\u540c\u6837\uff0c\u84dd\u65b9\u5236\u9020\u51fa\u6765\u7684\u7b2cn\u4e2a\u6b66\u58eb\uff0c\u7f16\u53f7\u4e5f\u662fn\u3002<br><br>\u6b66\u58eb\u5728\u521a\u964d\u751f\u7684\u65f6\u5019\u6709\u4e00\u4e2a\u751f\u547d\u503c\u3002<br><br>\u5728\u6bcf\u4e2a\u6574\u70b9\uff0c\u53cc\u65b9\u7684\u53f8\u4ee4\u90e8\u4e2d\u5404\u6709\u4e00\u4e2a\u6b66\u58eb\u964d\u751f\u3002<br><br>\u7ea2\u65b9\u53f8\u4ee4\u90e8\u6309\u7167iceman\u3001lion\u3001wolf\u3001ninja\u3001dragon\u7684\u987a\u5e8f\u5faa\u73af\u5236\u9020\u6b66\u58eb\u3002<br><br>\u84dd\u65b9\u53f8\u4ee4\u90e8\u6309\u7167lion\u3001dragon\u3001ninja\u3001iceman\u3001wolf\u7684\u987a\u5e8f\u5faa\u73af\u5236\u9020\u6b66\u58eb\u3002<br><br>\u5236\u9020\u6b66\u58eb\u9700\u8981\u751f\u547d\u5143\u3002<br><br>\u5236\u9020\u4e00\u4e2a\u521d\u59cb\u751f\u547d\u503c\u4e3am\u7684\u6b66\u58eb\uff0c\u53f8\u4ee4\u90e8\u4e2d\u7684\u751f\u547d\u5143\u5c31\u8981\u51cf\u5c11m\u4e2a\u3002<br><br>\u5982\u679c\u53f8\u4ee4\u90e8\u4e2d\u7684\u751f\u547d\u5143\u4e0d\u8db3\u4ee5\u5236\u9020\u67d0\u4e2a\u6309\u987a\u5e8f\u5e94\u8be5\u5236\u9020\u7684\u6b66\u58eb\uff0c\u90a3\u4e48\u53f8\u4ee4\u90e8\u5c31\u8bd5\u56fe\u5236\u9020\u4e0b\u4e00\u4e2a\u3002\u5982\u679c\u6240\u6709\u6b66\u58eb\u90fd\u4e0d\u80fd\u5236\u9020\u4e86\uff0c\u5219\u53f8\u4ee4\u90e8\u505c\u6b62\u5236\u9020\u6b66\u58eb\u3002<br><br>\u7ed9\u5b9a\u4e00\u4e2a\u65f6\u95f4\uff0c\u548c\u53cc\u65b9\u53f8\u4ee4\u90e8\u7684\u521d\u59cb\u751f\u547d\u5143\u6570\u76ee\uff0c\u8981\u6c42\u4f60\u5c06\u4ece0\u70b90\u5206\u5f00\u59cb\u5230\u53cc\u65b9\u53f8\u4ee4\u90e8\u505c\u6b62\u5236\u9020\u6b66\u58eb\u4e3a\u6b62\u7684\u6240\u6709\u4e8b\u4ef6\u6309\u987a\u5e8f\u8f93\u51fa\u3002<br>\u4e00\u5171\u6709\u4e24\u79cd\u4e8b\u4ef6\uff0c\u5176\u5bf9\u5e94\u7684\u8f93\u51fa\u6837\u4f8b\u5982\u4e0b\uff1a<br><br>1) \u6b66\u58eb\u964d\u751f<br>\u8f93\u51fa\u6837\u4f8b\uff1a 004 blue lion 5 born with strength 5,2 lion in red headquarter<br>\u8868\u793a\u57284\u70b9\u6574\uff0c\u7f16\u53f7\u4e3a5\u7684\u84dd\u9b54lion\u6b66\u58eb\u964d\u751f\uff0c\u5b83\u964d\u751f\u65f6\u751f\u547d\u503c\u4e3a5\uff0c\u964d\u751f\u540e\u84dd\u9b54\u53f8\u4ee4\u90e8\u91cc\u5171\u67092\u4e2alion\u6b66\u58eb\u3002\uff08\u4e3a\u7b80\u5355\u8d77\u89c1\uff0c\u4e0d\u8003\u8651\u5355\u8bcd\u7684\u590d\u6570\u5f62\u5f0f\uff09\u6ce8\u610f\uff0c\u6bcf\u5236\u9020\u51fa\u4e00\u4e2a\u65b0\u7684\u6b66\u58eb\uff0c\u90fd\u8981\u8f93\u51fa\u6b64\u65f6\u53f8\u4ee4\u90e8\u91cc\u5171\u6709\u591a\u5c11\u4e2a\u8be5\u79cd\u6b66\u58eb\u3002<br><br>2) \u53f8\u4ee4\u90e8\u505c\u6b62\u5236\u9020\u6b66\u58eb<br>\u8f93\u51fa\u6837\u4f8b\uff1a 010 red headquarter stops making warriors<br>\u8868\u793a\u572810\u70b9\u6574\uff0c\u7ea2\u65b9\u53f8\u4ee4\u90e8\u505c\u6b62\u5236\u9020\u6b66\u58eb<br><br>\u8f93\u51fa\u4e8b\u4ef6\u65f6\uff1a<br><br>\u9996\u5148\u6309\u65f6\u95f4\u987a\u5e8f\u8f93\u51fa\uff1b<br><br>\u540c\u4e00\u65f6\u95f4\u53d1\u751f\u7684\u4e8b\u4ef6\uff0c\u5148\u8f93\u51fa\u7ea2\u53f8\u4ee4\u90e8\u7684\uff0c\u518d\u8f93\u51fa\u84dd\u53f8\u4ee4\u90e8\u7684\u3002<\/p>\n\n\n\n<p>\u8f93\u5165<\/p>\n\n\n\n<p>\u7b2c\u4e00\u884c\u662f\u4e00\u4e2a\u6574\u6570\uff0c\u4ee3\u8868\u6d4b\u8bd5\u6570\u636e\u7ec4\u6570\u3002<br>\u6bcf\u7ec4\u6d4b\u8bd5\u6570\u636e\u5171\u4e24\u884c\u3002<br>\u7b2c\u4e00\u884c\uff1a\u4e00\u4e2a\u6574\u6570M\u3002\u5176\u542b\u4e49\u4e3a\uff0c \u6bcf\u4e2a\u53f8\u4ee4\u90e8\u4e00\u5f00\u59cb\u90fd\u6709M\u4e2a\u751f\u547d\u5143( 1 &lt;= M &lt;= 10000)\u3002<br>\u7b2c\u4e8c\u884c\uff1a\u4e94\u4e2a\u6574\u6570\uff0c\u4f9d\u6b21\u662f dragon \u3001ninja\u3001iceman\u3001lion\u3001wolf \u7684\u521d\u59cb\u751f\u547d\u503c\u3002\u5b83\u4eec\u90fd\u5927\u4e8e0\u5c0f\u4e8e\u7b49\u4e8e10000\u3002<\/p>\n\n\n\n<p>\u8f93\u51fa<\/p>\n\n\n\n<p>\u5bf9\u6bcf\u7ec4\u6d4b\u8bd5\u6570\u636e\uff0c\u8981\u6c42\u8f93\u51fa\u4ece0\u65f60\u5206\u5f00\u59cb\uff0c\u5230\u53cc\u65b9\u53f8\u4ee4\u90e8\u90fd\u505c\u6b62\u5236\u9020\u6b66\u58eb\u4e3a\u6b62\u7684\u6240\u6709\u4e8b\u4ef6\u3002<br>\u5bf9\u6bcf\u7ec4\u6d4b\u8bd5\u6570\u636e\uff0c\u9996\u5148\u8f93\u51fa&#8221;Case:n&#8221; n\u662f\u6d4b\u8bd5\u6570\u636e\u7684\u7f16\u53f7\uff0c\u4ece1\u5f00\u59cb \u3002<br>\u63a5\u4e0b\u6765\u6309\u6070\u5f53\u7684\u987a\u5e8f\u548c\u683c\u5f0f\u8f93\u51fa\u6240\u6709\u4e8b\u4ef6\u3002\u6bcf\u4e2a\u4e8b\u4ef6\u90fd\u4ee5\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u95f4\u5f00\u5934\uff0c\u65f6\u95f4\u4ee5\u5c0f\u65f6\u4e3a\u5355\u4f4d\uff0c\u6709\u4e09\u4f4d\u3002<\/p>\n\n\n\n<p>\u6837\u4f8b\u8f93\u5165<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1\n20\n3 4 5 6 7\n<\/pre>\n\n\n\n<p>\u6837\u4f8b\u8f93\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Case:1\n000 red iceman 1 born with strength 5,1 iceman in red headquarter\n000 blue lion 1 born with strength 6,1 lion in blue headquarter\n001 red lion 2 born with strength 6,1 lion in red headquarter\n001 blue dragon 2 born with strength 3,1 dragon in blue headquarter\n002 red wolf 3 born with strength 7,1 wolf in red headquarter\n002 blue ninja 3 born with strength 4,1 ninja in blue headquarter\n003 red headquarter stops making warriors\n003 blue iceman 4 born with strength 5,1 iceman in blue headquarter\n004 blue headquarter stops making warriors<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;map>\n#include&lt;cmath>\n#include&lt;queue>\n#include&lt;cstdio>\n#include&lt;string>\n#include&lt;cstring>\n#include&lt;iostream>\n#include&lt;algorithm>\nusing namespace std;\n#define inf 1000000007\n#define ll long long\n#define N 100010\ninline int rd()\n{\n\tint x=0,f=1;char ch=getchar();\n\twhile(ch&lt;'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n\twhile(ch>='0'&amp;&amp;ch&lt;='9'){x=x*10+ch-'0';ch=getchar();}\n\treturn x*f;\n}\nchar name[5][10]={\"dragon\",\"ninja\",\"iceman\",\"lion\",\"wolf\"};\nint ord[2][5]={{2,3,4,1,0},{3,0,1,2,4}};\nint Case,M,v[10];\nint tim,s[2][10];\nclass qaz\n{\n\tbool avl;\n\tint rem,tp,id,sz[5],tot;\n\tchar nam[5];\n\tpublic:\n\t\tqaz(int M,const char *s,int _id)\n\t\t{\n\t\t\trem=M;avl=1;tot=tp=0;id=_id;\n\t\t\tmemcpy(nam,s,5);\n\t\t\tmemset(sz,0,sizeof(sz));\n\t\t}\n\t\tbool if_avl(){return avl;}\n\t\tvoid ck()\n\t\t{\n\t\t\tfor(int i=0;i&lt;5;i++)\n\t\t\t{\n\t\t\t\tif(v[ord[id][(i+tp)%5]]&lt;=rem)\n\t\t\t\t{\n\t\t\t\t\ttp=(i+tp)%5;sz[tp]++;tot++;\n\t\t\t\t\trem-=v[ord[id][tp]];\n\t\t\t\t\tprintf(\"%03d %s %s %d born with strength %d,\",tim,nam,name[ord[id][tp]],tot,v[ord[id][tp]]);\n\t\t\t\t\tprintf(\"%d %s in %s headquarter\\n\",sz[tp],name[ord[id][tp]],nam);\n\t\t\t\t\ttp++;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tprintf(\"%03d %s headquarter stops making warriors\\n\",tim,nam);\n\t\t\tavl=0;\n\t\t}\n};\nvoid Init()\n{\n\ttim=0;\n}\nvoid work()\n{\n\tqaz A(M,\"red\",0);\n\tqaz B(M,\"blue\",1);\n\twhile(A.if_avl() or B.if_avl())\n\t{\n\t\tif(A.if_avl()) A.ck();\n\t\tif(B.if_avl()) B.ck();\n\t\ttim++;\n\t}\n}\nint main()\n{\n\tCase=rd();\n\tfor(int _c=1;_c&lt;=Case;_c++)\n\t{\n\t\tprintf(\"Case:%d\\n\",_c);\n\t\tM=rd();\n\t\tfor(int i=0;i&lt;5;i++) v[i]=rd();\n\t\tInit();\n\t\twork();\n\t}\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9b54\u517d\u4e16\u754c\u4e4b\u4e00\uff1a\u5907\u6218 \u603b\u65f6\u95f4\u9650\u5236:\u00a01000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB \u63cf\u8ff0 \u9b54\u517d\u4e16\u754c\u7684\u897f\u9762\u662f\u7ea2\u9b54\u519b\u7684\u53f8\u4ee4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-643","post","type-post","status-publish","format-standard","hentry","category-70"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/643","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=643"}],"version-history":[{"count":2,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":665,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/643\/revisions\/665"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}