{"id":1366,"date":"2024-02-07T00:01:37","date_gmt":"2024-02-06T16:01:37","guid":{"rendered":"http:\/\/www.forillusion.com\/?p=1366"},"modified":"2025-02-14T11:39:10","modified_gmt":"2025-02-14T03:39:10","slug":"codeforces-round-913-div-3-solution","status":"publish","type":"post","link":"https:\/\/www.forillusion.com\/index.php\/codeforces-round-913-div-3-solution\/","title":{"rendered":"Codeforces Round 913 Div. 3 \u9898\u89e3"},"content":{"rendered":"\n<p><div class=\"has-toc have-toc\"><\/div><\/p>\n\n\n\n<p>\u9898\u76ee\u94fe\u63a5\uff1a<a href=\"https:\/\/codeforces.com\/contest\/1907\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >https:\/\/codeforces.com\/contest\/1907<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A. Rook<\/h2>\n\n\n\n<p>\u96be\u5ea6\uff1a800<\/p>\n\n\n\n<p>\u6839\u636e\u8f93\u5165\uff0c\u5faa\u73af\u8f93\u51fa\u884c\u548c\u5217\u5e76\u8df3\u8fc7\u68cb\u5b50\u6240\u5728\u4f4d\u7f6e\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int t,a;\nchar c;\nint main()\n{\n    \/\/ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n    CI t;\n    while (t--)\n    {\n        scanf(\"\\n%c%d\",&amp;c,&amp;a);\n        F(i,1,8)\n            if (i!=a) CO c&lt;&lt;i L;\n        F(i,97,104)\n            if (i!=c) CO (char)i&lt;&lt;a L;\n    }\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">B. YetnotherrokenKeoard<\/h2>\n\n\n\n<p>\u96be\u5ea6\uff1a1000<\/p>\n\n\n\n<p>\u9047\u5230\u5b57\u7b26b\u65f6\uff0c\u5220\u9664\u5176\u524d\u9762\u79bb\u4ed6\u6700\u8fd1\u7684\u4e00\u4e2a\u5c0f\u5199\u5b57\u6bcd\uff0c\u5982\u679c\u6ca1\u6709\u5c31\u4e0d\u5220\u9664\u3002\u9047\u5230\u5b57\u6bcdB\u65f6\uff0c\u5220\u9664\u5176\u524d\u9762\u79bb\u4ed6\u6700\u8fd1\u7684\u4e00\u4e2a\u5927\u5199\u5b57\u6bcd\uff0c\u5982\u679c\u6ca1\u6709\u5c31\u4e0d\u5220\u9664\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u5feb\u901f\u5b8c\u6210\u6dfb\u52a0\u5b57\u7b26\u548c\u5220\u9664\u5b57\u7b26\u7684\u64cd\u4f5c\uff0c\u53ef\u4ee5\u7ef4\u62a4\u4e24\u4e2a\u6808\uff0c\u5206\u522b\u8868\u793a\u5927\u5199\u5b57\u6bcd\u548c\u5c0f\u5199\u5b57\u6bcd\uff0c\u6808\u4e2d\u5b58\u50a8\u7740\u5b57\u7b26\u7684\u4f4d\u7f6e\u3002\u9700\u8981\u5220\u9664\u5927\u5c0f\u5b57\u6bcd\u65f6\uff0c\u5c31\u5f39\u51fa\u5bf9\u5e94\u7684\u6808\u9876\u5143\u7d20\uff0c\u6700\u540e\u5c06\u4e24\u4e2a\u6808\u5b58\u50a8\u5230\u540c\u4e00\u4e2a\u6570\u7ec4\u7136\u540e\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u6700\u540e\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int t,ans&#91;1000006];\nstring s;\nstack&lt;int&gt; A,a;\nint main()\n{\n    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n    CI t;\n    while (t--)\n    {\n        CI s;\n        F(i,0,s.size()-1)\n        {\n            if (s&#91;i]=='b')\n            {\n                if (!a.empty()) a.pop();\n            } \n            elif (s&#91;i]=='B')\n            {\n                if (!A.empty()) A.pop();\n            }\n            else\n            {\n                if (s&#91;i]&gt;='A'&amp;&amp;s&#91;i]&lt;='Z') A.push(i);\n                else a.push(i);\n            }\n        }\n        \n        clear(ans);\n        int t=0;\n        while (!a.empty())\n        {\n            ans&#91;t++]=a.top();\n            a.pop();\n        }\n        while (!A.empty())\n        {\n            ans&#91;t++]=A.top();\n            A.pop();\n        }\n        sort(ans,ans+t);\n        F(i,0,t-1)\n            CO s&#91;ans&#91;i]];\n        CL\n    }\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">C. Removal of Unattractive Pairs<\/h2>\n\n\n\n<p>\u96be\u5ea6\uff1a1200<\/p>\n\n\n\n<p>\u7528\u6876\u6765\u7edf\u8ba1\u6bcf\u4e2a\u5b57\u6bcd\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u5982\u679c\u6ca1\u6709\u5b57\u6bcd\u8d85\u8fc7\u603b\u6570\u7684\u4e00\u534a\uff0c\u5219\u603b\u4f1a\u88ab\u6d88\u9664\u6389\uff0c\u5982\u679c\u8d85\u8fc7\u4e86\u4e00\u534a\uff0c\u5219\u80af\u5b9a\u6709\u4e00\u90e8\u5206\u8be5\u5b57\u6bcd\u65e0\u6cd5\u88ab\u6d88\u9664\u6389<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"cpp\">int t,n,a&#91;26];\nstring s;\nint main()\n{\n    \/\/ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n    CI t;\n    while (t--)\n    {\n        clear(a);\n        CI n;\n        CI s;\n        F(i,0,n-1)\n            a&#91;s&#91;i]-97]++;\n        \n        int m=0;\n        F(i,0,25)\n            m=max(m,a&#91;i]);\n        CO max(n%2,2*m-n) L;\n    }\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">D. Jumping Through Segments<\/h2>\n\n\n\n<p>\u96be\u5ea6\uff1a1400<\/p>\n\n\n\n<p>\u672c\u9898\u9700\u8981\u7528\u4e8c\u5206\u67e5\u627e\uff0c\u6765\u627e\u5230\u4e00\u4e2a\u6700\u5c0f\u7684k\u3002\u5bf9\u4e8e\u4e8c\u5206\u67e5\u627e\u4e2d\u7684\u68c0\u67e5\u51fd\u6570\uff0c\u53ef\u4ee5\u6c42\u51fa\u4eba\u5728\u5f53\u524dk\u503c\u4e0b\u7684\u79fb\u52a8\u8303\u56f4\u4e0e\u76ee\u6807\u8303\u56f4\u7684\u4ea4\u96c6\uff0c\u4e0b\u4e00\u6b21\u4ee5\u8be5\u4ea4\u96c6\u4e3a\u57fa\u7840\uff0c\u6c42\u51fa\u4eba\u7684\u6700\u5927\u79fb\u52a8\u8303\u56f4\u4e0e\u76ee\u6807\u8303\u56f4\u7684\u4ea4\u96c6\u5e76\u4e0d\u65ad\u8fdb\u884c\u8be5\u6b65\u9aa4\uff0c\u5982\u679c\u5176\u4e2d\u4efb\u610f\u4e00\u6b21\u6c42\u4ea4\u96c6\u65f6\u53d1\u73b0\u5e76\u4e0d\u5b58\u5728\u4ea4\u96c6\uff0c\u5373\u4eba\u65e0\u6cd5\u79fb\u52a8\u5230\u76ee\u6807\u4f4d\u7f6e\uff0c\u5219\u5f53\u524dk\u503c\u65e0\u6cd5\u5f97\u5230\u7b54\u6848\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"cpp\">LL t,n,a&#91;200005],b&#91;200005];\n\nint check(LL k)\n{\n    LL l=0,r=0;\n    F(i,1,n)\n    {\n        l=max(l-k,a&#91;i]);\n        r=min(r+k,b&#91;i]);\n        if (l&gt;r) return 0;\n    }\n    return 1;\n}\n\nint main()\n{\n    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n    CI t;\n    while (t--)\n    {\n        CI n;\n        F(i,1,n)\n            CI a&#91;i]&gt;&gt;b&#91;i];\n        LL l=0,r=1e9;\n        while (l&lt;=r)\n        {\n            LL mid=(l+r)\/2;\n            if (check(mid)) r=mid-1;\n            else l=mid+1;\n        }\n        CO l L;\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u94fe\u63a5\uff1ahttps:\/\/codeforces.com\/contest\/1907 A. Rook \u96be\u5ea6\uff1a800 \u6839\u636e\u8f93\u5165\uff0c\u5faa\u73af\u8f93\u51fa &#8230;<\/p>","protected":false},"author":1,"featured_media":1371,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,35],"tags":[40,12,34,22,39],"class_list":["post-1366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-3","category-35","tag-codeforces","tag-12","tag-34","tag-22","tag-39"],"_links":{"self":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/comments?post=1366"}],"version-history":[{"count":1,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1366\/revisions"}],"predecessor-version":[{"id":1730,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1366\/revisions\/1730"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/media\/1371"}],"wp:attachment":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/media?parent=1366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/categories?post=1366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/tags?post=1366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}