{"id":335,"date":"2017-12-25T19:49:45","date_gmt":"2017-12-25T11:49:45","guid":{"rendered":"http:\/\/kylelv.com\/?p=335"},"modified":"2017-12-25T19:49:45","modified_gmt":"2017-12-25T11:49:45","slug":"bzoj-4311-%e5%90%91%e9%87%8f-%e7%ba%bf%e6%ae%b5%e6%a0%91%e5%88%86%e6%b2%bb%e5%87%b8%e5%8c%85","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=335","title":{"rendered":"bzoj 4311: \u5411\u91cf  &#8212; \u7ebf\u6bb5\u6811\u5206\u6cbb+\u51f8\u5305"},"content":{"rendered":"<p><center><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef6074ad7\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef6074ad7\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#4311_%E5%90%91%E9%87%8F\" title=\"4311: \u5411\u91cf\">4311: \u5411\u91cf<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#HINT\" title=\"HINT\">HINT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.kylelv.com\/?p=335\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"4311_%E5%90%91%E9%87%8F\"><\/span>4311: \u5411\u91cf<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a0<\/span>20 Sec\u00a0\u00a0<span class=\"green\">Memory Limit:\u00a0<\/span>512 MB<\/center><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u4f60\u8981\u7ef4\u62a4\u4e00\u4e2a\u5411\u91cf\u96c6\u5408\uff0c\u652f\u6301\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/div>\n<div>1.\u63d2\u5165\u4e00\u4e2a\u5411\u91cf(x,y)<\/div>\n<div>2.\u5220\u9664\u63d2\u5165\u7684\u7b2ci\u4e2a\u5411\u91cf<\/div>\n<div>3.\u67e5\u8be2\u5f53\u524d\u96c6\u5408\u4e0e(x,y)\u70b9\u79ef\u7684\u6700\u5927\u503c\u662f\u591a\u5c11\u3002\u5982\u679c\u5f53\u524d\u662f\u7a7a\u96c6\u8f93\u51fa0<\/div>\n<div><\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u7b2c\u4e00\u884c\u8f93\u5165\u4e00\u4e2a\u6574\u6570n\uff0c\u8868\u793a\u64cd\u4f5c\u4e2a\u6570<\/div>\n<div>\u63a5\u4e0b\u6765n\u884c\uff0c\u6bcf\u884c\u5148\u662f\u4e00\u4e2a\u6574\u6570t\u8868\u793a\u7c7b\u578b\uff0c\u5982\u679ct=1\uff0c\u8f93\u5165\u5411\u91cf<\/div>\n<div>(x,y)\uff1b\u5982\u679ct=2\uff0c\u8f93\u5165id\u8868\u793a\u5220\u9664\u7b2cid\u4e2a\u5411\u91cf\uff1b\u5426\u5219\u8f93\u5165(x,y)\uff0c\u67e5\u8be2<\/div>\n<div>\u4e0e\u5411\u91cf(x,y)\u70b9\u79ef\u6700\u5927\u503c\u662f\u591a\u5c11\u3002<\/div>\n<div>\u4fdd\u8bc1\u4e00\u4e2a\u5411\u91cf\u53ea\u4f1a\u88ab\u5220\u9664\u4e00\u6b21\uff0c\u4e0d\u4f1a\u5220\u6ca1\u6709\u63d2\u5165\u8fc7\u7684\u5411\u91cf<\/div>\n<div><\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u5bf9\u4e8e\u6bcf\u6761t=3\u7684\u8be2\u95ee\uff0c\u8f93\u51fa\u4e00\u4e2a\u7b54\u6848<\/div>\n<div><\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">5<br \/>\n1 3 3<br \/>\n1 1 4<br \/>\n3 3 3<br \/>\n2 1<br \/>\n3 3 3<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\">18<br \/>\n15<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>n&lt;=200000\u00a01&lt;=x,y&lt;=10^6<\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u59dc\u5927\u7237\u8bb2\u5b8c\uff0c\u611f\u89c9\u9898\u89e3\u597d\u5de7\u5999<\/p>\n<p>\u9996\u5148\u6211\u4eec\u5bf9\u4e8e\u5220\u9664\u64cd\u4f5c\u53ef\u4ee5\u7528\u7ebf\u6bb5\u6811\u5206\u6cbb\u6765\u5b9e\u73b0<\/p>\n<p>\u7136\u540e\u95ee\u9898\u7684\u600e\u4e48\u67e5\u8be2<\/p>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u5411\u91cf\u7684\u6700\u4f18\u503c\uff0c\u662f\u5728\u4e0e\u8be5\u5411\u91cf\u5782\u76f4\u7684\u7ebf\u4e2d\uff0c\u5728\u8ddd\u79bb\u6700\u8fdc\u7684\u7ebf\u4e0a\u7684\u70b9\u7684\u70b9\u79ef<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u7ef4\u62a4\u51fa\u51f8\u5305\uff0c\u7136\u540e\u5728\u51f8\u5305\u4e0a\u4e09\u5206<\/p>\n<p>\u90a3\u4e48\uff0c\u6211\u4eec\u7b2c\u4e00\u79cd\u60f3\u6cd5\u662f\u7ebf\u6bb5\u6811\u5206\u6cbb\u65f6\u5408\u5e76\u51f8\u5305\uff0c\u6216\u5e73\u8861\u6811\u7ef4\u62a4\u51f8\u5305\uff1f<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2a\u592a\u96be\u4e86\uff0c\u4f5c\u4e3a\u849f\u84bb\u6211\u5f53\u7136\u4e0d\u4f1a\u4e86qaq<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5728\u7ebf\u6bb5\u6811\u4e0a\u6bcf\u4e00\u4e2a\u70b9\u7ef4\u62a4\u4e00\u4e2a\u51f8\u5305\uff0c\u5728\u67e5\u8be2\u7684\u65f6\u5019\u53bb\u627e\u4ece\u6839\u5230\u53f6\u5b50\u8282\u70b9\u8def\u5f84\u4e0a\u6bcf\u4e00\u4e2a\u7684\u6700\u4f18\u503c\u53bb\u53d6\u4e00\u4e2amax\u5c31\u597d\u5566<\/p>\n<p>\u6700\u540e\u65f6\u95f4\u590d\u6742\u5ea6O(nlog\u00b2n)<\/p>\n<pre class=\"lang:c++ decode:true \">#include&lt;map&gt;\r\n#include&lt;cmath&gt;\r\n#include&lt;queue&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;vector&gt;\r\n#include&lt;cstring&gt;\r\n#include&lt;iostream&gt;\r\n#include&lt;algorithm&gt;\r\nusing namespace std;\r\n#define inf 1000000007\r\n#define ll long long\r\n#define N 200010\r\ninline int rd()\r\n{\r\n\tint x=0,f=1;char ch=getchar();\r\n\twhile(ch&lt;'0'||ch&gt;'9'){if(ch=='-')f=-1;ch=getchar();}\r\n\twhile(ch&gt;='0'&amp;&amp;ch&lt;='9'){x=x*10+ch-'0';ch=getchar();}\r\n\treturn x*f;\r\n}\r\nstruct qaz{int x,y,l,r;}e[N],ak[N]; \r\nll cj(int x,int y,int xx,int yy){return (ll)x*yy-(ll)y*xx;}\r\nint n,tot,ta,xmn,ymn;\r\nbool cmp(qaz a,qaz b)\r\n{\r\n\treturn cj(a.x-xmn,a.y-ymn,b.x-xmn,b.y-ymn)&gt;0;\r\n}\r\nvector&lt;int&gt;st[N&lt;&lt;2],tb[N&lt;&lt;2];\r\n#define ls p&lt;&lt;1\r\n#define rs p&lt;&lt;1|1\r\nvoid add(int p,int l,int r,int L,int R,int x)\r\n{\r\n\tif(l==L&amp;&amp;r==R){st[p].push_back(x);return;}\r\n\tint mid=l+r&gt;&gt;1;\r\n\tif(R&lt;=mid) add(ls,l,mid,L,R,x);\r\n\telse if(L&gt;mid) add(rs,mid+1,r,L,R,x);\r\n\telse add(ls,l,mid,L,mid,x),add(rs,mid+1,r,mid+1,R,x);\r\n}\r\nint q[N];\r\nbool ck(int p,int a,int b,int c)\r\n{\r\n\tint X1,Y1,X2,Y2;\r\n\tX1=e[st[p][b]].x-e[st[p][c]].x;\r\n\tX2=e[st[p][a]].x-e[st[p][c]].x;\r\n\tY1=e[st[p][b]].y-e[st[p][c]].y;\r\n\tY2=e[st[p][a]].y-e[st[p][c]].y;\r\n\treturn cj(X1,Y1,X2,Y2)&lt;0;\r\n}\r\nvoid build(int p,int l,int r)\r\n{\r\n\tif(st[p].size()&lt;=2) tb[p]=st[p];\r\n\telse \r\n\t{\r\n\t\tq[0]=0;q[1]=1;int r=1;\r\n\t\tst[p].push_back(st[p][0]);\r\n\t\tfor(int i=2;i&lt;st[p].size();i++)\r\n\t\t{\r\n\t\t\twhile(r&amp;&amp;ck(p,i,q[r],q[r-1])) r--;\r\n\t\t\tq[++r]=i;\r\n\t\t}\r\n\t\tfor(int i=0;i&lt;=r;i++) tb[p].push_back(st[p][q[i]]);\r\n\t}\r\n\tif(l==r) return;\r\n\tint mid=l+r&gt;&gt;1;\r\n\tbuild(ls,l,mid);\r\n\tbuild(rs,mid+1,r);\r\n}\r\nll ans;\r\nll Dot(qaz a,qaz b){return (ll)a.x*b.x+(ll)a.y*b.y;}\r\nvoid fd(int p,int l,int r,qaz c)\r\n{\r\n\tint L=0,R=tb[p].size()-1,m1,m2;\r\n\twhile(L+3&lt;=R)\r\n\t{\r\n\t\tm1=(L+L+R)\/3;m2=(L+R+R)\/3;\r\n\t\tif(Dot(e[tb[p][m1]],c)&lt;=Dot(e[tb[p][m2]],c)) L=m1;\r\n\t\telse R=m2;\r\n\t}\r\n\tfor(int i=L;i&lt;=R;++i)ans=max(ans,Dot(e[tb[p][i]],c));\r\n\tif(l==r) return;\r\n\tint mid=l+r&gt;&gt;1;\r\n\tif(c.l&lt;=mid) fd(ls,l,mid,c);\r\n\telse fd(rs,mid+1,r,c);\r\n}\r\nvoid ask(int x)\r\n{\r\n\tans=0;\r\n\tfd(1,1,n,ak[x]);\r\n\tprintf(\"%lld\\n\",ans);\r\n}\r\nint main()\r\n{\r\n\tn=rd();\r\n\tint x,y,op;\r\n\tfor(int i=1;i&lt;=n;i++)\r\n\t{\r\n\t\top=rd();x=rd();\r\n\t\tif(op^2) y=rd();\r\n\t\tif(op==1)\r\n\t\t{\r\n\t\t\te[++tot]=(qaz){x,y,i,n};\r\n\t\t\txmn=min(x,xmn);\r\n\t\t\tymn=min(y,ymn);\r\n\t\t}\r\n\t\telse if(op==2) e[x].r=i-1;\r\n\t\telse ak[++ta]=(qaz){x,y,i,0};\r\n\t}\r\n\tsort(e+1,e+tot+1,cmp);\r\n\tfor(int i=1;i&lt;=tot;i++)\r\n\t\tadd(1,1,n,e[i].l,e[i].r,i);\r\n\tbuild(1,1,n);\r\n\tfor(int i=1;i&lt;=ta;i++) ask(i);\r\n\treturn 0;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>4311: \u5411\u91cf Time Limit:\u00a020 Sec\u00a0\u00a0Memory Limit:\u00a0512 MB Descr [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[28,8,27],"class_list":["post-335","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-28","tag-8","tag-27"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/335\/revisions"}],"predecessor-version":[{"id":336,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/335\/revisions\/336"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}