{"id":47,"date":"2023-02-02T12:55:00","date_gmt":"2023-02-02T04:55:00","guid":{"rendered":"https:\/\/solost.cn\/?p=47"},"modified":"2023-02-02T12:58:24","modified_gmt":"2023-02-02T04:58:24","slug":"107","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=47","title":{"rendered":"2023\u725b\u5ba2\u5bd2\u5047\u7b97\u6cd5\u57fa\u7840\u96c6\u8bad\u84255-D-\u5c0f\u6c99\u306e\u8d4c\u6c14"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/image.png\" alt=\"image.png\" title=\"image.png\"><\/p>\n<h2>solution<\/h2>\n<p>\u8fd9\u9053\u9898\u7684\u96be\u70b9\u662f\u6309\u7167\u987a\u5e8f\u7ed9\u51fa\u533a\u95f4\uff0c\u7136\u540e\u95ee\u4f60\u6bcf\u6b21\u80fd\u4ece1\u5230\u8fbe\u7684\u4f4d\u7f6e\u3002<\/p>\n<ul>\n<li>\u9519\u8bef\u70b9\u6709\u4e00\u4e2a\u5730\u65b9\uff0c\u6211\u4ee5\u4e3a\u662f\u8d2a\u5fc3\u5230\u6700\u8fdc\u7684\u5730\u65b9\uff0c\u7ed3\u679c\u540e\u6765\u53d1\u73b0\u662f\u4e0d\u53ef\u4ee5\u8c03\u6574\u987a\u5e8f\u7684<\/li>\n<li>\u6b63\u89e3\u662f\u628a\u6bcf\u4e2a\u533a\u95f4\u90fd\u653e\u5230\u4e00\u4e2aset\u91cc\u9762\uff0c\u56e0\u4e3aset\u4f1a\u81ea\u5df1\u6392\u5e8f\uff0c\u6240\u4ee5\u6839\u636epair\u7684\u7b2c\u4e00\u4e2a\u503c\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u5c06\u6bcf\u4e00\u4e2a\u533a\u95f4\u8fdb\u884c\u6269\u5c55\uff0c\u5982\u679c\u9047\u5230\u4e00\u4e2a\u5143\u7d20\u7684\u9996\u5143\u7d20\u5c0f\u4e8e\u7b49\u4e8e\u7ed3\u5c3e\uff0c\u90a3\u5c31\u628a\u7ed3\u5c3e\u6269\u5c55\uff0c\u6ce8\u610f\uff01\uff01\uff01\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u679c\u7ed3\u5c3e\u4ece1\u5f00\u59cb\uff0c\u90a3\u4e48\u6bcf\u4e2a\u533a\u95f4\u7684\u7ed3\u5c3e\u5143\u7d20\u5f97+1\uff0c\u9632\u6b62\u5b9a\u4e49\u521d\u59cb\u7ed3\u5c3e\u65f6\u51b2\u7a81\u3002\u4f8b\u5982\uff0c\u521a\u5f00\u59cb\u5b9a\u4e49<code>st=1<\/code>,\u7ed9\u51fa\u4e00\u4e2a\u533a\u95f4\u662f<code>2-3<\/code>\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5c31\u4e0d\u6ee1\u8db3\u60c5\u51b5\uff0c\u56e0\u4e3a1\u662f\u6211\u4eec\u521d\u59cb\u5316\u7684\uff0c\u7ed9\u51fa\u7684\u533a\u95f4\u8fd8\u6ca1\u7ed9\u51fa1\uff0c\u6240\u4ee5\u4e0d\u80fd\u8fd9\u6837\u64cd\u4f5c\uff0c\u9700\u8981\u5c06\u6bcf\u4e00\u4e2a\u533a\u95f4\u6269\u5c55\u7684\u65f6\u5019\u5c06\u672b\u5c3e\u52a01\uff0c<code>\u56e0\u4e3a\u8fd9\u9053\u9898\u7ed9\u51fa\u7684\u662f2\u89e3\u9501\u4e86\uff0c3\u4e5f\u5c31\u89e3\u9501\uff0c\u4e0d\u662f\u76f8\u4ea4\u7684\uff0c\u53ef\u4ee5\u65ad\u5f00\u4e00\u4e2a<\/code>\uff0c\u8fd9\u8981\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u521d\u59cb\u5316\u7684\u503c\u4e0d\u4f1a\u5f71\u54cd\u6b63\u5e38\u7684\u533a\u95f4\u5408\u5e76\u3002<\/li>\n<\/ul>\n<hr>\n<pre><code class=\"lang-cpp\">#include &lt;algorithm&gt;\n#include &lt;bitset&gt;\n#include &lt;cmath&gt;\n#include &lt;cstdio&gt;\n#include &lt;cstdlib&gt;\n#include &lt;cstring&gt;\n#include &lt;fstream&gt;\n#include &lt;iostream&gt;\n#include &lt;map&gt;\n#include &lt;queue&gt;\n#include &lt;set&gt;\n#include &lt;stack&gt;\n#include &lt;unordered_map&gt;\n#include &lt;vector&gt;\n\nusing namespace std;\n#define endl &#039;\\n&#039;\n#define IOS                       \\\n    ios_base::sync_with_stdio(0); \\\n    cin.tie(0);                   \\\n    cout.tie(0);\ntypedef long long ll;\ntypedef pair&lt;int, int&gt; PII;\ntypedef unsigned long long ull;\nconst int INF = 0x3f3f3f3f, mod = 1000000007;\nconst int N = 2e5 + 10;\nvector&lt;pair&lt;int, int&gt;&gt; a, b;\nset&lt;pair&lt;int, int&gt;&gt; v1, v2;\nint ed1 = 1, ed2 = 1;\n\nvoid op1(){\n    while((*v1.begin()).first &lt;= ed1){\n        ed1 = max((*v1.begin()).second + 1, ed1);\n        v1.erase(v1.begin());\n        if(v1.empty()) return;\n    }\n}\n\nvoid op2(){\n    while((*v2.begin()).first &lt;= ed2){\n        ed2 = max((*v2.begin()).second + 1, ed2);\n        v2.erase(v2.begin());\n        if(v2.empty()) return;\n    }\n}\n\nint main()\n{\n    int n;\n    cin &gt;&gt; n;\n  \n    for (int i = 1; i &lt;= n; i++) {\n        int l, r;\n        cin &gt;&gt; l &gt;&gt; r;\n        a.push_back({ l, r });\n    }\n    for (int i = 1; i &lt;= n; i++) {\n        int l, r;\n        cin &gt;&gt; l &gt;&gt; r;\n        b.push_back({ l, r });\n    }\n    for (int i = 0; i &lt; n; i++) {\n        \/\/ if (f1 &amp;&amp; a[i].first &lt;= ed1 + 1)\n        \/\/     ed1 = max(ed1, a[i].second);\n        \/\/ if (f2 &amp;&amp; b[i].first &lt;= ed2 + 1)\n        \/\/     ed2 = max(ed2, b[i].second);\n        v1.insert(a[i]);\n        v2.insert(b[i]);\n        op1();\n        op2();\n        if (ed1 &gt; ed2) {\n            cout &lt;&lt; &quot;sa_win!\\n&quot;;\n        } else if (ed1 &lt; ed2) {\n            cout &lt;&lt; &quot;ya_win!\\n&quot;;\n        } else {\n            cout &lt;&lt; &quot;win_win!\\n&quot;;\n        }\n        cout &lt;&lt; abs(ed1 - ed2) &lt;&lt; endl;\n    }\n\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>solution \u8fd9\u9053\u9898\u7684\u96be\u70b9\u662f\u6309\u7167\u987a\u5e8f\u7ed9\u51fa\u533a\u95f4\uff0c\u7136\u540e\u95ee\u4f60\u6bcf\u6b21\u80fd\u4ece1\u5230\u8fbe\u7684\u4f4d\u7f6e\u3002 \u9519\u8bef\u70b9\u6709\u4e00\u4e2a\u5730\u65b9\uff0c\u6211\u4ee5\u4e3a\u662f\u8d2a\u5fc3\u5230\u6700\u8fdc\u7684\u5730\u65b9\uff0c\u7ed3\u679c\u540e\u6765\u53d1\u73b0\u662f\u4e0d\u53ef\u4ee5\u8c03\u6574\u987a\u5e8f\u7684 \u6b63\u89e3\u662f\u628a\u6bcf\u4e2a\u533a\u95f4\u90fd\u653e\u5230\u4e00\u4e2aset\u91cc\u9762\uff0c\u56e0\u4e3aset\u4f1a\u81ea\u5df1\u6392\u5e8f\uff0c\u6240\u4ee5\u6839\u636epair\u7684\u7b2c\u4e00\u4e2a\u503c\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u5c06\u6bcf\u4e00\u4e2a\u533a\u95f4\u8fdb\u884c\u6269\u5c55\uff0c\u5982\u679c\u9047\u5230\u4e00\u4e2a\u5143\u7d20\u7684\u9996\u5143\u7d20\u5c0f\u4e8e\u7b49\u4e8e\u7ed3\u5c3e\uff0c\u90a3\u5c31\u628a\u7ed3\u5c3e\u6269\u5c55\uff0c\u6ce8\u610f\uff01\uff01\uff01\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u679c\u7ed3\u5c3e\u4ece1\u5f00\u59cb\uff0c\u90a3\u4e48\u6bcf\u4e2a\u533a\u95f4\u7684\u7ed3\u5c3e\u5143\u7d20\u5f97+1\uff0c\u9632\u6b62\u5b9a\u4e49\u521d\u59cb\u7ed3\u5c3e\u65f6\u51b2\u7a81\u3002\u4f8b\u5982\uff0c\u521a\u5f00\u59cb\u5b9a\u4e49st=1,\u7ed9\u51fa\u4e00\u4e2a\u533a\u95f4\u662f2-3\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5c31\u4e0d\u6ee1\u8db3\u60c5\u51b5\uff0c\u56e0\u4e3a1\u662f\u6211\u4eec\u521d\u59cb\u5316\u7684\uff0c\u7ed9\u51fa\u7684\u533a\u95f4\u8fd8\u6ca1\u7ed9\u51fa1\uff0c\u6240\u4ee5\u4e0d\u80fd\u8fd9\u6837\u64cd\u4f5c\uff0c\u9700\u8981\u5c06\u6bcf\u4e00\u4e2a\u533a\u95f4\u6269\u5c55\u7684\u65f6\u5019\u5c06\u672b\u5c3e\u52a01\uff0c\u56e0\u4e3a\u8fd9\u9053\u9898\u7ed9\u51fa\u7684\u662f2\u89e3\u9501\u4e86\uff0c3\u4e5f\u5c31\u89e3\u9501\uff0c\u4e0d\u662f\u76f8\u4ea4\u7684\uff0c\u53ef\u4ee5\u65ad\u5f00\u4e00\u4e2a\uff0c\u8fd9\u8981\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u521d\u59cb\u5316\u7684\u503c\u4e0d\u4f1a\u5f71\u54cd\u6b63\u5e38\u7684\u533a\u95f4\u5408\u5e76\u3002 #include &lt;algorithm&gt; #include &lt;bitset&gt; #include &lt;cmath&gt; #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;cstring&gt; #include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;queue&gt; #include &lt;set&gt; #include &lt;stack&gt; #include &lt;unordered_map&gt; #include &lt;vector&gt; using namespace std; #define endl &#039;\\n&#039; #define IOS \\ ios_base::sync_with_stdio(0); \\ cin.tie(0); \\ cout.tie(0); typedef long long ll; typedef pair&lt;int, int&gt; PII; typedef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[17,9],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-solution","tag-stl","tag-9"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}