{"id":460,"date":"2008-07-18T20:43:07","date_gmt":"2008-07-18T12:43:07","guid":{"rendered":"http:\/\/blog.axqd.net\/?p=460"},"modified":"2008-07-18T20:43:07","modified_gmt":"2008-07-18T12:43:07","slug":"google-code-jam-2008","status":"publish","type":"post","link":"https:\/\/blog.axqd.net\/?p=460","title":{"rendered":"Google Code Jam 2008"},"content":{"rendered":"<p>\u90ae\u4ef6\u63d0\u793a\u901a\u77e5\uff0c\u5148\u524d\u6ce8\u518c\u7684Google Code Jam\u5f00\u59cb\u4e86\uff0c\u4e8e\u662f\u767b\u8fdb\u53bb\u505a\u505a\u9898\u3002<br \/>\nQualification Round\u603b\u5171\u4e09\u9898\u3002\u5927\u81f4\u770b\u4e86\u4e00\u4e0b\uff0c\u6700\u540e\u4e00\u9898&#8212;&#8216;\u82cd\u8747\u62cd&#8217;\uff0c\u6ca1\u5565\u81ea\u7136\u7684\u601d\u8def\uff0c\u611f\u89c9\u7b97\u8d77\u6765\u6bd4\u8f83\u9ebb\u70e6\uff0c\u4e8e\u662f\u5c31\u9009\u4e86\u5176\u4ed6\u4e24\u9898\u3002\u8fd9\u4e24\u9898\u5012\u90fd\u8fd8\u6709\u6bd4\u8f83\u660e\u663e\u7684\u601d\u8def\u3002<\/p>\n<p>\u5176\u5b9e\uff0c\u4eceGoogle Code Jam\u8bbe\u7f6e\u7684\u65b9\u5f0f\u6765\u770b\uff0cQualification Round\u7684\u9898\u90fd\u4e0d\u96be\uff0c\u4f46\u901a\u8fc7\u5927\u3001\u5c0f\u8f93\u5165\u6570\u636e\u96c6\u6765\u8003\u5bdf\u7a0b\u5e8f\u5458\u5bf9\u4e8e\u5404\u4e2a\u8fb9\u754c\u6761\u4ef6\u7684\u5904\u7406\u3002<\/p>\n<p>\u7b2c\u4e00\u9898\uff0c&#8217;\u62ef\u6551\u5b87\u5b99&#8217;\uff1b<br \/>\n\u7531\u4e8e&#8217;Queries must be processed in the order they&#8217;re received.&#8217;\uff0c\u6240\u4ee5\u7b80\u5355\u7684\u6807\u8bb0\uff0c\u7136\u540e\u627e\u5927\u5757\u5c31\u53ef\u4ee5\u7b97\u51fa\u8f6c\u6362\u6b21\u6570\uff0c\u5982\u679c\u9700\u8981\uff0c\u4e5f\u53ef\u4ee5\u5f97\u51fa\u5176\u4e2d\u4e00\u4e2a\u53ef\u884c\u7684\u8f6c\u6362\u8def\u5f84\u3002\u65f6\u95f4\u590d\u6742\u5ea6O(N)\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\u662f\uff1a<br \/>\n1. Base case\u67e5\u8be2\u4e2a\u6570\u53ef\u80fd\u4e3a0\uff1b<\/p>\n<p>\u6211\u5728\u7b2c\u4e00\u6b21\u8bd5\u9a8cSmall Input\u7684\u65f6\u5019Fail\u6389\uff0c\u662f\u7531\u4e8e\u5fd8\u4e86\u6e05\u7a7a\u6807\u8bb0\u7684\u65f6\u5019\uff0c\u628a\u7f13\u5b58\u7684\u6807\u8bb0\u8ba1\u6570\u4e5f\u4e00\u5e76\u6e050\u3002<br \/>\n\u6539\u6b63\u540e\uff0cSmall\/Large Input\u7ed3\u679c\u5747\u6b63\u786e\u3002<\/p>\n<p>\u90c1\u95f7\u7684\u662f\uff0c\u8fd9\u9898Large Input\u5728\u4e0a\u4f20\u7ed3\u679c\u7684\u65f6\u5019\uff0c\u4e0d\u77e5\u662fFirefox\u7f13\u5b58\u8fd8\u662fGoogle Code Jam\u7cfb\u7edf\u7684\u95ee\u9898\uff0cLarge Output\u4f9d\u7136\u4e3a\u524d\u4e00\u6b21\u4e0a\u4f20\u7684Small Output\u7684\u6587\u4ef6\u3002\u4ee5\u540e\u5927\u5bb6\u4e00\u5b9a\u8981\u6ce8\u610f\u68c0\u67e5\u4e00\u4e0b\u4e0a\u4f20\u7ed3\u679c\u3002<\/p>\n<p>\u7b2c\u4e8c\u9898\uff0c&#8217;\u706b\u8f66\u65f6\u523b\u8868&#8217;\uff1b<br \/>\nA\u3001B\u4e24\u8fb9\u5206\u522b\u6309\u65f6\u95f4\u6392\u5e8f\u540e\uff0c\u5404\u81ea\u987a\u5e8f\u7edf\u8ba1\u4e00\u904d\uff0c\u4e5f\u5f88\u7b80\u5355\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4f9d\u7136\u4e3aO(N)\u3002<\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\u662f\uff1a<br \/>\n1. \u5982\u4f55\u7ec4\u7ec7\u5f55\u5165\u6570\u636e\u3002\u6211\u91c7\u7528\u7684\u662f\u4ee5\u65f6\u95f4\u4e3akey\u7684\u4e24\u4e2a\u54c8\u5e0c\u8868\u3002<br \/>\n2. \u65f6\u95f4\u53ef\u80fd\u91cd\u53e0\u3002\u8fd9\u662f\u6bd4\u8f83\u660e\u663e\u7684\u4e00\u4e2a\u95ee\u9898\u3002\u91cd\u53e0\u7684\u65f6\u95f4\u5728key\u4e0a\u901a\u8fc7+1\u3001-1\u6765\u76f8\u4e92\u62b5\u6d88\u3002\u8fd9\u6837\u5728\u5f55\u5165\u6570\u636e\u7684\u65f6\u5019\uff0c\u5c31\u628a\u91cd\u53e0\u65f6\u95f4\u7684\u95ee\u9898\u89e3\u51b3\u4e86\u3002<br \/>\n3. \u65f6\u95f4\u8d85\u8fc724\u5c0f\u65f6\u7684\u95ee\u9898\u4e5f\u5f88\u660e\u663e\u3002\u4f46\u7531\u4e8e&#8217;All arrivals and departures occur on the same day.&#8217;\uff0c\u6240\u4ee5\u53cd\u800c\u8ba9\u6211\u5ffd\u7565\u4e86\u8fd9\u4e2a\u95ee\u9898\u3002\u4f46\u5176\u5b9e\u8fd9\u4e2a\u95ee\u9898\u4f9d\u7136\u5b58\u5728\u4e8e\u7c7b\u4f3c&#8217;23:52&#8217; + &#8217;20 mins turn around time&#8217;\u7684\u60c5\u51b5\u91cc\u3002\u6211\u540e\u6765\u52a0\u4e0a\u4e86\u5bf9\u8fd9\u79cd\u60c5\u51b5\u7684ignore\u7684\u5904\u7406\u3002<\/p>\n<p>\u603b\u4e4b\uff0c\u5982\u679c\u6709\u5fc3\u60c5\u7684\u8bdd\uff0c\u505a\u505aCode Jam\u7684\u9898\u8fd8\u86ee\u4e0d\u9519\u7684\u3002<\/p>\n<p><a href=\"https:\/\/blog.axqd.net\/wp-content\/uploads\/2008\/07\/saving_the_universetar.gz\">\u4e0b\u8f7dSaving The Universe\u76f8\u5173\u6587\u4ef6<\/a><\/p>\n<p><a href=\"https:\/\/blog.axqd.net\/wp-content\/uploads\/2008\/07\/saving_the_universetar.gz\"><\/a><a href=\"https:\/\/blog.axqd.net\/wp-content\/uploads\/2008\/07\/train_timetabletar.gz\">\u4e0b\u8f7dTrain Timetable\u76f8\u5173\u6587\u4ef6<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u90ae\u4ef6\u63d0\u793a\u901a\u77e5\uff0c\u5148\u524d\u6ce8\u518c\u7684Google Code Jam\u5f00\u59cb\u4e86\uff0c\u4e8e\u662f\u767b\u8fdb\u53bb\u505a\u505a\u9898\u3002 Qualification  &hellip; <a href=\"https:\/\/blog.axqd.net\/?p=460\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cGoogle Code Jam 2008\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-460","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts\/460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=460"}],"version-history":[{"count":0,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=\/wp\/v2\/posts\/460\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.axqd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}