{"id":1990,"date":"2022-07-14T20:30:45","date_gmt":"2022-07-14T12:30:45","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=1990"},"modified":"2022-07-14T21:56:34","modified_gmt":"2022-07-14T13:56:34","slug":"uoj-77-ab-problem","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/uoj-77-ab-problem\/","title":{"rendered":"UOJ #77. A+B Problem"},"content":{"rendered":"<p>\u9996\u5148\u8fd8\u662f\u7c7b\u4f3c <a href=\"https:\/\/www.shuizilong.com\/house\/archives\/poj-3469-dual-core-cpu\/\">POJ 3469. Dual Core CPU<\/a> \u7684\u6700\u5c0f\u5272\u5efa\u6a21\u3002<br \/>\n\u96be\u70b9\u662f\u5bf9\u6bcf\u4e2a\u8282\u70b9 i\uff0c\u6211\u4eec\u9700\u8981\u6784\u9020\u8f85\u52a9\u8282\u70b9 i&#8217;\uff0c\u6ee1\u8db3\uff0c\u5982\u679c\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684 j \u5728 T \u5272\uff0c\u90a3\u4e48 i&#8217; \u4e5f\u4e00\u5b9a\u5728 T \u5272\u3002<\/p>\n<p>\u56e0\u4e3a\u627e j \u7684\u8fc7\u7a0b\u662f\u4e00\u4e2a\u533a\u95f4\u5173\u7cfb\uff0c\u66b4\u529b\u6784\u9020 i&#8217; \u7684\u8bdd\u8fb9\u6570\u592a\u591a\u3002<br \/>\n\u7c7b\u6bd4\u786e\u5b9a\u67d3\u8272\u65b9\u6848\u540e\uff0c\u67e5\u8be2\u7ed3\u679c\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u4e2a\u663e\u7136\u53ef\u4ee5\u79bb\u6563\u5316 + \u7ebf\u6bb5\u6811\uff08\u6811\u72b6\u6570\u7ec4\uff09\uff0c<br \/>\n\u6211\u4eec\u53d1\u73b0\u53ef\u4ee5\u4f7f\u7528\u7ebf\u6bb5\u6811\u6765\u523b\u753b\u8fd9\u4e9b\u8f85\u52a9\u8282\u70b9\u4ee5\u51cf\u5c11\u8fb9\u7684\u89c4\u6a21\u3002\uff08\u7c7b\u4f3c\u8fb9\u5206\u6cbb\u91cc\u7684\u52a0\u8f85\u52a9\u7ed3\u70b9\uff1f\uff09<br \/>\n\uff083b1b \u6f14\u793a\u7684\u8bdd\u3002\u3002\u5927\u6982\u5c31\u662f\u628a i&#8217; \u8fd9\u4e2a\u8f85\u52a9\u70b9\uff0c\u6162\u6162\u6269\u6563\u6210\u4e00\u4e2a\u7ebf\u6bb5\u6811\uff0c\u6bcf\u6269\u6563\u4e00\u5c42\uff0c\u53f6\u5b50\u6240\u8fde\u7684\u8fb9\u7684\u89c4\u6a21\u5c31\u5c11\u4e00\u5c42\u3002\u3002\uff09\u3002<\/p>\n<p>\u8fd9\u79cd\u9898\u76ee\u7684\u51fa\u6cd5\u540e\u6765\u5728\u7f51\u8d5b\u91cc\u4e5f\u51fa\u8fc7\u3002\u3002\u3002<br \/>\n\u53e6\u5916\u8fd9\u4e2a\u9898\u8981\u8003\u8651 j &lt;= i \u8fd9\u4e2a\u9650\u5236\uff0c\u6700\u540e\u8fd8\u9700\u8981\u4f7f\u7528\u51fd\u6570\u5f0f\u7ebf\u6bb5\u6811\u3002<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = int(5e3) + 9;\r\n\r\nint T&#x5B;N], X&#x5B;N], Y&#x5B;N]; vector&lt;int&gt; A;\r\nint n, z;\r\n\r\nnamespace ST{\r\n\r\n#define lx l&#x5B;x]\r\n#define rx r&#x5B;x]\r\n#define ly l&#x5B;y]\r\n#define ry r&#x5B;y]\r\n#define ml (ll + rr &gt;&gt; 1)\r\n#define mr (ml + 1)\r\n\r\n    const int NN = N*18 + 9;\r\n    int l&#x5B;NN], r&#x5B;NN], tot;\r\n\r\n    int new_node(){\r\n        return ++tot;\r\n    }\r\n\r\n    int Add(int y, int p, int i){\r\n        int x = new_node(), root = x; int ll = 0, rr = n-1;\r\n\r\n        while (ll &lt; rr){\r\n            if (p &lt; mr){\r\n                lx = new_node(), rx = ry;\r\n                x = lx, y = ly, rr = ml;\r\n            }\r\n            else {\r\n                lx = ly, rx = new_node();\r\n                x = rx, y = ry, ll = mr;\r\n            }\r\n        }\r\n\r\n        X&#x5B;i] = x; Y&#x5B;i] = y;\r\n        return root;\r\n    }\r\n\r\n    void Query(int x, int ll, int rr, int a, int b, VI&amp; L) {\r\n        if (!x || b &lt; ll || rr &lt; a) return;\r\n        if (a &lt;= ll &amp;&amp; rr &lt;= b) {\r\n            L.PB(x);\r\n        } else {\r\n            Query(lx, ll, ml, a, b, L);\r\n            Query(rx, mr, rr, a, b, L);\r\n        }\r\n    }\r\n} using namespace ST;\r\n\r\nstruct cell{\r\n    int a,b,w,l,r,p;\r\n    void in() {\r\n        RD(a,b,w,l,r,p); A.PB(a);\r\n        z += b; z += w;\r\n    }\r\n} C&#x5B;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    \/\/freopen(&quot;\/Users\/minakokojima\/Documents\/GitHub\/ACM-Training\/Workspace\/out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n\r\n    RD(n); REP(i, n) C&#x5B;i].in();\r\n\r\n    UNQ(A); REP(i, n) {\r\n        C&#x5B;i].l = LBD(A, C&#x5B;i].l); C&#x5B;i].r = UBD(A, C&#x5B;i].r)-1;\r\n        T&#x5B;i] = ST::Add(i ? T&#x5B;i-1] : 0, C&#x5B;i].a = LBD(A, C&#x5B;i].a), i);\r\n    }\r\n\r\n    atcoder::mf_graph&lt;int&gt; G(n+n+2+ST::tot);\r\n    int s = 2*n, t = n+n+1;\r\n\r\n    FOR(x, 1, ST::tot) {\r\n        if (lx) G.add_edge(t+x, t+lx, INF);\r\n        if (rx) G.add_edge(t+x, t+rx, INF);\r\n    }\r\n\r\n    REP(i, n) {\r\n        G.add_edge(s, i, C&#x5B;i].b);\r\n        G.add_edge(i, t, C&#x5B;i].w);\r\n        G.add_edge(i, n+i, C&#x5B;i].p);\r\n        \/*REP(j, i) if (C&#x5B;i].l &lt;= C&#x5B;j].a &amp;&amp; C&#x5B;j].a &lt;= C&#x5B;i].r) {\r\n            G.add_edge(i+n, j, INF);\r\n        }*\/\r\n        G.add_edge(t+X&#x5B;i], i, INF); if (Y&#x5B;i]) G.add_edge(t+X&#x5B;i], t+Y&#x5B;i], INF);\r\n        VI L; ST::Query(T&#x5B;i], 0, n-1, C&#x5B;i].l, C&#x5B;i].r, L);\r\n        for (auto l: L) G.add_edge(n+i, t+l, INF);\r\n    }\r\n\r\n    cout &lt;&lt; z - G.flow(s, t) &lt;&lt; endl;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u8fd8\u662f\u7c7b\u4f3c POJ 3469. Dual Core CPU \u7684\u6700\u5c0f\u5272\u5efa\u6a21\u3002 \u96be\u70b9\u662f\u5bf9\u6bcf\u4e2a\u8282\u70b9 i\uff0c\u6211\u4eec\u9700\u8981\u6784\u9020\u8f85\u52a9\u8282\u70b9 i&#8217;\uff0c\u6ee1\u8db3\uff0c\u5982\u679c\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684 j \u5728 T \u5272\uff0c\u90a3\u4e48 i&#8217; \u4e5f\u4e00\u5b9a\u5728 T \u5272\u3002 \u56e0\u4e3a\u627e j \u7684\u8fc7\u7a0b\u662f\u4e00\u4e2a\u533a\u95f4\u5173\u7cfb\uff0c\u66b4\u529b\u6784\u9020 i&#8217; \u7684\u8bdd\u8fb9\u6570\u592a\u591a\u3002 \u7c7b\u6bd4\u786e\u5b9a\u67d3\u8272\u65b9\u6848\u540e\uff0c\u67e5\u8be2\u7ed3\u679c\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u4e2a\u663e\u7136\u53ef\u4ee5\u79bb\u6563\u5316 + \u7ebf\u6bb5\u6811\uff08\u6811\u72b6\u6570\u7ec4\uff09\uff0c \u6211\u4eec\u53d1\u73b0\u53ef\u4ee5\u4f7f\u7528\u7ebf\u6bb5\u6811\u6765\u523b\u753b\u8fd9\u4e9b\u8f85\u52a9\u8282\u70b9\u4ee5\u51cf\u5c11\u8fb9\u7684\u89c4\u6a21\u3002\uff08\u7c7b\u4f3c\u8fb9\u5206\u6cbb\u91cc\u7684\u52a0\u8f85\u52a9\u7ed3\u70b9\uff1f\uff09 \uff083b1b \u6f14\u793a\u7684\u8bdd\u3002\u3002\u5927\u6982\u5c31\u662f\u628a i&#8217; \u8fd9\u4e2a\u8f85\u52a9\u70b9\uff0c\u6162\u6162\u6269\u6563\u6210\u4e00\u4e2a\u7ebf\u6bb5\u6811\uff0c\u6bcf\u6269\u6563\u4e00\u5c42\uff0c\u53f6\u5b50\u6240\u8fde\u7684\u8fb9\u7684\u89c4\u6a21\u5c31\u5c11\u4e00\u5c42\u3002\u3002\uff09\u3002 \u8fd9\u79cd\u9898\u76ee\u7684\u51fa\u6cd5\u540e\u6765\u5728\u7f51\u8d5b\u91cc\u4e5f\u51fa\u8fc7\u3002\u3002\u3002 \u53e6\u5916\u8fd9\u4e2a\u9898\u8981\u8003\u8651 j &lt;= i \u8fd9\u4e2a\u9650\u5236\uff0c\u6700\u540e\u8fd8\u9700\u8981\u4f7f\u7528\u51fd\u6570\u5f0f\u7ebf\u6bb5\u6811\u3002 const int N = int(5e3) + 9; int T&#x5B;N], X&#x5B;N], Y&#x5B;N]; vector&lt;int&gt; A; int n, z; namespace ST{ [&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-1990","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-w6","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1990","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=1990"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1990\/revisions"}],"predecessor-version":[{"id":1991,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1990\/revisions\/1991"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}