{"id":623,"date":"2013-01-14T07:26:27","date_gmt":"2013-01-13T23:26:27","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=623"},"modified":"2014-09-22T21:47:21","modified_gmt":"2014-09-22T13:47:21","slug":"srm-566","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/srm-566\/","title":{"rendered":"SRM 566"},"content":{"rendered":"<p><!--more--><\/p>\n<h2>DIV 1 Level 1:<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u5e73\u9762\u56fe\u3002\u3002\u6bcf\u4e2a\u70b9\u7684\u4f4d\u7f6e\u5750\u6807\u4e0d\u77e5\u9053\u3002\u3002<br \/>\n\u95ee\u6709\u591a\u5c11\u79cd\u5220\u8fb9\u65b9\u6848\u3002\u3002\u4f7f\u5f97\u56fe\u4e2d\u4e0d\u5b58\u5728\u4ea4\u53c9\u8fb9\u3002\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u6ee1\u8db3\u6761\u4ef6\u7684\u56fe\u53ea\u6709\u4e24\u79cd\u3002\u3002\u5206\u653e\u5c04\u5f62\u548c\u4e09\u89d2\u5f62\u8ba8\u8bba\u3002\u3002<\/p>\n<pre class=\"brush: cpp; notranslate\" collapse=\"true\" firstline=\"1\" highlight=\"\" title=\"fragment\">\r\nconst int N = 50;\r\n\r\nbool G[N][N];\r\nint deg[N];\r\n\r\nclass PenguinSledding {\r\npublic:\r\n\tlong long countDesigns(int n, vector &lt;int&gt; x, vector &lt;int&gt; y) {\r\n\r\n\t\tLL res = 1; int m = SZ(x);\r\n\t\tRST(deg, G); REP(i, m){\r\n\t\t    deg[--x[i]]++, deg[--y[i]]++;\r\n\t\t    G[x[i]][y[i]] = G[y[i]][x[i]] = 1;\r\n\t\t}\r\n\r\n\t\tREP(i, n) res += _1(deg[i]);\r\n\t\tREP_3(i, j, k, n, i, j) if (G[i][j] &amp;&amp; G[j][k] &amp;&amp; G[k][i]) ++res;\r\n\t\tres -= n + m;\r\n\r\n\t\treturn res;\r\n\t}\r\n};\r\n<\/pre>\n<h2>DIV 1 Level 2:<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u4e00\u4e2a\u4f01\u9e45\u5728\u4e00\u4e2a\u5706\u73af\u4e0a\u79fb\u52a8\u3002\u3002\u4f4d\u7f6e\u5750\u6807\u6709 <code>n<\/code> \u4e2a\u3002\u3002\u5f00\u59cb\u5728 <code>0<\/code> \u70b9\uff0c\u6bcf\u4e00\u6b65\u53ef\u4ee5\u9009\u62e9\u987a\u65f6\u9488\u6216\u8005\u9006\u65f6\u9488\u3002\u3002\u7b2c <code>i<\/code> \u7684\u6b65\u957f\u4e3a <code>i<\/code>\u3002\u3002<br \/>\n\u3002\u3002\u95ee <code>m<\/code> \u6b65\u6700\u7ec8\u8fd4\u56de <code>0<\/code> \u7684\u65b9\u6848\u6709\u591a\u5c11\u79cd\u3002\u3002\uff08\u4e24\u79cd\u65b9\u6848\u88ab\u79f0\u4e3a\u662f\u4e0d\u60f3\u540c\u7684\u3002\u3002\u5982\u679c\u4e2d\u95f4\u6709\u4e00\u6b65\u505c\u7559\u7684\u683c\u5b50\u4e0d\u4e00\u6837\u3002\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u7565\u3002\u3002\uff08\u5377\u79ef +\u3000\u5feb\u901f\u5e42\u3002\u3002<br \/>\n<a href=\"http:\/\/paste.ubuntu.com\/1536089\/\">\uff08\u4ee3\u7801\u3002\u3002<\/a><\/p>\n<h2>DIV 1 Level 3:<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u3002\u5706\u4e0a\u5b58\u5728\u4e00\u4e2a n \u4e2a\u70b9\u7684\u5185\u63a5\u6b63\u591a\u8fb9\u5f62\u3002\u3002\u5706\u5185\u5206\u5e03\u7740 m \u4e2a\u4f01\u9e45\u3002\u3002\u6bcf\u4e2a\u4f01\u9e45\u6709\u4e00\u79cd\u989c\u8272\u3002\u3002\u3002<br \/>\n\u3002\u3002\u9009\u62e9\u4e00\u4e9b\u5706\u73af\u4e0a\u7684\u70b9\u3002\u3002\u56f4\u6210\u7684\u591a\u8fb9\u5f62\u79f0\u4e3a\u6805\u680f\u3002\u3002\u4e00\u7ec4\u6805\u680f\u88ab\u79f0\u4e3a\u662f\u5408\u6cd5\u7684\u3002\u3002\u5f53\u4e14\u4ec5\u5f53\uff1a<\/p>\n<ul>\n<li>\u6805\u680f\u4e4b\u95f4\u7981\u6b62\u4ea4\u53c9\u4ee5\u53ca\u5171\u4eab\u67d0\u4e2a\u9876\u70b9\u3002<\/li>\n<li>\u6805\u680f\u5185\u90e8\u81f3\u5c11\u6709\u4e00\u4e2a\u4f01\u9e45\u3002<\/li>\n<li>\u6240\u6709\u4f01\u9e45\u90fd\u5fc5\u987b\u5904\u5728\u4e00\u4e2a\u6805\u680f\u5185\u3002<\/li>\n<li>\u6240\u6709\u540c\u79cd\u989c\u8272\u7684\u4f01\u9e45\u5fc5\u987b\u5904\u4e8e\u540c\u4e00\u4e2a\u6805\u680f\u5185\u3002<\/li>\n<\/ul>\n<p>\u3002\u3002\u8ba1\u6570\u5408\u6cd5\u6805\u680f\u7ec4\u7684\u65b9\u6848\u6570\u3002\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>\u8ba1\u7b97\u51e0\u4f55\u9884\u5904\u7406 + \u7ec4\u5408 DP\u3002\u3002<\/p>\n<p>&#8230;\u989c\u8272\u4fe1\u606f\u7684\u4f5c\u7528\u4ec5\u5728\u4e8e\u5220\u8fb9\u3002\u3002\u5982\u679c\u5bf9\u89d2\u7ebf\u4e24\u4fa7\u5b58\u5728\u76f8\u540c\u989c\u8272\u7684\u4f01\u9e45\u3002\u3002\u90a3\u4e48\u4efb\u4f55\u4e00\u79cd\u65b9\u6848\u4e2d\u90fd\u4e0d\u53ef\u80fd\u4f1a\u6709\u8be5\u8fb9\u51fa\u73b0\u3002\u3002<br \/>\n\u3002\u3002\u3002\u4e4b\u540e\u9884\u5904\u7406\u51fa\u6bcf\u6761\u8fb9\u3002\u3002\u5728\u5176\u9006\u65f6\u9488\u65b9\u5411\u4e0a\u6709\u591a\u5c11\u4e2a\u4f01\u9e45\u3002\uff08\u3002\u8fd9\u4e2a\u4fe1\u606f\u81f3\u5173\u91cd\u8981\u3002\u3002\u56e0\u4e3a\u9700\u8981\u5224\u65ad\u533a\u57df\u4e3a\u300c\u7a7a\u300d\u7684\u60c5\u51b5\u3002\u3002<br \/>\n\u3002\u4e24\u4e2a\u6b65\u9aa4\u90fd\u53ef\u4ee5\u7528\u53c9\u79ef\u8f7b\u677e\u5b8c\u6210\u3002\u3002\uff08\u540c\u65f6\u5728\u8fd9\u4e00\u6b65\u5224\u65ad\u65e0\u89e3\u3002\u3002<\/p>\n<p><a href=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2013\/01\/fencingConcept.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"624\" data-permalink=\"https:\/\/www.shuizilong.com\/house\/archives\/srm-566\/fencingconcept\/\" data-orig-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2013\/01\/fencingConcept.png\" data-orig-size=\"311,311\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"fencingConcept\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2013\/01\/fencingConcept-300x300.png\" data-large-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2013\/01\/fencingConcept.png\" data-id=\"624\"  src=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2013\/01\/fencingConcept.png\" alt=\"fencingConcept\" width=\"311\" height=\"311\" class=\"aligncenter size-full\" \/><\/a><\/p>\n<p>\u3002\u3002\u9996\u5148\u3002\u4ece\u540e\u5f80\u524d\u5212\u5206\u9636\u6bb5\u3002\u3002\u3002\u663e\u7136\u8981\u8ba8\u8bba\u4e24\u79cd\u72b6\u6001:\u3002\u3002<\/p>\n<ul>\n<li>F[s][t]: \u5f53\u524d\u533a\u95f4\u6ee1\u8db3\u9898\u76ee\u8981\u6c42\u7684\u5408\u6cd5\u89e3\u3002<\/li>\n<li>G[s][t]: \u6700\u5916\u5c42\u7684\u591a\u8fb9\u5f62\u6ca1\u6709\u5c01\u4e0a\u3002\u3002\uff08\u51f8\u58f3\u3002\u3002<\/li>\n<\/ul>\n<p>\u3002\u3002\u3002\u4f46\u662f\u8f6c\u79fb\u65b9\u7a0b\u60f3\u4e0d\u6e05\u695a\u3002\uff08\u5f31\u7206\u4e86\u3002\u3002\uff09\u3002\u3002\u4e8e\u662f\u5c31\u53bb\u819c\u62dc\u4e86\u4e00\u4e0b Petr \u7684 Practice Room \u91cc\u7684\u4ee3\u7801\u3002<br \/>\n\u3002\u3002\u4e8e\u662f\u53d1\u73b0\u5c11\u4e86\u4e00\u79cd\u72b6\u6001\u3002\u3002\u3002<\/p>\n<p>\u3002\u3002\u4e4b\u524d\u7684 G \u4e0d\u80fd\u76f4\u63a5\u8f6c\u79fb\u5230 F\u3002\u3002\u56e0\u4e3a\u65e0\u6cd5\u786e\u8ba4\u6700\u5916\u5c42\u7684\u591a\u8fb9\u5f62\uff0c\u7acb\u5373\u88ab\u5c01\u4e0a\u540e\u91cc\u9762\u662f\u5426\u5305\u542b\u4f01\u9e45\u3002\u3002\u3002<br \/>\n\u56e0\u6b64\u5bf9 G \u589e\u52a0\u4e00\u4e2a\u7ef4\u5ea6\u3002\u3002G[0\/1][s][t]\u3002\u3002\u8868\u793a\u5c01\u4e0a\u540e\u662f\u5426\u5408\u6cd5\u3002\u3002<br \/>\n\u3002\uff08\u3002\u3002F, G0, G1 \u5206\u522b\u5bf9\u5e94 Petr \u4ee3\u7801\u91cc\u7684 waysFree, waysInside, waysInsidish\u3002\u3002\uff09<br \/>\n\u3002\u3002\u8f6c\u79fb\u65b9\u7a0b\u662f\u8fd9\u6837\u3002\u3002<\/p>\n<pre>\r\n .. F &lt;- G1 &lt;- G0 &lt;- F ...\r\n<\/pre>\n<p>\u3002\u3002\u5443\u3002\u3002<\/p>\n<pre class=\"brush: cpp; notranslate\" collapse=\"true\" firstline=\"1\" highlight=\"\" title=\"fragment\">\r\n.. .\r\n       RST(F, G); DWN(s, n, 0){\r\n\r\n            F[s][s] = F[s+1][s] = F[s][s+1] = 1;\r\n            G[0][s][s+1] = 1, G[1][s][s+1] = 0;\r\n\r\n            FOR(t, s+2, n){ \/\/  \/\/ A[][] \u8868\u793a\u5bf9\u89d2\u7ebf\u9006\u65f6\u9488\u533a\u57df\u5185\u6709\u591a\u5c11\u4e2a\u4f01\u9e45\u3002\u3002\r\n\r\n                if (A[s][t] == A[s+1][t-1] &amp;&amp; !del[s][t]){\r\n                    INC(G[0][s][t], F[s+1][t-1]);\r\n                }\r\n                FOR(i, s+1, t) if (A[i][t] == A[i+1][t-1] &amp;&amp; !del[i][t]){\r\n                    INC(G[0][s][t], pdt(G[0][s][i], F[i+1][t-1]));\r\n                    INC(G[1][s][t], pdt(G[A[s][t] == A[s][i] + A[i+1][t]][s][i], F[i+1][t-1]));\r\n                }\r\n\r\n                if (A[s][t] == A[s+1][t]){\r\n                    INC(F[s][t], F[s+1][t]);\r\n                }\r\n                FOR_1(i, s+1, t) if (A[s][t] == A[s][i] + A[i+1][t] &amp;&amp; !del[s][i]){\r\n                    INC(F[s][t], pdt(G[1][s][i], F[i+1][t]));\r\n                }\r\n            }\r\n        }\r\n\r\n\treturn F[0][n-1];\r\n.. .\r\n<\/pre>\n<p><a href=\"http:\/\/paste.ubuntu.com\/1540834\/\">\u3002\u3002\u3002\uff08\u5b8c\u6574\u4ee3\u7801\u3002\u3002<\/a><\/p>\n<h3>External link: <\/h3>\n<p><a href=\"http:\/\/www.bilibili.tv\/video\/av442921\/\">http:\/\/www.bilibili.tv\/video\/av442921\/<\/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":[105],"class_list":["post-623","post","type-post","status-publish","format-standard","hentry","category-topcoder","tag--dp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-a3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/623","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=623"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"predecessor-version":[{"id":625,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/623\/revisions\/625"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}