{"id":245,"date":"2012-06-09T21:47:32","date_gmt":"2012-06-09T13:47:32","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=245"},"modified":"2012-06-09T21:47:32","modified_gmt":"2012-06-09T13:47:32","slug":"baidu-astar-2012-%e5%88%9d%e8%b5%9b","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/baidu-astar-2012-%e5%88%9d%e8%b5%9b\/","title":{"rendered":"Baidu Astar 2012 \u521d\u8d5b"},"content":{"rendered":"<p>Day 1<\/p>\n<h3>Brief description: <\/h3>\n<p>&#8230;<\/p>\n<h3>Analysis: <\/h3>\n<p>&#8230;<\/p>\n<p><!--more--><\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem C. \u96c6\u5408\u7684\u4ea4\u4e0e\u5e76.cpp; toolbar: true; notranslate\" title=\"Problem C. \u96c6\u5408\u7684\u4ea4\u4e0e\u5e76.cpp\">\r\nconst int N = 100009;\r\npair&lt;LL, LL&gt; a&#x5B;N], b&#x5B;N];\r\n\r\n#define x first\r\n#define y second\r\n\r\nLL f(int u, int v){\r\n    return a&#x5B;u].y-a&#x5B;v].x &lt;= 0 ? 0 : (a&#x5B;v].y-a&#x5B;u].x)*(a&#x5B;u].y-a&#x5B;v].x);\r\n}\r\n\r\nbool cmp(const pair&lt;LL, LL&gt;&amp; a, const pair&lt;LL, LL&gt;&amp; b){\r\n    return a.x&lt;b.x || a.x==b.x &amp;&amp; a.y&gt;b.y ;\r\n}\r\n\r\nint main(){\r\n    int n; while (cin&gt;&gt;n){\r\n        REP(i, n)\r\n            scanf(&quot;%lld %lld&quot;, &amp;b&#x5B;i].x, &amp;b&#x5B;i].y);\r\n\r\n        LL res=0; int m=0; sort(b, b+n, cmp); for (int i=0,j;i&lt;n;i=j){\r\n            j=i+1; while (j&lt;n &amp;&amp; b&#x5B;j].y&lt;b&#x5B;i].y){\r\n                checkMax(res, (b&#x5B;j].y-b&#x5B;j].x)*(b&#x5B;i].y-b&#x5B;i].x));\r\n                j++;\r\n            }\r\n            a&#x5B;m++]=b&#x5B;i];\r\n        }\r\n\r\n        n = m; int j = 1; checkMax(res,f(0,1)); FOR(i, 2, n){\r\n            checkMax(res, f(j++,i) );\r\n            while (j&lt;i &amp;&amp; f(j,i) &gt;res)\r\n                res=f(j++, i);\r\n        }\r\n        cout&lt;&lt;res&lt;&lt;endl;\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem D. \u8f6e\u6905\u4e0a\u7684\u5ea6\u5ea6\u718a.cpp; toolbar: true; notranslate\" title=\"Problem D. \u8f6e\u6905\u4e0a\u7684\u5ea6\u5ea6\u718a.cpp\">\r\nconst int N = 109, M = 10;\r\n\r\nbool dp&#x5B;N+1]&#x5B;M+1]&#x5B;M+1]&#x5B;1&lt;&lt;M]; LL bonus&#x5B;1&lt;&lt;M];\r\nint a&#x5B;M], b&#x5B;M], c&#x5B;M];\r\nint n, m, p;\r\n\r\nVI L, Lb;\r\nbool G&#x5B;M]&#x5B;M*M];\r\n\r\n\r\nLL f(int s){\r\n    LL ans = 0;\r\n    REP(i, m) if (_1(s, i)){\r\n        ans += b&#x5B;i];\r\n    }\r\n    REP(i, SZ(L)) if ((s&amp;L&#x5B;i]) == L&#x5B;i]){\r\n        ans += Lb&#x5B;i];\r\n    }\r\n    return ans;\r\n}\r\n\r\n\r\nint main() {\r\n\r\n\/*\r\n#ifndef ONLINE_JUDGE\r\n\tfreopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n*\/\r\n\r\n    Rush{\r\n\r\n        RD(n, m, p); REP(i, m) RD(a&#x5B;i]); REP(i, m) RD(c&#x5B;i]); REP(i, m) RD(b&#x5B;i]);\r\n\r\n        int x, y; CLR(L, Lb); REP(i, p){\r\n            RD(x, y); int s = 0;REP(j, x) s |= _1(RD()-1);\r\n         \/\/   cout &lt;&lt; s &lt;&lt; endl;\r\n            L.PB(s); Lb.PB(y);\r\n        }\r\n\r\n        RST(G); REP(i, m){\r\n            if (a&#x5B;i] == 0) continue;\r\n            if (a&#x5B;i] == 1){\r\n                REP(j, m) if (RD() == 1) G&#x5B;i]&#x5B;j] = true;\r\n            }\r\n            else {\r\n                REP_2(j, k, m, m) if (RD() == 1) G&#x5B;i]&#x5B;j*m+k] = true;\r\n            }\r\n        }\r\n\r\n        REP_C(s, _1(m)) bonus&#x5B;s] = f(s);\r\n        FLC(dp, false); dp&#x5B;0]&#x5B;m]&#x5B;m]&#x5B;0] = true;\r\n\r\n        LL ans = 0;\r\n\r\n        FOR_1(i, 0, n) REP(l1, m+1) REP(l2, m+1) REP_C(s, _1(m)){\r\n            if (!dp&#x5B;i]&#x5B;l1]&#x5B;l2]&#x5B;s]) continue;\r\n\r\n            \/\/cout &lt;&lt; i &lt;&lt; &quot; &quot; &lt;&lt; s &lt;&lt; endl;\r\n\r\n            if (i == n) checkMax(ans, bonus&#x5B;s]);\r\n\r\n            REP(k, m) if (i + c&#x5B;k] &lt;= n){\r\n                if (!a&#x5B;k] || a&#x5B;k] == 1 &amp;&amp; l2 != m &amp;&amp; G&#x5B;k]&#x5B;l2] || a&#x5B;k] == 2 &amp;&amp; l1 != m &amp;&amp; l2 != m &amp;&amp; G&#x5B;k]&#x5B;l1*m+l2]){\r\n                    dp&#x5B;i+c&#x5B;k]]&#x5B;l2]&#x5B;k]&#x5B;s|_1(k)] = true;\r\n                }\r\n            }\r\n        }\r\n\r\n\/*\r\n        REP_C(i, _1(m)){\r\n            cout &lt;&lt; i &lt;&lt; &quot; &quot; &lt;&lt; f(i) &lt;&lt; endl;\r\n        }\r\n    *\/\r\n\r\n        cout &lt;&lt; ans &lt;&lt; endl;\r\n    }\r\n}\r\n\r\n\r\n\/*\r\n1110\r\n\/\/ 101\r\n\r\n*\/\r\n<\/pre>\n<p>Day 2<\/p>\n<h3>Brief description: <\/h3>\n<p>&#8230;<\/p>\n<h3>Analysis: <\/h3>\n<p>&#8230;<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem D. \u5c0f\u738b\u5b50\u7684\u8868\u6f14.cpp; toolbar: true; notranslate\" title=\"Problem D. \u5c0f\u738b\u5b50\u7684\u8868\u6f14.cpp\">\r\n\r\nconst int N = 1009;\r\n\r\n\r\nint x&#x5B;N], y&#x5B;N], a&#x5B;N], b&#x5B;N], W&#x5B;N];\r\nDB vx&#x5B;N], vy&#x5B;N];\r\nint n;\r\n\r\n\r\nVD L;\r\n\r\nint main(){\r\n\r\n\/*\r\n#ifdef LOCAL\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n*\/\r\n\r\n    while (scanf(&quot;%d&quot;, &amp;n) != EOF &amp;&amp; n){\r\n\r\n        REP(i, n){\r\n            RD(x&#x5B;i], y&#x5B;i], a&#x5B;i], b&#x5B;i]);\r\n            vx&#x5B;i] = DB (a&#x5B;i] - x&#x5B;i]) \/ 10;\r\n            vy&#x5B;i] = DB (b&#x5B;i] - y&#x5B;i]) \/ 10;\r\n        }\r\n\r\n        if (n &lt;= 2){\r\n            cout &lt;&lt; n &lt;&lt; endl;\r\n            continue;\r\n        }\r\n\r\n        CLR(L);\r\n\r\n        L.PB(0), L.PB(10);\r\n\r\n\r\n        REP(i, n) FOR(j, i+1, n) FOR(k, j+1, n){\r\n\r\n         \/\/   Po v1 = PO( (x&#x5B;j] + vx&#x5B;j] * t) - (x&#x5B;i] + vx&#x5B;i] * t),  (y&#x5B;j] + vy&#x5B;j] * t) - (y&#x5B;i] + vy&#x5B;i] * t)  );\r\n           \/\/ Po v2 = PO( (x&#x5B;k] + vx&#x5B;k] * t) - (x&#x5B;i] + vx&#x5B;i] * t),  (y&#x5B;k] + vy&#x5B;k] * t) - (y&#x5B;i] + vy&#x5B;i] * t)  );\r\n\r\n\r\n            \/\/(x&#x5B;j] - x&#x5B;i]) + t (vx&#x5B;j] - vx&#x5B;i])  (y&#x5B;k] - y&#x5B;i]) + t (vy&#x5B;k] - vy&#x5B;i])\r\n            \/\/    =\r\n            \/\/(x&#x5B;k] - x&#x5B;i]) + t (vx&#x5B;k] - vx&#x5B;i])  (y&#x5B;j] - y&#x5B;i]) + t (vy&#x5B;j] - vy&#x5B;i])\r\n\r\n\r\n            DB c = (x&#x5B;j] - x&#x5B;i]) * (y&#x5B;k] - y&#x5B;i]) - (x&#x5B;k] - x&#x5B;i]) *  (y&#x5B;j] - y&#x5B;i]);\r\n            DB b = (vx&#x5B;j] - vx&#x5B;i]) * (y&#x5B;k] - y&#x5B;i]) + (vy&#x5B;k] - vy&#x5B;i]) * (x&#x5B;j] - x&#x5B;i])\r\n                - ((vx&#x5B;k] - vx&#x5B;i]) * (y&#x5B;j] - y&#x5B;i]) + (vy&#x5B;j] - vy&#x5B;i]) * (x&#x5B;k] - x&#x5B;i]));\r\n            DB a = (vx&#x5B;j] - vx&#x5B;i]) * (vy&#x5B;k] - vy&#x5B;i]) - (vx&#x5B;k] - vx&#x5B;i]) * (vy&#x5B;j] - vy&#x5B;i]);\r\n\r\n\r\n            if (!sgn(a)){\r\n\r\n                if (sgn(b)){\r\n                DB t1 = (-c \/ b);\r\n                if (sgn(t1) &gt;= 0 || sgn(t1, 10) &lt;= 0){\r\n                    L.PB(t1);\r\n                }\r\n                }\r\n                continue;\r\n            }\r\n\r\n\r\n            DB delta = sqr(b) - 4 * a * c;\r\n\r\n           \/\/ cout &lt;&lt; i &lt;&lt; &quot; &quot; &lt;&lt; j &lt;&lt; &quot; &quot; &lt;&lt; k &lt;&lt; &quot; &quot; &lt;&lt; delta &lt;&lt; endl;\r\n\r\n            if (sgn(delta) &lt; 0) continue;\r\n            if (!sgn(delta)){\r\n\r\n                DB t = -b \/ (2*a);\r\n\/\/                cout &lt;&lt; t &lt;&lt; endl;\r\n                if (sgn(t) &lt; 0 || sgn(t, 10) &gt; 0) continue;\r\n\r\n                Po v1 = Po( (x&#x5B;j] + vx&#x5B;j] * t) - (x&#x5B;i] + vx&#x5B;i] * t),  (y&#x5B;j] + vy&#x5B;j] * t) - (y&#x5B;i] + vy&#x5B;i] * t)  );\r\n                Po v2 = Po( (x&#x5B;k] + vx&#x5B;k] * t) - (x&#x5B;i] + vx&#x5B;i] * t),  (y&#x5B;k] + vy&#x5B;k] * t) - (y&#x5B;i] + vy&#x5B;i] * t)  );\r\n\r\n\/*\r\n                if (sgn(det(v1, v2))){\r\n                    cout &lt;&lt; &quot;Error&quot; &lt;&lt; endl;\r\n                }\r\n                *\/\r\n            }\r\n            else {\r\n\r\n\r\n                DB t1 = (-b + sqrt(delta))  \/ (2*a);\r\n                if (sgn(t1) &gt;= 0 || sgn(t1, 10) &lt;= 0){\r\n                    L.PB(t1);\r\n                }\r\n\r\n                t1 = (-b - sqrt(delta))  \/ (2*a);\r\n                if (sgn(t1) &gt;= 0 || sgn(t1, 10) &lt;= 0){\r\n                    L.PB(t1);\r\n                }\r\n            }\r\n        }\r\n\r\n        SRT(L);\r\n        L.resize(unique(ALL(L)) - L.begin());\r\n\r\n\r\n        int ans = 2;\r\n\r\n\/\/        cout &lt;&lt; n &lt;&lt; endl;\r\n\r\n        REP(ii, SZ(L)){\r\n\r\n            DB t = L&#x5B;ii];\r\n\r\n\r\n            vector&lt;Po&gt; pp; CLR(pp);\r\n            REP(i, n){\r\n                pp.PB( Po( (x&#x5B;i] + vx&#x5B;i] * t),  (y&#x5B;i] + vy&#x5B;i] * t) ));\r\n            }\r\n\r\n            SRT(pp);\r\n\r\n            vector&lt;Po&gt; ppp = pp;\r\n\r\n\r\n            RST(W);\r\n\r\n\r\n            pp.resize( unique( ALL(pp) ) - pp.begin() );\r\n\r\n\r\n\r\n\r\n\r\n\r\n            int nn = SZ(pp);\r\n            REP(i, nn){\r\n\r\n                REP(j, n) if ( pp&#x5B;i] == ppp&#x5B;j] ) ++ W&#x5B;i];\r\n\r\n            }\r\n\r\n\r\n\r\n            REP(i, nn) FOR(j, i+1, nn){\r\n\r\n                Po v1 = pp&#x5B;j] - pp&#x5B;i];\r\n\r\n                int cnt = W&#x5B;i] + W&#x5B;j];\r\n\r\n                FOR(k, j+1, nn){\r\n\r\n                    Po v2 = pp&#x5B;k] - pp&#x5B;i];\r\n\r\n                    if (!sgn(det(v1, v2))){\r\n                        cnt += W&#x5B;k];\r\n                    }\r\n\r\n                }\r\n\r\n                checkMax(ans, cnt);\r\n            }\r\n        }\r\n\r\n        cout &lt;&lt; ans &lt;&lt; endl;\r\n\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Day 1 Brief description: &#8230; Analysis: &#8230;<\/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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[74],"tags":[24],"class_list":["post-245","post","type-post","status-publish","format-standard","hentry","category-astar","tag-24"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-3X","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/245","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=245"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}