{"id":151,"date":"2026-05-16T11:18:44","date_gmt":"2026-05-16T03:18:44","guid":{"rendered":"https:\/\/huxiaole.cloud\/?p=151"},"modified":"2026-05-20T18:35:49","modified_gmt":"2026-05-20T10:35:49","slug":"codeforces-2185e-the-robotic-rush","status":"publish","type":"post","link":"https:\/\/huxiaole.cloud\/index.php\/2026\/05\/16\/codeforces-2185e-the-robotic-rush\/","title":{"rendered":"CodeForces &#8211; 2185E The Robotic Rush"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709\u4e00\u6761\u65e0\u9650\u957f\u7684\u6570\u8f74\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u8f74\u4e0a\u6709 $n$ \u4e2a\u673a\u5668\u4eba\u548c $m$ \u4e2a\u5c16\u523a\uff0c\u5b83\u4eec\u5206\u522b\u4f4d\u4e8e\u6570\u8f74\u4e0a\u7684\u7279\u5b9a\u70b9\u3002\u7b2c $i$ \u4e2a\u673a\u5668\u4eba\u4f4d\u4e8e\u4f4d\u7f6e $a_i$\uff0c\u7b2c $i$ \u4e2a\u5c16\u523a\u4f4d\u4e8e\u4f4d\u7f6e $b_i$\u3002\u53ea\u8981\u673a\u5668\u4eba\u78b0\u5230\u5c16\u523a\uff0c\u5b83\u5c31\u4f1a\u9635\u4ea1\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5171\u6709 $k$ \u6761\u6307\u4ee4\u4f20\u8fbe\u7ed9\u673a\u5668\u4eba\uff0c\u6bcf\u6761\u6307\u4ee4\u8981\u4e48\u8ba9\u673a\u5668\u4eba\u5411\u5de6\u79fb\u52a8\u4e00\u683c\uff0c\u8981\u4e48\u5411\u53f3\u79fb\u52a8\u4e00\u683c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u6bcf\u4e2a $i$ ($1 \\le i \\le k$)\uff0c\u8bf7\u8f93\u51fa\u5728\u6267\u884c\u5b8c\u524d $i$ \u6761\u6307\u4ee4\u540e\uff0c\u8fd8\u6709\u591a\u5c11\u673a\u5668\u4eba\u5e78\u5b58\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u6574\u6570 $t$ ($1 \\le t \\le 10^4$) \u2014\u2014 \u6d4b\u8bd5\u7528\u4f8b\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u7684\u7b2c\u4e00\u884c\u5305\u542b\u4e09\u4e2a\u6574\u6570 $n, m, k$ ($1 \\le n, m, k \\le 2 \\cdot 10^5$) \u2014\u2014 \u673a\u5668\u4eba\u6570\u91cf\u3001\u5c16\u523a\u6570\u91cf\u548c\u6307\u4ee4\u6570\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u884c\u5305\u542b $n$ \u4e2a\u6574\u6570 $a_1, a_2, \\dots, a_n$ ($0 \\le a_i \\le 10^9$) \u2014\u2014 \u673a\u5668\u4eba\u6240\u5728\u7684\u4f4d\u7f6e\u3002\u4fdd\u8bc1 $a$ \u4e2d\u6240\u6709\u5143\u7d20\u4e92\u4e0d\u76f8\u540c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e09\u884c\u5305\u542b $m$ \u4e2a\u6574\u6570 $b_1, b_2, \\dots, b_m$ ($0 \\le b_i \\le 10^9$) \u2014\u2014 \u5c16\u523a\u6240\u5728\u7684\u4f4d\u7f6e\u3002\u4fdd\u8bc1 $b$ \u4e2d\u6240\u6709\u5143\u7d20\u4e92\u4e0d\u76f8\u540c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u56db\u884c\u662f\u957f\u5ea6\u4e3a $k$ \u7684\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u4f20\u7ed9\u673a\u5668\u4eba\u7684\u6307\u4ee4\u3002\u6bcf\u4e2a\u5b57\u7b26\u8981\u4e48\u662f <code>L<\/code>\uff0c\u8868\u793a\u5411\u5de6\u79fb\u52a8\u4e00\u683c\uff0c\u8981\u4e48\u662f <code>R<\/code>\uff0c\u8868\u793a\u5411\u53f3\u79fb\u52a8\u4e00\u683c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fdd\u8bc1\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u4e2d $n, m, k$ \u7684\u603b\u548c\u4e0d\u8d85\u8fc7 $2 \\cdot 10^5$\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>\u989d\u5916\u7ea6\u675f\uff1a<\/strong> \u4fdd\u8bc1\u673a\u5668\u4eba\u548c\u5c16\u523a\u4e0d\u4f1a\u51fa\u73b0\u5728\u540c\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u51fa\u683c\u5f0f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fa $k$ \u4e2a\u6574\u6570\uff0c\u7b2c $i$ \u4e2a\u6574\u6570\u8868\u793a\u6267\u884c\u5b8c\u524d $i$ \u6761\u6307\u4ee4\u540e\u5e78\u5b58\u7684\u673a\u5668\u4eba\u6570\u91cf\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Python \u7528\u6237\u6ce8\u610f\uff1a<\/strong> \u63d0\u4ea4\u65f6\u8bf7\u9009\u7528 PyPy3 \/ PyPy2\uff08\u53d6\u51b3\u4e8e\u4f60\u7528\u7684 Python \u7248\u672c\uff09\uff0c\u4e0d\u8981\u7528 Python3 \u6216 Python2\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u6837\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Plaintext<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>3\n2 1 3\n0 1\n2\nLRR\n2 3 3\n2 4\n1 3 5\nLRL\n3 2 3\n1 3 7\n9 6\nRRL\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Plaintext<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2 2 1\n0 0 0\n3 2 2\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6837\u4f8b\u8bf4\u660e<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5bf9\u4e8e\u7b2c\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff1a<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u7b2c\u4e00\u4e2a\u673a\u5668\u4eba\u4f1a\u79fb\u52a8\u5230 $0 \\to -1 \\to 0 \\to 1$\uff0c\u56e0\u6b64\u4e0d\u4f1a\u9635\u4ea1\u3002<\/li>\n\n\n\n<li>\u7b2c\u4e8c\u4e2a\u673a\u5668\u4eba\u4f1a\u79fb\u52a8\u5230 $1 \\to 0 \\to 1 \\to 2$\uff0c\u6267\u884c\u7b2c\u4e09\u6761\u6307\u4ee4\u540e\u4f1a\u78b0\u5230\u4f4d\u7f6e $2$ \u7684\u5c16\u523a\uff0c\u9635\u4ea1\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5bf9\u4e8e\u7b2c\u4e8c\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff1a<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u4e24\u4e2a\u673a\u5668\u4eba\u79fb\u52a8\u4e00\u6b21\u540e\u90fd\u4f1a\u9635\u4ea1\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u9898\u76ee\u601d\u8def<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a\u673a\u5668\u4eba\u627e\u5230\u5de6\u53f3\u4e24\u8fb9\u6700\u8fd1\u80fd\u649e\u6b7b\u7684\u9489\u5b50\uff0c\u7136\u540e\u5f00\u4e00\u4e2a\u201c\u6b7b\u4ea1\u7b14\u8bb0\u201d\uff1a\u8bb0\u5f55\u4f4d\u79fb\u91cf\u8fbe\u5230\u591a\u5c11\u53ef\u4ee5\u521b\u6b7b\u8be5\u673a\u5668\u4eba\u3002\u7136\u540e\u5f00\u59cb\u6a21\u62df\u8be2\u95ee\uff0c\u5728\u8fd9\u4e2a\u5730\u65b9\u521b\u6b7b\u8fc7\u673a\u5668\u4eba\u4ee5\u540e\u5c31\u4e0d\u7528\u91cd\u590d\u68c0\u67e5\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u4ee3\u7801<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">C++<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;  \n#include&lt;vector&gt;  \n#include&lt;set&gt;  \n#include&lt;map&gt;  \n#include&lt;algorithm&gt;  \n\nusing namespace std;  \n\nvoid solve(){  \n    int n, m, k;  \n    cin &gt;&gt; n &gt;&gt; m &gt;&gt; k;  \n    \n    set&lt;int&gt; a;  \n    for(int i = 0; i &lt; n; i++){  \n        int x; \n        cin &gt;&gt; x;  \n        a.insert(x);  \n    }  \n    \n    vector&lt;int&gt; b;  \n    for(int i = 0; i &lt; m; i++){  \n        int x; \n        cin &gt;&gt; x;  \n        b.push_back(x);  \n    }  \n    \n    map&lt;int, vector&lt;int&gt;&gt; death_note;  \n    \n    for(int x : a){  \n        int idx = lower_bound(b.begin(), b.end(), x) - b.begin();  \n        \n        if(idx &lt; m){  \n            int dist = b&#91;idx] - x;  \n            if(abs(dist) &lt;= k){  \n                death_note&#91;dist].push_back(x);  \n            }  \n        }  \n        \n        if(idx &gt; 0){  \n            int dist = b&#91;idx-1] - x;  \n            if(abs(dist) &lt;= k){  \n                death_note&#91;dist].push_back(x);  \n            }  \n        }  \n    }  \n    \n    string s; \n    cin &gt;&gt; s;  \n    \n    int curr = 0;  \n    for(auto c : s){  \n        if(c == 'L') curr--;  \n        else curr++;  \n        \n        if(death_note.count(curr)){  \n            for(auto robot : death_note&#91;curr]){  \n                a.erase(robot);  \n            }  \n            death_note.erase(curr);  \n        }  \n        \n        cout &lt;&lt; a.size() &lt;&lt; \" \";  \n    }  \n    cout &lt;&lt; endl;  \n}  \n  \nint main(){  \n    int t; \n    cin &gt;&gt; t;  \n    while(t--) solve();  \n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0 \u6709\u4e00\u6761\u65e0\u9650\u957f\u7684\u6570\u8f74\u3002 \u6570\u8f74\u4e0a\u6709 $n$ \u4e2a\u673a\u5668\u4eba\u548c $m$ \u4e2a\u5c16\u523a\uff0c\u5b83\u4eec\u5206\u522b\u4f4d\u4e8e\u6570\u8f74\u4e0a\u7684\u7279\u5b9a\u70b9\u3002\u7b2c  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,10],"tags":[],"class_list":["post-151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeforces","category-10"],"_links":{"self":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":2,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/151\/revisions\/207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media\/133"}],"wp:attachment":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}