{"id":2007,"date":"2022-08-17T22:13:45","date_gmt":"2022-08-17T14:13:45","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=2007"},"modified":"2022-08-23T13:33:51","modified_gmt":"2022-08-23T05:33:51","slug":"codeforces-round-814","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-814\/","title":{"rendered":"Codeforces Round #814"},"content":{"rendered":"<h2><span class=\"ez-toc-section\" id=\"%E4%BC%A0%E9%80%81%E9%97%A8\"><\/span>\u4f20\u9001\u95e8<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/codeforces.com\/contest\/1718\">https:\/\/codeforces.com\/contest\/1718<\/a><\/li>\n<li><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/554786501\">https:\/\/zhuanlan.zhihu.com\/p\/554786501<\/a><\/li>\n<\/ul>\n<p>\u611f\u89c9\u6389\u4e86\u8fd1 100 \u5206\u3002QAQ\u3002\u3002<br \/>\n\u9898\u76ee\u8fd8\u662f\u975e\u5e38\u4e0d\u9519\u7684\u3002\u3002\u3002\u7279\u522b\u662f D \u9898~~<\/p>\n<p>\u6bd4\u8d5b\u65f6\u5148\u5f00\u4e86 A2 \u4f46\u662f\u5199\u5f97\u975e\u5e38\u6709\u95ee\u9898\u3002\u3002\u7136\u540e\u5c31\u53ea\u80fd\u5148\u53bb\u5199 A1 \u62ff\u5206\u3002\u3002\u3002\u7ed3\u679c A1 \u8fd8\u5199\u9519\u4e86 1 \u6b21\uff0c\u5e76\u4e14 A2 \u5c31\u4e00\u76f4\u6ca1 debug\u3002\u3002\u3002<br \/>\n\u7136\u540e\u5f00 B \u7ed9\u7684\u8d2a\u5fc3\u4e5f\u5f88\u5931\u8d25\u3002\u3002\u9700\u8981\u7279\u5224\u5f88\u591a\u60c5\u51b5\u3002\u3002\u3002\u6700\u540e\u867d\u7136\u53d1\u73b0\u4e86\u9519\u8bef\u7684 case\u3002\u3002\u3002\u4f46\u662f\u6700\u540e debug \u7684\u65f6\u5019\u5c45\u7136\u5199\u9519\u4e86\u3002\u3002\u5bfc\u81f4\u4e00\u76f4\u4ee5\u4e3a\u662f case \u6ca1\u627e\u5bf9\u3002\u3002\u3002<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e22fd1a2c39\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e22fd1a2c39\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-814\/#%E4%BC%A0%E9%80%81%E9%97%A8\" title=\"\u4f20\u9001\u95e8\">\u4f20\u9001\u95e8<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-814\/#Problem_A_Burenka_and_Traditions\" title=\"Problem A. Burenka and Traditions\">Problem A. Burenka and Traditions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-814\/#Problem_B_Fibonacci_Strings\" title=\"Problem B. Fibonacci Strings\">Problem B. Fibonacci Strings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-814\/#Problem_C_Tonya_and_Burenka-179\" title=\"Problem C. Tonya and Burenka-179\">Problem C. Tonya and Burenka-179<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-814\/#Problem_D_%E2%80%A6\" title=\"Problem D. &#8230;\">Problem D. &#8230;<\/a><\/li><\/ul><\/nav><\/div>\n\n<h2><span class=\"ez-toc-section\" id=\"Problem_A_Burenka_and_Traditions\"><\/span>Problem A. Burenka and Traditions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u9898\u610f\uff1a\u6709\u4e00\u4e2a\u6570\u7ec4a\uff0c\u6bcf\u6b21\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u533a\u95f4 [l,r] \u548c\u4e00\u4e2a\u6574\u6570 x\uff0c\u5c06 al, al+1, &#8230;, ar \u4e2d\u4e0e x \u5f02\u6216\uff0c\u4ee3\u4ef7\u4e3a \\ceil((r-l+1)\/2)<br \/>\n\u95ee\u81f3\u5c11\u9700\u8981\u591a\u5c11\u4ee3\u4ef7\uff0c\u6570\u7ec4\u6240\u6709\u5143\u7d20\u5747\u53d8\u4e3a 0\u3002<\/p>\n<p>A1, n, ai &lt;= 5000.<br \/>\nA2, n &lt;= 1e5, ai &lt;= 1e9,<\/p>\n<p>\u3002\u3002\u6700\u597d\u5c31\u4e0d\u8981\u770b A1\u3002\u3002\u3002\uff08A1 dp \u5199\u5b8c\u6d6a\u8d39\u65f6\u95f4\u4e0d\u8bf4\uff0c\u8fd8\u5bb9\u6613\u6570\u7ec4\u5f00\u5c0f\u5bfc\u81f4\u5199\u9519\u3002\u3002\uff09<br \/>\n\u9996\u5148\u9009\u957f\u5ea6 >= 2 \u7684\u533a\u95f4\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u6211\u4eec\u53ea\u9700\u8981\u7528\u4e00\u4e9b\u957f\u5ea6\u4e3a 1\u30012 \u7684\u533a\u95f4\u62fc\u6210\u8fde\u7eed\u7684\u64cd\u4f5c\u5e8f\u5217\u5373\u53ef\u3002\u3002<br \/>\n\u8003\u5bdf\u4e0b\u9762\u7684\u60c5\u51b5\u3002\u3002\u3002<br \/>\n3<br \/>\n1 2 3<br \/>\n\u663e\u7136\uff0c\u64cd\u4f5c\u5e8f\u5217\u5e94\u8be5\u662f\u3002\u3002\u3002<br \/>\n1 2 3 -> 0 3 3 -> 0 0 0<br \/>\n\u4e5f\u5c31\u662f\u6211\u4eec\u8981\u627e\u5230\u524d\u7f00\u7684 xor \u7b49\u4e8e\u5f53\u524d\u6570\u7684\u60c5\u51b5\u3002<br \/>\n\u8fd9\u4e2a\u53ea\u9700\u8981\u7528\u4e00\u4e2a set \u7ef4\u62a4\uff0c\u53d1\u73b0\u51fa\u73b0\u91cd\u590d\u6570\u5b57\u5c31\u8bf4\u660e\u51fa\u73b0\u4e86\u4e00\u79cd\u4e0a\u8ff0\u7684\u60c5\u51b5\uff0c\u6b64\u65f6\u53ef\u4ee5\u7b54\u6848 -1\uff0c\u5e76\u628a\u5f53\u524d set \u6e05\u7a7a\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Problem_B_Fibonacci_Strings\"><\/span>Problem B. Fibonacci Strings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/oi-wiki.org\/math\/fibonacci\/\">https:\/\/oi-wiki.org\/math\/fibonacci\/<\/a><\/li>\n<\/ul>\n<p>\u6211\u80af\u5b9a\u662f\u5f88\u4e45\u5f88\u4e45\u4ee5\u524d\u5728 cf \u505a\u8fc7\u7c7b\u4f3c\u7684\u9898\uff0c\uff08\u597d\u50cf\u4e5f\u662f B\u3002\u3002\u3002\uff09<br \/>\n\u90a3\u4e48\u65e2\u7136\u53ef\u4ee5\u552f\u4e00\u6590\u6ce2\u90a3\u5951\u5206\u89e3\uff0c\u6240\u4ee5\u7406\u8bba\u4e0a\u5c31\u53ef\u4ee5\u968f\u4fbf\u505a\u4e86\u3002<br \/>\n\u6709\u95ee\u9898\u7684\u662f\u8fd9\u4e2a\u9898\u6709\u4e24\u4e2a 1\uff0c\u53ef\u80fd\u4f1a\u6709\u51b2\u7a81\uff0c\u53ef\u4ee5\u679a\u4e3e\u8fd9\u591a\u51fa\u7684 1 \u5206\u7ed9\u54ea\uff0c\u7136\u540e\u7ee7\u7eed\u786c\u505a\u3002\u3002<br \/>\n\u4f46\u662f\u8fd9\u6837\u975e\u5e38\u4e0d\u4f18\u96c5\uff0c\u597d\u7684\u8d2a\u5fc3\u8bbe\u8ba1\u662f\u4e0d\u9700\u8981\u7279\u5224\u7684\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Problem_C_Tonya_and_Burenka-179\"><\/span>Problem C. Tonya and Burenka-179<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u5148\u4e0d\u8003\u8651\u4fee\u6539\u3002<br \/>\n\u90a3\u4e48\u6211\u4eec\u9996\u5148\u8003\u8651 n \u662f\u7d20\u6570\u7684\u60c5\u51b5\uff0c\u90a3\u4e48\u663e\u7136\u65e0\u8bba (s,k) \u600e\u4e48\u9009\uff0cf(s, k) \u90fd\u662f\u4e00\u6837\u7684\uff0c\u5e8f\u5217\u7684\u548c\u3002<br \/>\n\u5f53 n \u4e0d\u662f\u7d20\u6570\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u6839\u636e\u6bcf\u4e2a n \u7684\u56e0\u5b50 d\uff0c\u5206\u6210\u4e00\u4e9b\u957f\u5ea6\u4e3a n\/d, \u95f4\u9694\u4e3a d\uff0c\u6bcf\u4e2a\u4f4d\u7f6e\u6839\u636e %d \u7684\u7ed3\u679c\u8fdb\u884c\u5206\u7c7b\uff0c\u6bcf\u7c7b\u6c42\u548c\u5e76\u4e58\u4ee5 d \u5c31\u662f f(s, k) \u7684\u503c\u3002<br \/>\n\u90a3\u4e48\u4e00\u4e2a\u91cd\u8981\u7684\u7ed3\u8bba\u5c31\u662f\u5bf9\u4e8e d1 | d2\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8003\u5bdf d1 \u5373\u53ef\uff0c\u56e0\u4e3a d1 \u6240\u5f20\u6210\u7684\u96c6\u5408\u662f d2 \u7684\u771f\u5b50\u96c6\uff0c\u4e14\u4e00\u5b9a\u5b58\u5728\u4e00\u4e2a\u5747\u503c\u66f4\u9ad8\u7684\u5b50\u96c6\uff0c\u5176\u6240\u5bf9\u5e94\u7684 f(s, k) \u7684\u503c\u4e5f\u66f4\u9ad8\u3002<\/p>\n<p>\u56e0\u6b64\u53ea\u9700\u8981\u56e0\u5b50\u5206\u89e3 n\uff0c\u9884\u5904\u7406\u51fa\u6240\u6709\u4e0d\u540c\u7684 f(s, k) \u5373\u53ef\u3002\u3002\u3002<br \/>\n\u6700\u540e\u8003\u8651\u4fee\u6539\uff0c\u663e\u7136\u9700\u8981\u641e\u4e2a\u6570\u636e\u7ed3\u6784\u7ef4\u62a4\u6700\u503c\u3002\u3002\u3002<br \/>\n\u8fd9\u91cc\u53ea\u6709\u5355\u70b9\u4fee\u6539\uff0c\u6240\u4ee5\u5f00\u4e24\u4e2a\u5806\u7ef4\u62a4\u5373\u53ef\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n#include&lt;lastweapon\/io&gt;\r\nusing namespace lastweapon;\r\n\r\nconst int PMAX = 31623;\r\nVI P; bitset&lt;PMAX&gt; isC;\r\n#define ii (i*P&#x5B;j])\r\nvoid sieve(){\r\n    FOR(i, 2, PMAX){\r\n        if (!isC&#x5B;i]) P.PB(i);\r\n        for (int j=0;j&lt;SZ(P)&amp;&amp;ii&lt;PMAX;++j){\r\n            isC&#x5B;ii]=1; if (!(i%P&#x5B;j])) break;\r\n        }\r\n    }\r\n}\r\n#undef ii\r\n\r\nconst int N = int(2e5) + 9;\r\nint a&#x5B;N], n, q;\r\n\r\nvoid solve() {\r\n    RD(n, q); REP(i, n) RD(a&#x5B;i]);\r\n\r\n    VI fac; int x = n; REP(i, SZ(P)) {\r\n        int p = P&#x5B;i]; if (p*p &gt; x) break;\r\n        if (x % p) continue;\r\n        x \/= p; while (x % p == 0) x \/= p;\r\n        fac.PB(n\/p);\r\n    }\r\n    if (x != 1) fac.PB(n\/x);\r\n\r\n    vector&lt;vector&lt;LL&gt;&gt; s(SZ(fac));\r\n    priority_queue&lt;LL&gt; Q, D;\r\n\r\n    REP(i, SZ(fac)) {\r\n        int p = fac&#x5B;i]; s&#x5B;i].resize(p);\r\n        REP(j, n) s&#x5B;i]&#x5B;j%p] += a&#x5B;j];\r\n        REP(j, p) Q.push(s&#x5B;i]&#x5B;j] * p);\r\n    }\r\n\r\n    auto modify = &#x5B;&amp;](int x, int d) {\r\n        REP(i, SZ(fac)) {\r\n            int p = fac&#x5B;i], j = x % p;\r\n            D.push(s&#x5B;i]&#x5B;j] * p); s&#x5B;i]&#x5B;j] += d;\r\n            Q.push(s&#x5B;i]&#x5B;j] * p);\r\n        }\r\n        while (!D.empty() &amp;&amp; D.top() == Q.top()) {\r\n            D.pop(), Q.pop();\r\n        }\r\n    };\r\n\r\n    printf(&quot;%lld\\n&quot;, Q.top()); DO(q) {\r\n        int p, v; RD(p, v); --p;\r\n        modify(p, v-a&#x5B;p]); a&#x5B;p] = v;\r\n        printf(&quot;%lld\\n&quot;, Q.top());\r\n    }\r\n}\r\n\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n    sieve(); Rush solve();\r\n}\r\n<\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Problem_D_%E2%80%A6\"><\/span>Problem D. &#8230;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/t.me\/algorithm_daily_of_minako\/6067\">https:\/\/t.me\/algorithm_daily_of_minako\/6067<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4f20\u9001\u95e8 https:\/\/codeforces.com\/contest\/1718 https:\/\/zhuanlan.zhihu.com\/p\/554786501 \u611f\u89c9\u6389\u4e86\u8fd1 100 \u5206\u3002QAQ\u3002\u3002 \u9898\u76ee\u8fd8\u662f\u975e\u5e38\u4e0d\u9519\u7684\u3002\u3002\u3002\u7279\u522b\u662f D \u9898~~ \u6bd4\u8d5b\u65f6\u5148\u5f00\u4e86 A2 \u4f46\u662f\u5199\u5f97\u975e\u5e38\u6709\u95ee\u9898\u3002\u3002\u7136\u540e\u5c31\u53ea\u80fd\u5148\u53bb\u5199 A1 \u62ff\u5206\u3002\u3002\u3002\u7ed3\u679c A1 \u8fd8\u5199\u9519\u4e86 1 \u6b21\uff0c\u5e76\u4e14 A2 \u5c31\u4e00\u76f4\u6ca1 debug\u3002\u3002\u3002 \u7136\u540e\u5f00 B \u7ed9\u7684\u8d2a\u5fc3\u4e5f\u5f88\u5931\u8d25\u3002\u3002\u9700\u8981\u7279\u5224\u5f88\u591a\u60c5\u51b5\u3002\u3002\u3002\u6700\u540e\u867d\u7136\u53d1\u73b0\u4e86\u9519\u8bef\u7684 case\u3002\u3002\u3002\u4f46\u662f\u6700\u540e debug \u7684\u65f6\u5019\u5c45\u7136\u5199\u9519\u4e86\u3002\u3002\u5bfc\u81f4\u4e00\u76f4\u4ee5\u4e3a\u662f case \u6ca1\u627e\u5bf9\u3002\u3002\u3002 Problem A. Burenka and Traditions \u9898\u610f\uff1a\u6709\u4e00\u4e2a\u6570\u7ec4a\uff0c\u6bcf\u6b21\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u533a\u95f4 [l,r] \u548c\u4e00\u4e2a\u6574\u6570 x\uff0c\u5c06 al, al+1, &#8230;, ar \u4e2d\u4e0e x \u5f02\u6216\uff0c\u4ee3\u4ef7\u4e3a \\ceil((r-l+1)\/2) \u95ee\u81f3\u5c11\u9700\u8981\u591a\u5c11\u4ee3\u4ef7\uff0c\u6570\u7ec4\u6240\u6709\u5143\u7d20\u5747\u53d8\u4e3a 0\u3002 A1, n, ai &lt;= 5000. A2, n [&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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-2007","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-wn","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2007","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=2007"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2007\/revisions"}],"predecessor-version":[{"id":2008,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2007\/revisions\/2008"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=2007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=2007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=2007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}