{"id":297,"date":"2012-07-14T03:45:48","date_gmt":"2012-07-13T19:45:48","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=297"},"modified":"2012-08-10T07:04:09","modified_gmt":"2012-08-09T23:04:09","slug":"codeforces-round-129","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-129\/","title":{"rendered":"Codeforces Round #129"},"content":{"rendered":"<h3>Brief description: <\/h3>\n<p>Problem A. Little Elephant and Interval:<br \/>\n\u7edf\u8ba1 [l, r] \u533a\u95f4\u4e2d\uff0c\u9996\u672b\u4f4d\u76f8\u540c\u7684\u6570\u6709\u591a\u5c11\u4e2a\u3002<br \/>\n\u7565\u3002([\u6570\u4f4dDP] \u6216\u8005\u76f4\u63a5\u7b97\uff1f\u3002\u3002<\/p>\n<p>Problem B. Little Elephant and Cards:<br \/>\n\u7565\u3002([Map][\u8d2a\u5fc3]..<\/p>\n<p>Problem C. Little Elephant and Furik and Rubik:<br \/>\n\u7565\uff09[\u7b97\u6570]<\/p>\n<p>Problem D. Little Elephant and Retro Strings:<br \/>\n\u7ed9\u4f60\u4e00\u5b57\u7b26\u4e32\uff0cB \u548c W \u8868\u793a\u767d\u8272\u548c\u9ed1\u8272\u3001\u6709 X \u8868\u793a\u989c\u8272\u4e0d\u786e\u5b9a\u3001\u7ed9\u5b9a\u6574\u6570 K\u3002<br \/>\n\u95ee\u6709\u591a\u5c11\u79cd\u67d3\u8272\u65b9\u6848\u4f7f\u5f97\u5b58\u5728\u4e24\u7ec4\u4e0d\u60f3\u4ea4\u7684\u957f\u5ea6\u4e3a k \u7684\u5b50\u4e32\uff0c\u6ee1\u8db3\u5de6\u4e32\u5168\u90e8\u662f\u767d\u8272\u3001\u53f3\u4e32\u5168\u90e8\u662f\u9ed1\u8272\u3002<br \/>\n..<\/p>\n<p>Problem E. Little Elephant and Strings:<br \/>\n\u7ed9\u5b9a n \u4e2a\u4e32\u7684\u96c6\u5408\uff0c\u518d\u7ed9\u5b9a k\uff0c\u6c42\u6bcf\u4e2a\u4e32\u5206\u522b\u6709\u591a\u5c11\u4e2a\u5b50\u4e32\uff0c\u662f\u96c6\u5408\u4e2d\u81f3\u5c11 k \u4e2a\u4e32\u7684\u5b50\u4e32\u3002<br \/>\n&#8230;<br \/>\n<!--more--><\/p>\n<h3>Analysis: <\/h3>\n<p>Problem A. Little Elephant and Interval:<br \/>\n..<br \/>\nProblem B. Little Elephant and Cards:<br \/>\n..<br \/>\nProblem C. Little Elephant and Furik and Rubik:<br \/>\n..<\/p>\n<p>Problem D. Little Elephant and Retro Strings:<br \/>\n\u6211\u4eec\u7528 F \u548c G \u5206\u522b\u5904\u7406\u5de6\u4e32\u548c\u53f3\u4e32\u3002\u3002\uff08\u65b9\u5411\u76f8\u53cd<br \/>\nF1[i]: \u6070\u597d\u4ee5\u7b2c i \u4f4d\u7ed3\u5c3e\uff0c\u5f62\u6210\u957f\u5ea6\u4e3a k \u7684 {BBBBB..} \u7684\u6570\u76ee\u3002<br \/>\nF2[i]: \u6240\u6709\u4ee5 i \u4f4d\u7ed3\u5c3e\uff0c\u957f\u5ea6 >= k\u7684 {BBBBB..} \u4e32\u7684\u6570\u76ee\u3002\u3002<br \/>\nG1[i]: \u6070\u597d\u4ee5\u7b2c i \u4f4d\u7ed3\u5c3e\uff0c\u5f62\u6210\u957f\u5ea6\u4e3a k \u7684 {WWWWW..} \u7684\u6570\u76ee\u3002<br \/>\nG2[i]: \u6240\u6709\u4ee5 i \u4f4d\u7ed3\u5c3e\uff0c\u957f\u5ea6 >= k\u7684 {WWWWW..} \u4e32\u7684\u6570\u76ee\u3002\u3002<\/p>\n<p>Problem E. Little Elephant and Strings:<br \/>\n&#8230; ?<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem D. Little Elephant and Retro Strings.cpp; toolbar: true; notranslate\" title=\"Problem D. Little Elephant and Retro Strings.cpp\">\r\nconst int N = 1000009;\r\n\r\nint F0&#x5B;N], F1&#x5B;N], G0&#x5B;N], G1&#x5B;N]; char s&#x5B;N];\r\nint L&#x5B;N], R&#x5B;N], n, k, k_, l, r;\r\n\r\nint main(){\r\n\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n\r\n    RD(n, k); RS(s+1); k_ = k + 1;\r\n\r\n\tREP_1(i, n) L&#x5B;i] = L&#x5B;i-1] + (s&#x5B;i]=='X');\r\n\tDWN_1(i, n, 1) R&#x5B;i] = R&#x5B;i+1] + (s&#x5B;i]=='X');\r\n\r\n    l = 0, r = 0; REP_1(i, n){\r\n        if (s&#x5B;i] == 'X' || s&#x5B;i] == 'B') ++r; else l = r = i;\r\n        F1&#x5B;i] = sum(pdt(s&#x5B;i] == 'X' ? 2 : 1, F1&#x5B;i-1]), F0&#x5B;i] = r-l&gt;=k &amp;&amp; s&#x5B;i-k] != 'B' ? dff(pow(2, L&#x5B;i-k_]), F1&#x5B;i-k_]) : 0);\r\n    }\r\n\r\n    l = n+1, r = n+1; DWN_1(i, n, 1){\r\n        if (s&#x5B;i] == 'X' || s&#x5B;i] == 'W') --l; else r = l = i;\r\n        G1&#x5B;i] = sum(pdt(s&#x5B;i] == 'X' ? 2 : 1, G1&#x5B;i+1]), G0&#x5B;i] = r-l&gt;=k &amp;&amp; s&#x5B;i+k] != 'W' ? dff(pow(2, R&#x5B;i+k_]), G1&#x5B;i+k_]) : 0);\r\n    }\r\n\r\n    int res = 0; FOR(i, 1, n) INC(res, pdt(F0&#x5B;i], G1&#x5B;i+1]));\r\n    OT(res);\r\n}\r\n<\/pre>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem E. Little Elephant and Strings.cpp; toolbar: true; notranslate\" title=\"Problem E. Little Elephant and Strings.cpp\">\r\n...\r\n<\/pre>\n<p>&#8230;<\/p>\n<h3>External link: <\/h3>\n<p><a href=\"http:\/\/codeforces.com\/contest\/204\/room\/12\">http:\/\/codeforces.com\/contest\/204\/room\/12<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brief description: Problem A. Little Elephant and Interval: \u7edf\u8ba1 [l, r] \u533a\u95f4\u4e2d\uff0c\u9996\u672b\u4f4d\u76f8\u540c\u7684\u6570\u6709\u591a\u5c11\u4e2a\u3002 \u7565\u3002([\u6570\u4f4dDP] \u6216\u8005\u76f4\u63a5\u7b97\uff1f\u3002\u3002 Problem B. Little Elephant and Cards: \u7565\u3002([Map][\u8d2a\u5fc3].. Problem C. Little Elephant and Furik and Rubik: \u7565\uff09[\u7b97\u6570] Problem D. Little Elephant and Retro Strings: \u7ed9\u4f60\u4e00\u5b57\u7b26\u4e32\uff0cB \u548c W \u8868\u793a\u767d\u8272\u548c\u9ed1\u8272\u3001\u6709 X \u8868\u793a\u989c\u8272\u4e0d\u786e\u5b9a\u3001\u7ed9\u5b9a\u6574\u6570 K\u3002 \u95ee\u6709\u591a\u5c11\u79cd\u67d3\u8272\u65b9\u6848\u4f7f\u5f97\u5b58\u5728\u4e24\u7ec4\u4e0d\u60f3\u4ea4\u7684\u957f\u5ea6\u4e3a k \u7684\u5b50\u4e32\uff0c\u6ee1\u8db3\u5de6\u4e32\u5168\u90e8\u662f\u767d\u8272\u3001\u53f3\u4e32\u5168\u90e8\u662f\u9ed1\u8272\u3002 .. Problem E. Little Elephant and Strings: \u7ed9\u5b9a [&hellip;]<\/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":[18],"tags":[],"class_list":["post-297","post","type-post","status-publish","format-standard","hentry","category-codeforces"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-4N","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/297","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=297"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}