{"id":162,"date":"2012-04-04T13:16:41","date_gmt":"2012-04-04T05:16:41","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=162"},"modified":"2012-04-05T02:18:25","modified_gmt":"2012-04-04T18:18:25","slug":"tco-2012-round-1a","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/tco-2012-round-1a\/","title":{"rendered":"TCO 2012 Round 1A"},"content":{"rendered":"<p><!--more--><\/p>\n<h2>250 EllysJuice: <\/h2>\n<h3>Brief description: <\/h3>\n<p>\u6709\u4e24\u676f\u679c\u6c41\u996e\u6599\uff0c\u6709 n \u4e2a\u4eba\u6b21\uff0c\u6bcf\u4eba\u6bcf\u6b21\u53ef\u4ee5\u559d\u5176\u4e2d\u7684\u4e00\u676f\uff0c\u6bcf\u6b21\u559d\u4e00\u534a\u3002<br \/>\n\u73b0\u5728\u53ea\u77e5\u9053\u4eba\u6b21\u4fe1\u606f\uff0c\u4e0d\u77e5\u9053\u987a\u5e8f\uff0c\u95ee\u6709\u591a\u5c11\u4eba\u6709\u53ef\u80fd\u559d\u7684\u662f\u6700\u591a\u7684\u3002<br \/>\n\uff08n <= 8)\n\n\n<h3>Analysis: <\/h3>\n<p>\u6ce8\u610f\u5230\u5f53\u7b2c\u6709\u4eba\u559d\u4e86 2 \u6b21\u65f6\uff0c\u53ef\u4ee5\u5b89\u6392\u5176\u559d\u7b2c\u4e00\u676f\u7684\u7b2c\u4e00\u53e3\u548c\u7b2c\u4e8c\u676f\u7684\u7b2c\u4e00\u53e3\u3002<br \/>\n\u4e4b\u540e\u5176\u4ed6\u4eba\u65e0\u8bba\u600e\u4e48\u559d\u4e5f\u8d85\u4e0d\u8fc7\u8fd9\u4e2a\u503c\u5373\u53ef\u3002<\/p>\n<h2>500 EllysFractions: <\/h2>\n<h3>Brief description: <\/h3>\n<p>\u95ee\u5206\u5b50\u548c\u5206\u6bcd\u7684\u79ef\u662f\u4e00\u4e2a\u9636\u4e58\u6570\uff08\u4e0d\u8d85\u8fc7 N!\uff09\u7684\u5047\u5206\u6570\u4e00\u5171\u6709\u591a\u5c11\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u6ce8\u610f\u5230\u56e0\u5b50\u7684\u72ec\u7acb\u6027\u5373\u53ef\u3002<\/p>\n<h2>1000 EllysLights: <\/h2>\n<h3>Brief description: <\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u706f\u548c\u4e00\u7ec4\u5f00\u5173\uff0c\u6bcf\u4e2a\u706f\u81f3\u591a\u548c\u4e24\u4e2a\u5f00\u5173\u8054\u7cfb\u3002<br \/>\n\u7ed9\u5b9a\u521d\u59cb\u706f\u7684\u72b6\u6001\uff0c\u95ee\u6700\u5c11\u9700\u8981\u6b21\u5f00\u5173\u64cd\u4f5c\u53ef\u4ee5\u7184\u706d\u6240\u6709\u706f\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u4ea6\u6216\u65b9\u7a0b\u7ec4\uff0c\u6ce8\u610f\u5230\u95ee\u9898\u7684\u7279\u6b8a\u6027\u5927\u6982\u66b4\u641c\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: 250 EllysJuice; toolbar: true; notranslate\" title=\"250 EllysJuice\">\r\n\/* -&amp;$&amp;#*( &amp;#*@)^$@&amp;*)*\/\r\n\r\nconst int MOD = 1000000007;\r\nconst int INF = 0x7fffffff;\r\n\r\nconst int N = 50;\r\n\r\n\r\nclass EllysJuice {\r\npublic:\r\n\tvector &lt;string&gt; getWinners(vector &lt;string&gt; players) {\r\n\r\n\t\tmap&lt;string ,int&gt; Hash; int up = 0;\r\n\r\n\t\tREP(i, SZ(players)) checkMax(up, ++Hash&#x5B;players&#x5B;i]]);\r\n\r\n\t\tvector &lt;string&gt; res;\r\n\r\n\t\tif (up &gt;= 2){\r\n\t\t    for(map&lt;string, int&gt;::iterator it = Hash.begin(); it != Hash.end(); ++it)\r\n\t\t        if (it-&gt;second &gt;= 2) res.PB(it-&gt;first);\r\n\t\t}\r\n\t\telse {\r\n\t\t    if (SZ(Hash) == 1) res.PB(players&#x5B;0]);\r\n\t\t}\r\n\r\n\t\treturn res;\r\n\t}\r\n};\r\n<\/pre>\n<pre class=\"brush: cpp; light: false; title: 500 EllysFractions; toolbar: true; notranslate\" title=\"500 EllysFractions\">\r\n\/* -&amp;$&amp;#*( &amp;#*@)^$@&amp;*)*\/\r\n\r\nconst int MOD = 1000000007;\r\nconst int INF = 0x7fffffff;\r\n\r\nconst int N = 50;\r\n\r\nbool isPrime(int n){\r\n    FOR(i, 2, n) if (n % i == 0) return false;\r\n    return true;\r\n}\r\n\r\n\r\nclass EllysFractions {\r\npublic:\r\n\tlong long getCount(int n) {\r\n        LL res = 0; int cnt = -1;\r\n        FOR(i, 2, n+1) cnt += isPrime(i), res += 1LL &lt;&lt; cnt;\r\n\t\treturn res;\r\n\t}\r\n};\r\n<\/pre>\n<pre class=\"brush: cpp; light: false; title: 1000 EllysLights; toolbar: true; notranslate\" title=\"1000 EllysLights\">\r\n\/* -&amp;$&amp;#*( &amp;#*@)^$@&amp;*)*\/\r\n\r\nconst int MOD = 1000000007;\r\nconst int INF = 999;\r\n\r\nconst int N = 50;\r\n\r\nvector&lt;int&gt; L&#x5B;N]; LL op&#x5B;N], state, forbid;\r\nint n, m, res;\r\n\r\n#define o1 L&#x5B;x]&#x5B;0]\r\n#define o2 L&#x5B;x]&#x5B;1]\r\n\r\nint dfs(int x = 0){\r\n\r\n    if (x == n) return 0;\r\n\r\n    int res = INF;\r\n\r\n    if (SZ(L&#x5B;x]) == 0){\r\n        if (!_1(state, x)) res = dfs(x+1);\r\n    }\r\n    else if (SZ(L&#x5B;x]) == 1){\r\n        if (_1(state, x)){\r\n            state ^= op&#x5B;o1];\r\n            res = dfs(x+1)+1;\r\n            state ^= op&#x5B;o1];\r\n        }\r\n        else {\r\n            res = dfs(x+1);\r\n        }\r\n    }\r\n    else if (SZ(L&#x5B;x]) == 2){\r\n        if (_1(state, x)){\r\n            state ^= op&#x5B;o1];\r\n            res = dfs(x+1)+1;\r\n            state ^= op&#x5B;o1];\r\n            state ^= op&#x5B;o2];\r\n            checkMin(res, dfs(x+1)+1);\r\n            state ^= op&#x5B;o2];\r\n        }\r\n        else {\r\n            res = dfs(x+1);\r\n            state ^= op&#x5B;o1], state ^= op&#x5B;o2];\r\n            checkMin(res, dfs(x+1) + 2);\r\n            state ^= op&#x5B;o1], state ^= op&#x5B;o2];\r\n        }\r\n    }\r\n\r\n    return res;\r\n}\r\n\r\n\r\nclass EllysLights {\r\npublic:\r\n\tint getMinimum(string initial, vector &lt;string&gt; switches) {\r\n\r\n\t    n = SZ(initial), m = SZ(switches);\r\n\r\n\t    REP(i, n) CLR(L&#x5B;i]); RST(op), res = state = forbid = 0;\r\n\r\n\t    REP(i, m) FOR(j, i+1, m) if (switches&#x5B;i] == switches&#x5B;j]){\r\n\t        switches&#x5B;j] = string('N', n);\r\n\t    }\r\n\r\n\t    REP(i, m) REP(j, n){\r\n            if (switches&#x5B;i]&#x5B;j] == 'Y'){\r\n                L&#x5B;j].PB(i), op&#x5B;i] |= _1(j);\r\n            }\r\n\t    }\r\n\r\n        REP(i, n) if (initial&#x5B;i] == 'Y') state |= _1(i);\r\n\r\n        REP(x, n) if (_1(state, x)){\r\n            if (L&#x5B;x].empty()) return -1;\r\n            if (SZ(L&#x5B;x]) == 1) state ^= op&#x5B;o1], forbid |= _1(o1), ++res;\r\n        }\r\n        else {\r\n            if (SZ(L&#x5B;x]) == 1) forbid |= _1(o1);\r\n        }\r\n\r\n        REP(i, n) CLR(L&#x5B;i]);\r\n\r\n\t    REP(i, m) if (!_1(forbid, i)){\r\n            REP(j, n){\r\n                if (switches&#x5B;i]&#x5B;j] == 'Y'){\r\n                    L&#x5B;j].PB(i); break;\r\n                }\r\n            }\r\n\t    }\r\n\r\n        res += dfs(); if (res &gt;= INF) res = -1;\r\n\r\n\t\treturn res;\r\n\t}\r\n};\r\n<\/pre>\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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[17],"tags":[],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-topcoder"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-2C","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/162","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=162"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}