{"id":222,"date":"2012-05-15T01:37:34","date_gmt":"2012-05-14T17:37:34","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=222"},"modified":"2014-10-05T16:36:39","modified_gmt":"2014-10-05T08:36:39","slug":"pku-campus-2012","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/pku-campus-2012\/","title":{"rendered":"PKU Campus 2012"},"content":{"rendered":"<p><a href=\"http:\/\/poj.openjudge.cn\/campus2012\/\">http:\/\/poj.openjudge.cn\/campus2012\/<\/a><\/p>\n<p><!--more--><\/p>\n<h2>Problem A. Hand Evaluation<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u7565\u3002\uff09<\/p>\n<h3>Analysis: <\/h3>\n<p>\u7b7e\u5230\u3002\uff09<\/p>\n<h2>Problem C. Lausanne Capitale Olympique<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u56fe\uff0c\u95ee\u662f\u5426\u4ece\u6e90\u70b9\u51fa\u53d1\uff0c\u5230\u4efb\u610f\u70b9\u7684\u6700\u77ed\u8def\u5f84\u548c\u6b21\u77ed\u8def\u5f84\u7684\u957f\u5ea6\u76f8\u5dee\u4e0d\u8d85\u8fc7 1 \u3002\u3002\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u505a\u4e00\u6b21  <code>bfs()<\/code> \u5bf9\u6240\u6709\u4e0d\u5728\u6700\u77ed\u8def\u5f84\u6811\u4e2d\u7684\u8fb9\uff0c\u5982\u679c\u8fde\u63a5\u4e24\u70b9\u7684\u5c42\u6b21\u4e00\u6837\u5219\u540c\u65f6\u6807\u8bb0\u8fd9\u4e24\u4e2a\u9876\u70b9\u3002\u3002\u5982\u679c\u4e00\u9ad8\u4e00\u4f4e\u5219\u6807\u8bb0\u9ad8\u70b9\u3002\u3002<br \/>\n\u8fd4\u56de\u6807\u8bb0\u7684\u9876\u70b9\u6570\u662f\u5426 == n\u3002<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem C. Lausanne Capitale Olympique; toolbar: true; notranslate\" title=\"Problem C. Lausanne Capitale Olympique\">\r\nconst int N = 10009;\r\n\r\nVI adj&#x5B;N]; MIB used&#x5B;N]; int q&#x5B;N], d&#x5B;N], head, tail;\r\nbool bj&#x5B;N]; int cnt;\r\nint n, m;\r\n\r\n\r\nvoid init(){\r\n    REP(i, n) CLR(adj&#x5B;i]), CLR(used&#x5B;i]);\r\n    int x, y; REP(i, m){\r\n        RD(x, y); --x, --y;\r\n        adj&#x5B;x].PB(y), adj&#x5B;y].PB(x);\r\n    }\r\n}\r\n\r\n\r\n\r\nvoid bfs(){\r\n    RST(d), d&#x5B;0] = 1, q&#x5B;head = 0] = 0, tail = 1;\r\n    \r\n    while (head &lt; tail){\r\n        \r\n        int u = q&#x5B;head++];\r\n        \r\n#define v adj&#x5B;u]&#x5B;i]\r\n        \r\n        REP(i, SZ(adj&#x5B;u])) if (!d&#x5B;v]){\r\n            d&#x5B;v] = d&#x5B;u] + 1, used&#x5B;u]&#x5B;v] = used&#x5B;v]&#x5B;u] = true;\r\n            q&#x5B;tail++] = v;\r\n        }\r\n    }\r\n}\r\n\r\nvoid tick(int x){\r\n    if (!bj&#x5B;x]) bj&#x5B;x] = true, ++cnt;\r\n}\r\n\r\nint check(){\r\n    RST(bj); bj&#x5B;0] = true, cnt = 1;\r\n    \r\n    REP(u, n) REP(i, SZ(adj&#x5B;u])) if (!used&#x5B;u]&#x5B;v]){\r\n        if (d&#x5B;u] == d&#x5B;v]) tick(u), tick(v);\r\n        else tick(d&#x5B;u] &gt; d&#x5B;v] ? u : v);\r\n    }\r\n    \r\n    \r\n    return cnt == n;\r\n}\r\n\r\nint main(){\r\n    while (scanf(&quot;%d %d&quot;, &amp;n, &amp;m) != EOF){\r\n        init(); bfs();\r\n        cout &lt;&lt; check() &lt;&lt; endl;\r\n    }\r\n}\r\n<\/pre>\n<h2>Problem F. Game<\/h2>\n<p>\u3002\u3002\u5148\u5199\u4e2a\u7a0b\u5e8f\u66b4\u529b\u4e00\u4e0b SG \u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: \u66b4\u529bSG_1.cpp; toolbar: true; notranslate\" title=\"\u66b4\u529bSG_1.cpp\">\r\nconst int N = 1024;\r\nint SG&#x5B;N], n;\r\nVI tmp;\r\n\r\nint mex(VI&amp; tmp){\r\n    if (tmp&#x5B;0] != 0) return 0;\r\n    FOR(i, 1, SZ(tmp)) if (tmp&#x5B;i] - tmp&#x5B;i-1] != 1){\r\n        return tmp&#x5B;i-1] + 1;\r\n    }\r\n    return tmp&#x5B;SZ(tmp) - 1] + 1;\r\n}\r\n\r\nint main(){\r\n    \r\n    freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);\r\n    \r\n    n = 1024;\r\n   \r\n    SG&#x5B;0] = 1, SG&#x5B;1] = 0;\r\n\r\n    FOR(i, 2, n){\r\n        CLR(tmp); REP_1(j, i\/2) tmp.PB(SG&#x5B;i - j] ^ SG&#x5B;i - 2 * j]);\r\n        SRT(tmp); tmp.resize(unique(ALL(tmp)) - tmp.begin()); SG&#x5B;i] = mex(tmp);\r\n    }\r\n    \r\n    REP(i, n){\r\n        if (!SG&#x5B;i] &amp;&amp; !SG&#x5B;i+1]) cout &lt;&lt; endl;\r\n        cout &lt;&lt; SG&#x5B;i];\r\n    }\r\n}\r\n<\/pre>\n<p>\u7a0d\u5fae\u6574\u7406\u4e0b\u5f97\u5230\u4ee5\u4e0b\u6570\u636e\u3002\u3002<\/p>\n<pre>\r\n1\r\n0\r\n010\r\n012210\r\n010\r\n012214414412210\r\n010\r\n012210\r\n01\r\n001221441441221771771221771771221441441221\r\n001\r\n001221\r\n001\r\n001221441441221\r\n001\r\n001221\r\n001\r\n001221441441221771771221771771221441441221881881221881881221441441221881881221881881221441441221771771221771771221441441221\r\n001\r\n001221\r\n001\r\n001221441441221\r\n001\r\n001221\r\n001\r\n001221441441221771771221771771221441441221\r\n001\r\n001221\r\n001\r\n001221441441221\r\n001\r\n001221\r\n001\r\n00122144144122177177122177177122144144122188188122188188122144144122188188122188188122144144122177177122177177122144144122111111111112211111111111221441441221111111111122111111111112214414412217717712217717712214414412211111111111221111111111122144144122111111111112211111111111221441441221771771221771771221441441221881881221881881221441441221881881221881881221441441221771771221771771221441441221\r\n<\/pre>\n<p>\u8fd9\u6837\u89c4\u5f8b\u6027\u5c31\u5df2\u7ecf\u663e\u73b0\u4e86\u3002\u3002\u4e2d\u95f4\u7684 Pattern \u7c7b\u4f3c\u67d0\u79cd\u6811\u72b6\u6570\u7ec4\u7684\u4e1c\u897f\u3002\u3002<br \/>\n\u4e2d\u95f4\u53c8\u51fa\u73b0\u4e86 1, 2, 5, 14, 51, 152 \u8fd9\u6837\u7684\u6570\u5217\u3002\u3002\uff08\u5dee\u5206\u4e00\u4e0b\u662f a[n] = 3n &#8211; 1)\u3002\u3002\u3002<br \/>\n\u3002\u3002\u91cd\u65b0\u6574\u7406\u3002\u3002<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Regroup.cpp; toolbar: true; notranslate\" title=\"Regroup.cpp\">\r\nconst int N = 1&lt;&lt;10;\r\nint SG&#x5B;N], n;\r\nVI tmp;\r\n\r\nint mex(VI&amp; tmp){\r\n    if (tmp&#x5B;0] != 0) return 0;\r\n    FOR(i, 1, SZ(tmp)) if (tmp&#x5B;i] - tmp&#x5B;i-1] != 1){\r\n        return tmp&#x5B;i-1] + 1;\r\n    }\r\n    return tmp&#x5B;SZ(tmp) - 1] + 1;\r\n}\r\n\r\nint main(){\r\n    \r\n    freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);\r\n    \r\n    n = N;\r\n    \r\n    \r\n    SG&#x5B;0] = 1, SG&#x5B;1] = 0;\r\n\r\n    FOR(i, 2, n){\r\n        CLR(tmp); REP_1(j, i\/2) tmp.PB(SG&#x5B;i - j] ^ SG&#x5B;i - 2 * j]);\r\n        SRT(tmp); tmp.resize(unique(ALL(tmp)) - tmp.begin()); SG&#x5B;i] = mex(tmp);\r\n    } \r\n    \r\n    \r\n    int cnt = 0; REP(i, n){\r\n        printf(&quot;%c&quot;, (SG&#x5B;i] &lt;= 10 ? '0' : ('A' - 10)) + SG&#x5B;i]);\r\n        if (!SG&#x5B;i]){\r\n            if (++cnt&amp;1) cout &lt;&lt; endl;\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<h2>Problem H. Gugle Seating<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u7ed9\u4e00\u4e2aN*M\u7684\u77e9\u9635\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u4e0a\u53ef\u4ee5\u6709\u7535\u8111(2)\u6216\u8005\u6905\u5b50(1)\u6216\u8005\u7a7a(0)\u3002\u5982\u4e0b\u9762\u7684\u77e9\u9635<\/p>\n<pre>\r\n3 4\r\n2 2 1 2\r\n0 1 2 2\r\n2 2 2 1\r\n<\/pre>\n<p>\u6bcf\u4e2a\u5de5\u7a0b\u5e08\u9700\u8981\u5360\u7528\u4e00\u4e2a\u6905\u5b50 + \u4e24\u4e2a\u548c\u6905\u5b50\u76f8\u90bb\u4e14\u6210\u76f4\u89d2\u5173\u7cfb\u7684\u7535\u8111\u3002\u5982\uff1a<\/p>\n<pre>\r\n1 2\r\n2\r\n<\/pre>\n<p>\u95ee\u6700\u591a\u80fd\u5b89\u6392\u591a\u5c11\u4e2a\u5de5\u7a0b\u5e08\u8fdb\u6765\u3002\u7535\u8111\u53ea\u80fd\u540c\u65f6\u7ed9\u4e00\u4e2a\u4eba\uff0c\u6905\u5b50\u4e5f\u662f\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p><code>S -> (\u5947\u6570\u5217) \u7535\u8111-> \u4eba -> (\u5076\u6570\u5217) \u7535\u8111 -> T<\/code><br \/>\n\u4e2d\u95f4\u6905\u5b50\u62c6\u70b9\u4ee5\u4fdd\u8bc1\u6bcf\u4e2a\u6905\u5b50\u53ea\u4f1a\u88ab\u8ba1\u6570\u4e00\u6b21\u3002<\/p>\n<p><a href=\"https:\/\/gist.github.com\/lychees\/7306034\">https:\/\/gist.github.com\/lychees\/7306034<\/a><\/p>\n<h3>References: <\/h3>\n<p><a href=\"http:\/\/roosephu.github.io\/2013\/04\/07\/TC-575\/\">http:\/\/roosephu.github.io\/2013\/04\/07\/TC-575\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/poj.openjudge.cn\/campus2012\/<\/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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10],"tags":[24],"class_list":["post-222","post","type-post","status-publish","format-standard","hentry","category-algorithm-contest","tag-24"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-3A","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/222","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=222"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":223,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/222\/revisions\/223"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}