{"id":668,"date":"2013-01-29T19:47:06","date_gmt":"2013-01-29T11:47:06","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=668"},"modified":"2013-01-29T19:48:16","modified_gmt":"2013-01-29T11:48:16","slug":"codeforces-round-164","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-164\/","title":{"rendered":"Codeforces Round #164"},"content":{"rendered":"<h2>Problem D. Wall Bars<\/h2>\n<h3>Brief description: <\/h3>\n<p>&#8230; \u3002\u3002\u6784\u9020\u4e00\u4e2a\u5c42\u6570\u4e3a n \u7684\u5854\u3002\u3002\u6bcf\u4e00\u5c42\u5411\u56db\u4e2a\u65b9\u5411\u4e2d\u7684\u4e00\u4e2a\u4f38\u51fa\u4e00\u4e2a\u53f0\u9636\u3002\u3002<br \/>\n\u3002\u4f7f\u5f97\u53ef\u4ee5\u4ece\u5730\u9762\u767b\u4e0a\u5854\u9876\u3002\u3002\u6500\u722c\u7684\u6700\u5927\u8de8\u5ea6\u4e3a h\u3002\u3002\u4e2d\u95f4\u4e0d\u53ef\u4ee5\u6362\u65b9\u5411\u3002<br \/>\n( n <= 1000, h <= 30 \u3002\u3002\u3002\n\n<!--more--><\/p>\n<h3>Analysis: <\/h3>\n<p>\u3002\u3002dp[i][x][y][z][w]\uff1a<br \/>\n\u3002\u3002O(n*h4) \u72b6\u6001\u3002\u3002\u8868\u793a\u5f53\u524d\u7b2c i \u5c42\u3002\u3002\u56db\u4e2a\u65b9\u5411\u7684\u6700\u540e\u4e00\u5757\u6728\u677f\u8ddd\u79bb\u5f53\u524d\u5c42\u7684\u8ddd\u79bb\u5206\u522b\u4e3a x, y, z, w \u65f6\u7684\u65b9\u6848\u6570\u3002\u3002\uff08\u3002\u3002\u5f53\u8ddd\u79bb\u8fbe\u5230 h \u65f6\u3002\u3002\u9ad8\u5ea6\u4e0d\u518d\u589e\u52a0\u3002\u6b64\u65f6\u7684\u95f4\u9699\u5df2\u7ecf\u8fc7\u5927\u3002\u3002\u4e4b\u540e\u4e0d\u53ef\u4ee5\u53c2\u4e0e\u8f6c\u79fb\u3002\u3002<br \/>\n\u3002\u3002dp[i][x][y][z][w]:<br \/>\n\u3002\u3002O(n*h3) \u72b6\u6001\u3002\u3002\u8868\u793a\u5f53\u524d\u7b2c i \u5c42\u3002\u3002\u4e0a\u4e00\u5c42\u662f\u5426\u4ea7\u751f\u4e86\u4e0d\u53ef\u8f6c\u79fb\u7684\u95f4\u9699 w \u3002\u3002\u3002\u4ee5\u53ca\u4e0a\u4e0a\u4e00\u5c42\u3002\u3002\u4e0a\u4e0a\u4e0a \u3002\u7684\u8ddd\u79bb\u5206\u522b\u4e3a\u5206\u522b z, y, x \u65f6\u7684\u65b9\u6848\u6570\u3002\u3002\uff08\u3002\u3002\u8fd9\u6837\u72b6\u6001\u538b\u7f29\u8fc7\u540e\u3002\u3002x,y,w,z \u4fdd\u5b58\u7684\u90fd\u662f\u76f8\u5bf9\u4f4d\u7f6e\u3002\u3002<br \/>\n\u3002\u3002\u8f6c\u79fb\u4f9d\u7136\u662f O(1)\u3002\u3002\u679a\u4e3e\u56db\u4e2a\u65b9\u5411\u3002\u3002\u3002<\/p>\n<p><a href=\"http:\/\/codeforces.com\/contest\/268\/submission\/3032299\">http:\/\/codeforces.com\/contest\/268\/submission\/3032299<\/a><\/p>\n<pre class=\"brush: cpp; first-line: 1; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int H = 30 + 1;\r\nint dp&#x5B;2]&#x5B;H]&#x5B;H]&#x5B;H]&#x5B;2];\r\nint n, h;\r\n\r\nint main(){\r\n\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \/\/freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n\r\n    while (scanf(&quot;%d %d&quot;, &amp;n, &amp;h) != EOF){\r\n        int p = 0, q = 1; int _h = h; ++h; RST(dp&#x5B;p]); dp&#x5B;p]&#x5B;0]&#x5B;0]&#x5B;0]&#x5B;0] = 1;\r\n        REP_1(i, n){\r\n            swap(p, q); RST(dp&#x5B;p]);\r\n#define u dp&#x5B;q]&#x5B;x]&#x5B;y]&#x5B;z]&#x5B;w]\r\n#define t(x) (x==_h?_h:x+1)\r\n#define ww(x) (x==_h)\r\n            REP_4(x,y,z,w,h,h,h,2) if (u){\r\n                int zz = w ? _h : 1;\r\n                INC(dp&#x5B;p]&#x5B;t(x)]&#x5B;t(y)]&#x5B;t(z)]&#x5B;w], u);\r\n                INC(dp&#x5B;p]&#x5B;t(x)]&#x5B;t(y)]&#x5B;zz]&#x5B;ww(z)], u);\r\n                INC(dp&#x5B;p]&#x5B;t(x)]&#x5B;t(z)]&#x5B;zz]&#x5B;ww(y)], u);\r\n                INC(dp&#x5B;p]&#x5B;t(y)]&#x5B;t(z)]&#x5B;zz]&#x5B;ww(x)], u);\r\n            }\r\n        }\r\n\r\n        int res = 0; swap(p, q); REP_4(x,y,z,w,h,h,h,2) if (u){\r\n            if (x&lt;_h||y&lt;_h||z&lt;_h||!w) INC(res, u);\r\n        }\r\n\r\n        OT(res);\r\n    }\r\n}\r\n<\/pre>\n<h3>External link: <\/h3>\n<p><a href=\"http:\/\/codeforces.com\/contest\/268\">http:\/\/codeforces.com\/contest\/268<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem D. Wall Bars Brief description: &#8230; \u3002\u3002\u6784\u9020\u4e00\u4e2a\u5c42\u6570\u4e3a n \u7684\u5854\u3002\u3002\u6bcf\u4e00\u5c42\u5411\u56db\u4e2a\u65b9\u5411\u4e2d\u7684\u4e00\u4e2a\u4f38\u51fa\u4e00\u4e2a\u53f0\u9636\u3002\u3002 \u3002\u4f7f\u5f97\u53ef\u4ee5\u4ece\u5730\u9762\u767b\u4e0a\u5854\u9876\u3002\u3002\u6500\u722c\u7684\u6700\u5927\u8de8\u5ea6\u4e3a h\u3002\u3002\u4e2d\u95f4\u4e0d\u53ef\u4ee5\u6362\u65b9\u5411\u3002 ( n<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[18],"tags":[],"class_list":["post-668","post","type-post","status-publish","format-standard","hentry","category-codeforces"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-aM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=668"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/668\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}