{"id":921,"date":"2014-06-20T06:19:17","date_gmt":"2014-06-19T22:19:17","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=921"},"modified":"2014-06-20T06:19:17","modified_gmt":"2014-06-19T22:19:17","slug":"srm-625","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/srm-625\/","title":{"rendered":"SRM 625"},"content":{"rendered":"<p><!--more--><\/p>\n<h2>500. BlockTheBlockPuzzle<\/h2>\n<h3>Brief description:<\/h3>\n<p>&#8230; \u7565\uff09<\/p>\n<h3>Analysis:<\/h3>\n<p>\u6bd4\u8f83\u88f8\u7684\u6700\u5c0f\u5272\uff0c\u6ce8\u610f\u62c6\u70b9\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n    int minimumHoles(vector &lt;string&gt; board) {\r\n    \tr = board.size (), c = board&#x5B;0].size (); init();\r\n\r\n    \tREP_2(i, j, r, c) if (board&#x5B;i]&#x5B;j] == 'b'){\r\n    \t    add_edge(s, V(i, j, 1), INF);\r\n    \t    add_edge(V(i, j), V(i, j, 1), INF);\r\n    \t}\r\n    \telse if (board&#x5B;i]&#x5B;j] == '$'){\r\n    \t    t = V(i, j, 1); add_edge(V(i, j), V(i, j, 1), INF);\r\n            board&#x5B;i]&#x5B;j] = 'b';\r\n    \t}\r\n    \telse if (board&#x5B;i]&#x5B;j] == '.'){\r\n            add_edge(V(i, j), V(i, j, 1), 1);\r\n    \t}\r\n\r\n        REP_2(i, j, r, c){\r\n    \t    if (j+3 &lt; c){\r\n                int cc = (board&#x5B;i]&#x5B;j+1] == 'b') || (board&#x5B;i]&#x5B;j+2] == 'b') ? INF : (board&#x5B;i]&#x5B;j+1] == '.') + (board&#x5B;i]&#x5B;j+2] == '.');\r\n                add_edge(V(i, j, 1), V(i, j+3), cc);\r\n                add_edge(V(i, j+3, 1), V(i, j), cc);\r\n    \t    }\r\n    \t    if (i+3 &lt; r){\r\n                int cc = (board&#x5B;i+1]&#x5B;j] == 'b') || (board&#x5B;i+2]&#x5B;j] == 'b') ? INF : (board&#x5B;i+1]&#x5B;j] == '.') + (board&#x5B;i+2]&#x5B;j] == '.');\r\n                add_edge(V(i, j, 1), V(i+3, j), cc);\r\n                add_edge(V(i+3, j, 1), V(i, j), cc);\r\n    \t    }\r\n        }\r\n\r\n    \treturn Dinitz();\r\n    }\r\n<\/pre>\n<h2>900. Seatfriends<\/h2>\n<h3>Brief description:<\/h3>\n<p>\u7565\u3002\uff09<\/p>\n<h3>Analysis:<\/h3>\n<p>\u3002\u3002\u3002dp[i][j] \u8868\u793a i \u4e2a\u4eba\u3001 j \u4e2a cluster \u65f6\u7684\u65b9\u6848\u6570\u3002\u3002\u3002<br \/>\n\u3002\u3002\u4e3b\u8981\u5c31\u662f\u641e\u4e24\u6b21\u3002dp \u65f6\u3002\u4e0d\u8981\u53bb\u5904\u7406 <code>cluster<\/code> \u95f4\u5177\u4f53\u6709\u591a\u5c11\u7a7a\u683c\u7684\u95ee\u9898\u3002\u3002<br \/>\n\u3002\u518d\u5f80\u4e4b\u95f4\u63d2\u5165\u7a7a\u683c\u5c31\u884c\u4e86\u3002\u3002\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = 2009;\r\nInt dp&#x5B;2]&#x5B;N], Binom&#x5B;N]&#x5B;N];\r\n\r\nclass Seatfriends {\r\npublic:\r\n\tint countseatnumb(int n, int m, int g) {\r\n\r\n        REP(i, N){Binom&#x5B;i]&#x5B;0] = 1; REP_1(j, i) Binom&#x5B;i]&#x5B;j] = Binom&#x5B;i-1]&#x5B;j-1] + Binom&#x5B;i-1]&#x5B;j];}\r\n\r\n#define u dp&#x5B;q]&#x5B;j]\r\n#define v dp&#x5B;p]\r\n\r\n        int p = 0, q = 1; RST(dp&#x5B;p]); dp&#x5B;p]&#x5B;1] = n;\r\n\r\n        FOR(i, 1, m){\r\n            swap(p, q); RST(dp&#x5B;p]);\r\n            REP_1(j, g) if (u){\r\n                v&#x5B;j] += u*j*2;\r\n                v&#x5B;j+1] += u*j;\r\n                v&#x5B;j-1] += u*j;\r\n            }\r\n        }\r\n\r\n        if (n == m) return dp&#x5B;p]&#x5B;0];\r\n\t\tInt res = 0; REP_1(i, g) res += dp&#x5B;p]&#x5B;i] * Binom&#x5B;n-m-1]&#x5B;i-1];\r\n\t\treturn res;\r\n\t}\r\n};\r\n<\/pre>\n<h2>External link:<\/h2>\n<p><a href=\"https:\/\/gist.github.com\/lychees\/3829f110b3f9317800ac\">https:\/\/gist.github.com\/lychees\/3829f110b3f9317800ac<\/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":[125],"class_list":["post-921","post","type-post","status-publish","format-standard","hentry","category-topcoder","tag-125"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-eR","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/921","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=921"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/921\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}