{"id":2933,"date":"2023-05-29T06:29:48","date_gmt":"2023-05-28T22:29:48","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=2933"},"modified":"2023-05-30T00:09:00","modified_gmt":"2023-05-29T16:09:00","slug":"codeforces-round-875","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-875\/","title":{"rendered":"Codeforces Round #875"},"content":{"rendered":"<p>\u4e45\u8fdd\u5730\u51b2\u4e86\u4e00\u5c40\u3002\u3002\u3002\u65e0\u60ac\u5ff5\u7684\u5dee\u70b9\u7206 0 \u4e86\u3002<\/p>\n<h2>Problem A. Copil Copac Draws Trees<\/h2>\n<p>\u9898\u610f\uff1a\u7ed9\u5b9a\u4e00\u4e2a\u6811\uff0c\u548c\u8fb9\uff0c\u521d\u59cb\u6839\u8282\u70b9\u662f\u70b9\u4eae\u7684\uff0c\u6bcf\u56de\u5408\u4f60\u53ef\u4ee5\u6309\u7167\u8fb9\u5730\u987a\u5e8f\u626b\u4e00\u904d\u6240\u6709\u8fb9\uff0c\u5982\u679c\u5176\u4e2d\u4e00\u4e2a\u70b9\u662f\u70b9\u4eae\u7684\uff0c\u90a3\u4e48\u70b9\u4eae\u53e6\u4e00\u4e2a\u70b9\u3002\u95ee\u591a\u5c11\u56de\u5408\u540e\u6240\u6709\u70b9\u88ab\u70b9\u4eae\u3002<\/p>\n<p>\u5206\u6790\uff1a\u663e\u7136\u4e0d\u8003\u8651\u8fb9\u987a\u5e8f\u7684\u8bdd\uff0c\u5c31\u662f\u6c42\u6811\u7684\u6df1\u5ea6\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u4e5f\u53ef\u4ee5\u770b\u4f5c\u6811 dp\u3002\u3002<br \/>\ndp[i] \u5b58\u4e24\u4e2a\u503c\uff0c\u5206\u522b\u8868\u793a\u6700\u5c11\u88ab\u70b9\u4eae\u6240\u9700\u7684\u56de\u5408\u6570\uff0c\u548c\u88ab\u70b9\u4eae\u65f6\u6240\u7528\u8fb9\u7684\u7f16\u53f7\u3002\u8f6c\u79fb\u7684\u65f6\u5019\u8ba8\u8bba\u4e00\u4e0b\u7f16\u53f7\u5373\u53ef\u3002<\/p>\n<h2>Problem C. Hyperregular Bracket Strings<\/h2>\n<p>\u9898\u610f\uff1a\u95ee\u6709\u591a\u5c11\u957f\u5ea6 n \u7684\u5408\u6cd5\u62ec\u53f7\u5e8f\u5217\uff0c\u6ee1\u8db3\u7ed9\u5b9a\u7684\u6240\u6709\u533a\u95f4\u4e5f\u65f6\u5408\u6cd5\u7684\u62ec\u53f7\u5e8f\u5217\u3002<\/p>\n<p>\u5206\u6790\uff1a\u4e2a\u4eba\u611f\u89c9\u975e\u5e38\u68d2\u7684\u9898\u76ee\u3002\u9996\u5148\u4e0d\u8003\u8651\u533a\u95f4\u7684\u8bdd\u5c31\u662f\u5361\u5854\u5170\u6570 {C_i}\u3002<\/p>\n<p>\u7136\u540e\u8003\u5bdf [1,4] [2,3] \u548c [1,3] [2,4] \u4e24\u79cd\u60c5\u51b5\uff0c\u524d\u8005\u6bd4\u8f83\u5bb9\u6613\u5206\u6790\uff0c[2,3] \u73b0\u5728\u4e00\u5b9a\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u5408\u6cd5\u62ec\u53f7\u5e8f\u5217\uff0c[1]-[4] \u7136\u540e\u4e24\u4e2a\u4f4d\u7f6e\u867d\u7136\u4e0d\u8fde\u7eed\uff0c\u4f46\u662f\u4e5f\u6784\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u5408\u6cd5\u62ec\u53f7\u5e8f\u5217\u3002\u800c\u540e\u8005 [2,3] \u5219\u8981\u6c42 [1] [2,3] [4] \u5206\u522b\u662f\u4e09\u7ec4\u72ec\u7acb\u7684\u5361\u5854\u5170\u5e8f\u5217\uff0c\u56e0\u4e3a\u4e2d\u95f4\u91cd\u5408\u7684\u90e8\u5206\u5bf9\u524d\u7f00\u548c\u7684 delta \u4e00\u5b9a\u662f 0\uff08\u53cd\u8bc1\u6cd5\uff09\u3002<\/p>\n<p>\u8fd9\u6837\u770b\u7684\u8bdd\u6700\u540e\u7ed3\u679c\u4e00\u5b9a\u662f\u82e5\u5e72 {C_i} \u76f8\u4e58\uff0c\u96be\u70b9\u5c31\u662f\u5206\u89e3\u51fa\u8fd9\u4e9b\u72ec\u7acb\u7684\u533a\u95f4\u7684\u6d4b\u5ea6\uff0c\u770b\u8d77\u6765\u7ed3\u6784\u7b80\u5355\uff0c\u5199\u8d77\u6765\u5374\u5e76\u4e0d\u5bb9\u6613\uff0c\u6211\u4eec\u65e0\u6cd5\u50cf\u8868\u8fbe\u5f0f\u89e3\u6790\u90a3\u6837\u7b80\u5355\u7684\u9012\u5f52\u6216\u8005\u7528\u4e00\u4e2a\u6808\uff0c\u8003\u8651\u5230\u8fd8\u6709\u533a\u95f4\u5171\u4eab\u7aef\u70b9\u7684\u60c5\u51b5\u5c31\u66f4\u9ebb\u70e6\u4e86\u3002<\/p>\n<p>\u7136\u540e\u6709\u4e00\u4e2a\u975e\u5e38\u5de7\u5999\u5730\u601d\u8def\u3002\u3002\u3002\u7ed9\u6bcf\u4e2a\u533a\u95f4\u968f\u673a\u5206\u914d\u4e00\u4e2a uint \u6570\uff0c\u7136\u540e\u628a\u524d\u7f00\u548c\u6539\u6210 xor \u524d\u7f00\u548c\uff0c\u7136\u540e\u7528 hash[] \u8bb0\u5f55\u6bcf\u79cd\u533a\u95f4\u96c6\u5408\u5f71\u54cd\u4e0b\u7684\u6d4b\u5ea6\u6570\uff0c\u5c31\u80fd\u8f7b\u6613\u5904\u7406\u4e0d\u8fde\u7eed\u7684\u72b6\u6001\uff0c\u5e76\u533a\u5206\u4e0a\u9762\u8bf4\u5230\u7684\u5d4c\u5957\u548c\u91cd\u53e0\u4e24\u79cd\u60c5\u51b5\u4e86\u3002<\/p>\n<p>\u8fd9\u79cd hash \u7684\u601d\u60f3\u975e\u5e38\u5b9e\u7528\uff0c\u6bd4\u5982\u53bb\u5e74 <a href=\"https:\/\/www.facebook.com\/codingcompetitions\/hacker-cup\/2022\/round-2\/problems\/A2\/\">FHQ R2 \u7684 A \u9898<\/a> \u4e5f\u51fa\u73b0\u8fc7\u7c7b\u4f3c\u7684\u601d\u8def\u3002<\/p>\n<p>\u5177\u4f53\u8bf4\u6765\u5c31\u662f\u5f00\u4e09\u4e2a\u4e1c\u897f\uff1a<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nmap&lt;int, uint64_t&gt; H; \/\/ \u8bb0\u5f55\u6bcf\u4e2a\u533a\u95f4\u7684\u968f\u673a hash \u6620\u5c04\r\nmap&lt;uint64_t, int&gt; cnt; \/\/ \u8bb0\u5f55\u6bcf\u4e2a\u533a\u95f4\u4ea4\u7684\u683c\u5b50\u6570\r\nuint64_t S&#x5B;N]; \/\/ \u8bb0\u5f55\u524d\u7f00\u548c\u5bf9\u5e94\u7684\u533a\u95f4\u4ea4\r\n<\/pre>\n<p>\u5982\u679c\u533a\u95f4\u7a00\u758f\u7684\u8bdd\uff0c\u8fd8\u9700\u8981\u5bf9\u524d\u7f00\u548c\u79bb\u6563\u5316\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n#include &lt;lastweapon\/poly&gt;\r\n#include &lt;bits\/stdc++.h&gt;\r\nusing namespace lastweapon;\r\n\r\nmt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());\r\nuniform_int_distribution&lt;uint64_t&gt; rnd(0, ULLONG_MAX);\r\n\r\nconst int N = int(3e5) + 9;\r\nMint C&#x5B;N]; uint64_t S&#x5B;N];\r\nint n, k;\r\n\r\nMint binom(int n, int m) {\r\n    return fac&#x5B;n] * invFac&#x5B;m] * invFac&#x5B;n-m];\r\n}\r\n\r\nmap&lt;int, uint64_t&gt; H;\r\nmap&lt;uint64_t, int&gt; cnt;\r\nuint64_t h(int x) {\r\n    if (!CTN(H, x)) H&#x5B;x] = rnd(gen);\r\n    return H&#x5B;x];\r\n}\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    FOR(i, 1, N\/2) C&#x5B;i*2] = binom(2*i,  i) - binom(2*i, i+1);\r\n\r\n    Rush {\r\n        RD(n, k);\r\n\r\n        H.clear(), cnt.clear(); fill(S+1, S+n+1, 0);\r\n\r\n        REP(i, k) {\r\n            int a, b; RD(a, b);\r\n            S&#x5B;a] ^= h(i); S&#x5B;b+1] ^= h(i);\r\n        }\r\n\r\n        REP_1(i, n) ++cnt&#x5B;S&#x5B;i] ^= S&#x5B;i-1]];\r\n        Mint z = 1; for (auto it: cnt) z *= C&#x5B;it.se];\r\n\r\n        cout &lt;&lt; z &lt;&lt; endl;\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e45\u8fdd\u5730\u51b2\u4e86\u4e00\u5c40\u3002\u3002\u3002\u65e0\u60ac\u5ff5\u7684\u5dee\u70b9\u7206 0 \u4e86\u3002 Problem A. Copil Copac Draws Trees \u9898\u610f\uff1a\u7ed9\u5b9a\u4e00\u4e2a\u6811\uff0c\u548c\u8fb9\uff0c\u521d\u59cb\u6839\u8282\u70b9\u662f\u70b9\u4eae\u7684\uff0c\u6bcf\u56de\u5408\u4f60\u53ef\u4ee5\u6309\u7167\u8fb9\u5730\u987a\u5e8f\u626b\u4e00\u904d\u6240\u6709\u8fb9\uff0c\u5982\u679c\u5176\u4e2d\u4e00\u4e2a\u70b9\u662f\u70b9\u4eae\u7684\uff0c\u90a3\u4e48\u70b9\u4eae\u53e6\u4e00\u4e2a\u70b9\u3002\u95ee\u591a\u5c11\u56de\u5408\u540e\u6240\u6709\u70b9\u88ab\u70b9\u4eae\u3002 \u5206\u6790\uff1a\u663e\u7136\u4e0d\u8003\u8651\u8fb9\u987a\u5e8f\u7684\u8bdd\uff0c\u5c31\u662f\u6c42\u6811\u7684\u6df1\u5ea6\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u4e5f\u53ef\u4ee5\u770b\u4f5c\u6811 dp\u3002\u3002 dp[i] \u5b58\u4e24\u4e2a\u503c\uff0c\u5206\u522b\u8868\u793a\u6700\u5c11\u88ab\u70b9\u4eae\u6240\u9700\u7684\u56de\u5408\u6570\uff0c\u548c\u88ab\u70b9\u4eae\u65f6\u6240\u7528\u8fb9\u7684\u7f16\u53f7\u3002\u8f6c\u79fb\u7684\u65f6\u5019\u8ba8\u8bba\u4e00\u4e0b\u7f16\u53f7\u5373\u53ef\u3002 Problem C. Hyperregular Bracket Strings \u9898\u610f\uff1a\u95ee\u6709\u591a\u5c11\u957f\u5ea6 n \u7684\u5408\u6cd5\u62ec\u53f7\u5e8f\u5217\uff0c\u6ee1\u8db3\u7ed9\u5b9a\u7684\u6240\u6709\u533a\u95f4\u4e5f\u65f6\u5408\u6cd5\u7684\u62ec\u53f7\u5e8f\u5217\u3002 \u5206\u6790\uff1a\u4e2a\u4eba\u611f\u89c9\u975e\u5e38\u68d2\u7684\u9898\u76ee\u3002\u9996\u5148\u4e0d\u8003\u8651\u533a\u95f4\u7684\u8bdd\u5c31\u662f\u5361\u5854\u5170\u6570 {C_i}\u3002 \u7136\u540e\u8003\u5bdf [1,4] [2,3] \u548c [1,3] [2,4] \u4e24\u79cd\u60c5\u51b5\uff0c\u524d\u8005\u6bd4\u8f83\u5bb9\u6613\u5206\u6790\uff0c[2,3] \u73b0\u5728\u4e00\u5b9a\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u5408\u6cd5\u62ec\u53f7\u5e8f\u5217\uff0c[1]-[4] \u7136\u540e\u4e24\u4e2a\u4f4d\u7f6e\u867d\u7136\u4e0d\u8fde\u7eed\uff0c\u4f46\u662f\u4e5f\u6784\u6210\u4e00\u4e2a\u72ec\u7acb\u7684\u5408\u6cd5\u62ec\u53f7\u5e8f\u5217\u3002\u800c\u540e\u8005 [2,3] \u5219\u8981\u6c42 [1] [2,3] [4] \u5206\u522b\u662f\u4e09\u7ec4\u72ec\u7acb\u7684\u5361\u5854\u5170\u5e8f\u5217\uff0c\u56e0\u4e3a\u4e2d\u95f4\u91cd\u5408\u7684\u90e8\u5206\u5bf9\u524d\u7f00\u548c\u7684 delta \u4e00\u5b9a\u662f 0\uff08\u53cd\u8bc1\u6cd5\uff09\u3002 \u8fd9\u6837\u770b\u7684\u8bdd\u6700\u540e\u7ed3\u679c\u4e00\u5b9a\u662f\u82e5\u5e72 {C_i} \u76f8\u4e58\uff0c\u96be\u70b9\u5c31\u662f\u5206\u89e3\u51fa\u8fd9\u4e9b\u72ec\u7acb\u7684\u533a\u95f4\u7684\u6d4b\u5ea6\uff0c\u770b\u8d77\u6765\u7ed3\u6784\u7b80\u5355\uff0c\u5199\u8d77\u6765\u5374\u5e76\u4e0d\u5bb9\u6613\uff0c\u6211\u4eec\u65e0\u6cd5\u50cf\u8868\u8fbe\u5f0f\u89e3\u6790\u90a3\u6837\u7b80\u5355\u7684\u9012\u5f52\u6216\u8005\u7528\u4e00\u4e2a\u6808\uff0c\u8003\u8651\u5230\u8fd8\u6709\u533a\u95f4\u5171\u4eab\u7aef\u70b9\u7684\u60c5\u51b5\u5c31\u66f4\u9ebb\u70e6\u4e86\u3002 \u7136\u540e\u6709\u4e00\u4e2a\u975e\u5e38\u5de7\u5999\u5730\u601d\u8def\u3002\u3002\u3002\u7ed9\u6bcf\u4e2a\u533a\u95f4\u968f\u673a\u5206\u914d\u4e00\u4e2a uint \u6570\uff0c\u7136\u540e\u628a\u524d\u7f00\u548c\u6539\u6210 xor \u524d\u7f00\u548c\uff0c\u7136\u540e\u7528 hash[] \u8bb0\u5f55\u6bcf\u79cd\u533a\u95f4\u96c6\u5408\u5f71\u54cd\u4e0b\u7684\u6d4b\u5ea6\u6570\uff0c\u5c31\u80fd\u8f7b\u6613\u5904\u7406\u4e0d\u8fde\u7eed\u7684\u72b6\u6001\uff0c\u5e76\u533a\u5206\u4e0a\u9762\u8bf4\u5230\u7684\u5d4c\u5957\u548c\u91cd\u53e0\u4e24\u79cd\u60c5\u51b5\u4e86\u3002 \u8fd9\u79cd hash \u7684\u601d\u60f3\u975e\u5e38\u5b9e\u7528\uff0c\u6bd4\u5982\u53bb\u5e74 [&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-2933","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-Lj","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2933","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=2933"}],"version-history":[{"count":7,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2933\/revisions"}],"predecessor-version":[{"id":2946,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/2933\/revisions\/2946"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=2933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=2933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=2933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}