{"id":23,"date":"2023-01-19T21:01:00","date_gmt":"2023-01-19T13:01:00","guid":{"rendered":"https:\/\/solost.cn\/?p=23"},"modified":"2023-02-02T00:54:27","modified_gmt":"2023-02-01T16:54:27","slug":"50","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=23","title":{"rendered":"2023\u725b\u5ba2\u5bd2\u5047\u7b97\u6cd5\u57fa\u7840\u96c6\u8bad\u84252 C-Tokitsukaze and a+b=n (hard)"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/2202397934.png\" alt=\"\" title=\"\"><\/p>\n<h2>solution<\/h2>\n<p>\u7d2f\u4e86\uff0c\u521a\u5199\u5b8c\u7684\u9898\u89e3\u6ca1\u4fdd\u5b58\uff0c\u5c31\u7b80\u5355\u7684\u7ed9\u4e00\u4e0b\u8fc7\u7a0b\u5427<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/2583859761.png\" alt=\"\" title=\"\"><\/p>\n<pre><code class=\"C++\">#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 = 998244353;\nconst int N = 4e5 + 10;\nll a[N];\nvoid solve()\n{\n    ll n, m;\n    vector&lt;pair&lt;int, int&gt;&gt; q;\n    cin &gt;&gt; n &gt;&gt; m;\n    for (int i = 1; i &lt;= m; i++) {\n        int l, r;\n        cin &gt;&gt; l &gt;&gt; r;\n        a[l]++, a[r + 1]--;\/\/\u5dee\u5206\u6570\u7ec4\u5904\u7406\n        q.push_back({ l, r });\n    }\n    for (int i = 1; i &lt;= 4e5 + 5; i++) {\n        a[i] += a[i - 1];\/\/\u5c06\u6570\u7ec4\u5904\u7406\u6210\u5dee\u5206\u6570\u7ec4\n    }\n    for(int i = 1; i &lt;= 4e5 + 5; i++){\n        a[i] += a[i - 1];\/\/\u5c06\u5dee\u5206\u6570\u7ec4\u5904\u7406\u6210\u524d\u7f00\u548c\u6570\u7ec4\n    }\n    ll ans = 0;\n    for (auto x : q) {\n        ll l = x.first, r = x.second;\n        ll st = max(n - r, 1ll), ed = max(0ll, n - l);\/\/\u8ba1\u7b97\u672c\u533a\u95f4\u7684\u4e92\u8865\u533a\u95f4\u5927\u5c0f\n        ll st1 = max(l, n - r);\n        ll ed1 = min(r, n - l);\/\/\u8ba1\u7b97\u81ea\u8eab\u533a\u95f4\u6ee1\u8db3\u6761\u4ef6\u7684\u5408\u6cd5\u533a\u95f4\n        ans = (ans % mod + (a[ed] - a[st - 1] - max(ed1 - st1 + 1, 0ll)) % mod) % mod;\n    \/\/\u7b54\u6848\u5c31\u662f\u81ea\u8eab\u6ee1\u8db3\u6761\u4ef6\u7684\u5408\u6cd5\u4e92\u8865\u533a\u95f4\u51cf\u53bb\u81ea\u8eab\u548c\u81ea\u8eab\u4e92\u8865\u7684\u533a\u95f4\u957f\u5ea6\uff0c\u5c31\u5f97\u5230\u4e86\u672c\u6b21\u533a\u95f4\u548c\u5269\u4e0b\u6240\u6709\u6ee1\u8db3\u6761\u4ef6\u4e92\u8865\u533a\u95f4\u4e2a\u6570\uff0c\u7d2f\u52a0\u53d6\u6a21\u5373\u53ef\n    }\n    cout &lt;&lt; ans &lt;&lt; endl;\n}\nint main()\n{\n    IOS;\n    int t = 1;\n    while (t--) {\n        solve();\n    }\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>solution \u7d2f\u4e86\uff0c\u521a\u5199\u5b8c\u7684\u9898\u89e3\u6ca1\u4fdd\u5b58\uff0c\u5c31\u7b80\u5355\u7684\u7ed9\u4e00\u4e0b\u8fc7\u7a0b\u5427 #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 unsigned long [&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":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-solution"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/23","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=23"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}