{"id":1988,"date":"2022-07-07T08:39:25","date_gmt":"2022-07-07T00:39:25","guid":{"rendered":"https:\/\/www.shuizilong.com\/house\/?p=1988"},"modified":"2022-07-08T15:16:04","modified_gmt":"2022-07-08T07:16:04","slug":"codechef-june15-chefbook","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codechef-june15-chefbook\/","title":{"rendered":"Codechef JUNE15. Chefbook"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/www.codechef.com\/submit\/CHEFBOOK\">https:\/\/www.codechef.com\/submit\/CHEFBOOK<\/a><\/li>\n<\/ul>\n<p>\u6211\u9760\u8fd9\u4e2a\u8fd8\u8981\u6784\u9020\u89e3\u3002\u3002\u3002\u3002<br \/>\nWA ing<\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\r\nconst int N = 1000, M = N*N;\r\nVI in&#x5B;N], out&#x5B;N];\r\n\r\nstruct Simplex {\r\n    const static int N = int(1e4) + 9, M = int(1e4) + 9;\r\n    DB a&#x5B;N]&#x5B;M]; int b&#x5B;N], c&#x5B;M], X&#x5B;M];\r\n    int n, m;\r\n\r\n    void pivot(int in, int out) {\r\n        REP(i, m+1) if(i!=in) a&#x5B;out]&#x5B;i] \/= -a&#x5B;out]&#x5B;in]; \/\/\u91cd\u7f6eout\u7ea6\u675f\r\n        a&#x5B;out]&#x5B;in] = 1\/a&#x5B;out]&#x5B;in];\r\n\r\n        REP(i, n+1) if (i!=out &amp;&amp; sgn(a&#x5B;i]&#x5B;in])) { \/\/\u91cd\u65b0\u8ba1\u7b97\u5176\u4ed6\u7ea6\u675f\r\n            DB t = a&#x5B;i]&#x5B;in]; a&#x5B;i]&#x5B;in] = 0;\r\n            REP(j, m+1) a&#x5B;i]&#x5B;j] += t*a&#x5B;out]&#x5B;j];\r\n        }\r\n        swap(c&#x5B;in], b&#x5B;out]);\r\n    }\r\n\r\n    void run() {\r\n\r\n        REP_1(i, n) b&#x5B;i] = -i;\r\n        REP_1(i, m) c&#x5B;i] = i;\r\n\r\n        while (true) {\r\n            int in=0, out=0; DB Min=OO;\r\n            REP_1(i, m) if(sgn(a&#x5B;0]&#x5B;i])&gt;0) {\r\n                in=i;\r\n                break;\r\n            }\r\n            if(!in)return;\r\n            REP_1(i, n) if(sgn(a&#x5B;i]&#x5B;in])&lt;0&amp;&amp;a&#x5B;i]&#x5B;0]\/-a&#x5B;i]&#x5B;in]&lt;Min) {\r\n                Min=a&#x5B;i]&#x5B;0]\/-a&#x5B;i]&#x5B;in];\r\n                out=i;\r\n            }\r\n            if(!out) return; \/\/throw ; \/\/unbounded\r\n            pivot(in, out);\r\n        }\r\n    }\r\n\r\n    struct Edge {\r\n        int x,y,w,s,t;\r\n        void in() {\r\n            RD(x,y,w,s,t);\r\n            --x; --y;\r\n        }\r\n    } E&#x5B;::M];\r\n\r\n    void gao() {\r\n\/\/ z c\r\n\/\/ b A\r\n\r\n        RD(n, m);\r\n\r\n        REP(i, n) {\r\n            in&#x5B;i].clear();\r\n            out&#x5B;i].clear();\r\n        }\r\n\r\n        REP(i, m){\r\n            E&#x5B;i].in();\r\n            int x = E&#x5B;i].x, y = E&#x5B;i].y, w = E&#x5B;i].w, s = E&#x5B;i].s, t = E&#x5B;i].t;\r\n            in&#x5B;x].PB(y); out&#x5B;y].PB(x); a&#x5B;0]&#x5B;0] += w;\r\n            DB (&amp;r0)&#x5B;M] = a&#x5B;i+1]; r0&#x5B;0] = t - w; r0&#x5B;x+1] -= 1; r0&#x5B;n+y+1] += 1;\r\n            DB (&amp;r1)&#x5B;M] = a&#x5B;m+i+1]; r1&#x5B;0] = w - s; r1&#x5B;x+1] += 1; r1&#x5B;n+y+1] -= 1;\r\n        }\r\n\r\n        REP(i, n) a&#x5B;0]&#x5B;i+1] += SZ(out&#x5B;i]);\r\n        REP(i, n) a&#x5B;0]&#x5B;n+i+1] -= SZ(in&#x5B;i]);\r\n\r\n        n *= 2; m *= 2; swap(n, m);\r\n\r\n        \/*\r\n        REP(i, n+1) {\r\n            REP(j, m+1) cout &lt;&lt; a&#x5B;i]&#x5B;j] &lt;&lt; &quot; &quot;;\r\n            cout &lt;&lt; endl;\r\n        }\r\n\r\n        REP_1(i, n) cout &lt;&lt; b&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        REP_1(i, m) cout &lt;&lt; c&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        REP_1(i, m) cout &lt;&lt; X&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        *\/\r\n\r\n        run();\r\n\r\n        \/*\r\n        cout &lt;&lt; &quot;-----------&quot; &lt;&lt; endl;\r\n\r\n        REP(i, n+1) {\r\n            REP(j, m+1) cout &lt;&lt; a&#x5B;i]&#x5B;j] &lt;&lt; &quot; &quot;;\r\n            cout &lt;&lt; endl;\r\n        }\r\n        cout &lt;&lt; &quot;-----------&quot; &lt;&lt; endl;\r\n        *\/\r\n\r\n\r\n\r\n        \/*REP_1(i, m\/2) {\r\n            cout &lt;&lt; a&#x5B;0]&#x5B;i] &lt;&lt; &quot; &quot;&lt;&lt; a&#x5B;0]&#x5B;m\/2+i] &lt;&lt; endl;\r\n        }*\/\r\n\r\n\r\n        REP_1(i, m) X&#x5B;i] = 0;\r\n        REP_1(i, n) if (b&#x5B;i] &gt; 0) X&#x5B;b&#x5B;i]] = a&#x5B;i]&#x5B;0];\r\n\r\n        \/*\r\n        REP_1(i, n) cout &lt;&lt; b&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        REP_1(i, m) cout &lt;&lt; c&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        REP_1(i, m) cout &lt;&lt; X&#x5B;i] &lt;&lt; &quot; &quot;; cout &lt;&lt; endl;\r\n        *\/\r\n\r\n        REP(i, n\/2) {\r\n            int x = E&#x5B;i].x, y = E&#x5B;i].y, w = E&#x5B;i].w, s = E&#x5B;i].s, t = E&#x5B;i].t;\r\n            w += X&#x5B;x+1]; w -= X&#x5B;m\/2+y+1];\r\n            if (w &lt; s || t &lt; w) {\r\n                puts(&quot;Unlike&quot;);\r\n                REP(i, n+1) {\r\n                    REP(j, m+1) a&#x5B;i]&#x5B;j] = 0;\r\n                }\r\n                return;\r\n            }\r\n        }\r\n\r\n        OT((LL)a&#x5B;0]&#x5B;0]);\r\n        REP_1(i, m\/2) {\r\n            cout &lt;&lt; (LL)X&#x5B;i] &lt;&lt; &quot; &quot;&lt;&lt; (LL)X&#x5B;m\/2+i] &lt;&lt; endl;\r\n        }\r\n\r\n\r\n        REP(i, n+1) {\r\n            REP(j, m+1) a&#x5B;i]&#x5B;j] = 0;\r\n        }\r\n    }\r\n} fst;\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;out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n    Rush fst.gao();\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.codechef.com\/submit\/CHEFBOOK \u6211\u9760\u8fd9\u4e2a\u8fd8\u8981\u6784\u9020\u89e3\u3002\u3002\u3002\u3002 WA ing const int N = 1000, M = N*N; VI in&#x5B;N], out&#x5B;N]; struct Simplex { const static int N = int(1e4) + 9, M = int(1e4) + 9; DB a&#x5B;N]&#x5B;M]; int b&#x5B;N], c&#x5B;M], X&#x5B;M]; int n, m; void pivot(int in, int out) { REP(i, m+1) if(i!=in) a&#x5B;out]&#x5B;i] \/= -a&#x5B;out]&#x5B;in]; \/\/\u91cd\u7f6eout\u7ea6\u675f a&#x5B;out]&#x5B;in] = [&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-1988","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-w4","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1988","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=1988"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1988\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}