{"id":644,"date":"2013-01-23T05:38:30","date_gmt":"2013-01-22T21:38:30","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=644"},"modified":"2013-01-23T06:41:19","modified_gmt":"2013-01-22T22:41:19","slug":"srm-567","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/srm-567\/","title":{"rendered":"SRM 567"},"content":{"rendered":"<p><!--more--><br \/>\n\u3002\u3002\u3002\u3002\u8fd9\u573a\u6211\u7761\u8fc7\u4e86\u3002\u3002 \/$:o~o \uff09\u3002\u3002<br \/>\n\uff08\u3002\u3002\u53e6\u5916\u9898\u76ee\u597d\u50cf\u7565\u6c34\u3002\u3002<\/p>\n<h2>DIV 1 Level 2:<\/h2>\n<h3>Brief description: <\/h3>\n<p>&#8230; n \u4e2a\u5b57\u7b26\u4e32\u3002\u3002\u73a9\u5bb6 1 \u9009\u62e9\u4e00\u4e2a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u4e3b\u4e32\u3002\u3002\u5e76\u4e14\u53ef\u4ee5\u5236\u5b9a\u4e00\u4e2a\u5b57\u7b26\u8868\u7684\u6392\u5217\u987a\u5e8f\u3002\u3002\u518d\u4efb\u610f\u91cd\u6392\u8be5\u5b57\u7b26\u4e32\u3002\u3002<br \/>\n\u3002\u3002\u73a9\u5bb6 2 \u53ef\u4ee5\u4efb\u610f\u91cd\u6392\u5176\u4ed6\u5b57\u7b26\u4e32\u3002\u3002\u95ee\u6709\u591a\u5c11\u5b57\u7b26\u4e32\u4f5c\u4e3a\u4e3b\u4e32\u65f6\u3002\u3002\u73a9\u5bb6 2 \u65e0\u8bba\u600e\u4e48\u91cd\u6392\u5176\u4ed6\u4e32\u3002\u3002\u90fd\u65e0\u6cd5\u5c0f\u4e8e\u4e3b\u4e32\u3002\u3002\uff08\u5b57\u5178\u5e8f\u3002\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u3002\u3002\u663e\u7136\u5bf9\u4e8e\u6bcf\u4e2a\u5b57\u7b26\u4e32\u53ea\u9700\u8981\u4fdd\u5b58\u6bcf\u4e2a\u5b57\u7b26\u51fa\u73b0\u4e86\u591a\u5c11\u6b21\u3002\u3002\u3002\u679a\u4e3e\u6bcf\u4e2a\u5b57\u7b26\u4e32\u3002\u3002\u5224\u65ad\u5176\u662f\u5426\u53ef\u4ee5\u6210\u4e3a\u5148\u624b\u5fc5\u80dc\u4e32\u3002<br \/>\n\u3002\u3002\u3002\u3002\u7b97\u6cd5\u662f\u53cd\u590d\u8fed\u4ee3\u3002\u6bcf\u4e00\u8f6e\u81f3\u5c11\u53bb\u6389\u4e00\u4e2a\u5b57\u7b26\u3002\u6216\u8005\u5ba3\u5224\u5931\u8d25\u3002\u3002\u56e0\u6b64\u590d\u6742\u5ea6 O(n \u00d7 nc)..<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = 59;\r\n\r\nint freq&#x5B;N]&#x5B;26];\r\n\r\nclass StringGame {\r\npublic:\r\n\tvector &lt;int&gt; getWinningStrings(vector &lt;string&gt; s) {\r\n\r\n\t\tint n = SZ(s);\r\n\t\tRST(freq); REP(i, n) REP(j, SZ(s&#x5B;i])) ++freq&#x5B;i]&#x5B;s&#x5B;i]&#x5B;j] - 'a'];\r\n\r\n\t\tVI res; REP(i, n){\r\n            static bool used&#x5B;26]; RST(used);\r\n\t\t    VI rest; REP(j, n) if (i != j) rest.PB(j);\r\n            for (bool flag = true; flag;){\r\n                flag = false; REP(c, 26) if (!used&#x5B;c]){\r\n                    int j; REP_N(j, SZ(rest)) if (freq&#x5B;rest&#x5B;j]]&#x5B;c] &gt; freq&#x5B;i]&#x5B;c]) break;\r\n                    if (j != SZ(rest)) continue;\r\n                    VI next; REP(j, SZ(rest)) if (freq&#x5B;rest&#x5B;j]]&#x5B;c] == freq&#x5B;i]&#x5B;c]) next.PB(rest&#x5B;j]);\r\n                    rest = next, used&#x5B;c] = flag = true;\r\n                }\r\n                if (rest.empty()) res.PB(i), flag = false;\r\n            }\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n};\r\n<\/pre>\n<p><a href=\"http:\/\/paste.ubuntu.com\/1560993\/\">\uff08\u3002\u3002\u5b8c\u6574\u4ee3\u7801\u3001\u3001<\/a><\/p>\n<h2>DIV 1 Level 3:<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a 2 \u7ef4\u683c\u70b9\u3002\u3002\u6309\u7167\u987a\u5e8f\u5728\u4e0a\u9762\u7ed8\u5236 n \u5ea7\u3000\u201c\u5c71\u201d\u3000\u578b\u7684\u56fe\u6848\u3002\u3002\uff08\u6709\u8986\u76d6\u5173\u7cfb\u3002\u3002<br \/>\n\u3002\u3002\u5c71\u578b\u7684\u56fe\u6848\u7531\u5c71\u9876\u7684\u5750\u6807\u552f\u4e00\u786e\u5b9a\u3002\u3002\u3002\u73b0\u5728\u7ed9\u5b9a\u6bcf\u5ea7\u5c71\u7684\u9ad8\u5ea6\u3002\u3002\u4ee5\u53ca\u6bcf\u4e00\u5217\u51fa\u73b0\u8fc7\u54ea\u4e9b\u5c71\u3002<br \/>\n\u3002\u3002\u3002\u8ba1\u6570\u6ee1\u8db3\u8be5\u8981\u6c42\u7684\u5c71\u9876\u5750\u6807\u65b9\u6848\u7684\u603b\u6570\u3002\u3002<br \/>\n\uff08 \u3002\u3002n <= 10\u3002\u3002\u5217\u6570 <= 50 \u3002\u3002\u3002\n\n\n\n<h3>Analysis: <\/h3>\n<p>\u3002\u3002\u3002\u521d\u770b\u9898\u76ee\u975e\u5e38\u4e0d\u5bb9\u6613\u4e0b\u624b\u3002\u3002\u4f46\u662f\u5c71\u7684\u6570\u76ee\u53ea\u6709 10 \u3002\u3002\u800c\u4e14\u8986\u76d6\u5173\u7cfb\u662f\u56fa\u5b9a\u7684\u3001\u3001<br \/>\n\u3002\u4ee5\u524d\u8bbe\u60f3\u8fc7\u5bf9 vector&lt;int&gt; \u8fdb\u884c\u7f16\u7801\u540e\u3002\u3002\u8fdb\u884c\u7684\u8bb0\u5fc6\u5316\u641c\u7d22\u3002\u3002\u867d\u7136\u603b\u662f\u6709\u5176\u4ed6\u6b63\u786e\u89e3\u6cd5\u3002\uff09<br \/>\n\u3002\u3002\u4e0d\u8fc7\u5bf9\u8fd9\u9898\u6765\u8bf4\u5c45\u7136\u5c31\u662f\u8fd9\u4e48\u505a\u7684\u3002\u3002<\/p>\n<p>\u7b97\u6cd5\u5c31\u662f\u4ece\u540e\u5f80\u524d\u3002\u3002\u8fdb\u884c\u66b4\u529b\u8bb0\u5fc6\u5316\u641c\u7d22\u3002\u3002\u5bf9\u6bcf\u4e00\u5c42\u8bb0\u5f55\u5f53\u524d\u7684\u6700\u5927\u9ad8\u5ea6\u3002\u3002<br \/>\n\u3002\u3002\u3002\u7528\u8fd9\u4e2a\u9ad8\u5ea6\u6765\u5224\u65ad\u906e\u76d6\u5173\u7cfb\u3002\u3002\uff08\u6ce8\u610f\u5e38\u6570\u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int P = 3214567;\r\nconst int N = 50;\r\n\r\nmap&lt;ULL, int&gt; F&#x5B;10];\r\nVI h; bool v&#x5B;10]&#x5B;N]; int n, m;\r\n\r\nint f(int k, int h&#x5B;N]){\r\n    if (k &lt; 0) return 1;\r\n    ULL x = 0; REP(i, m) x *= P, x += h&#x5B;i];\r\n\r\n    if (F&#x5B;k].count(x)) return F&#x5B;k]&#x5B;x];\r\n    int &amp;res = F&#x5B;k]&#x5B;x], hh&#x5B;N]; REP(i0, m){\r\n        int i; REP_N(i, m){\r\n            int hi = ::h&#x5B;k] - abs(i-i0);\r\n            if (hi &gt; h&#x5B;i] != v&#x5B;k]&#x5B;i]) break;\r\n            hh&#x5B;i] = max(h&#x5B;i], hi);\r\n        }\r\n        if (i == m) INC(res, f(k-1, hh));\r\n    }\r\n    return res;\r\n}\r\n\r\n\r\nclass Mountains {\r\npublic:\r\n\tint countPlacements(vector &lt;int&gt; h, vector &lt;string&gt; v) {\r\n\t    ::h = h, n = SZ(h), m = SZ(v&#x5B;0]); \/\/REP(i, n) CLR(F&#x5B;i]);\r\n\t    REP_2(i, j, n, m) ::v&#x5B;i]&#x5B;j] = v&#x5B;i]&#x5B;j] == 'X';\r\n\t    int _h&#x5B;N]={}; return f(n-1, _h);\r\n\t}\r\n};\r\n<\/pre>\n<p><a href=\"http:\/\/paste.ubuntu.com\/1560992\/\">\uff08\u3002\u3002\u5b8c\u6574\u4ee3\u7801.\u3002\u3002<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","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":[17],"tags":[],"class_list":["post-644","post","type-post","status-publish","format-standard","hentry","category-topcoder"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-ao","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/644","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=644"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/644\/revisions"}],"predecessor-version":[{"id":645,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/644\/revisions\/645"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}