{"id":171,"date":"2010-03-20T17:16:00","date_gmt":"2010-03-20T09:16:00","guid":{"rendered":"http:\/\/localhost\/?p=171"},"modified":"2010-03-20T17:16:00","modified_gmt":"2010-03-20T09:16:00","slug":"baltic2001mars_maps","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=171","title":{"rendered":"[Baltic2001]Mars Maps"},"content":{"rendered":"\n<p>[Baltic2001]Mars Maps<\/p>\n<p>Time Limit:5000MS&#160; Memory Limit:65536K<br \/>Total Submit:19 Accepted:7 <br \/>Case Time Limit:1000MS<\/p>\n<p><strong>Description <\/strong><\/p>\n<p> \u7ed9\u51faN\u4e2a\u77e9\u5f62,N&lt;=10000.\u5176\u5750\u6807\u4e0d\u8d85\u8fc710^9.\u6c42\u5176\u9762\u79ef\u5e76<\/p>\n<p><strong>Input <\/strong><\/p>\n<p> \u5148\u7ed9\u51fa\u4e00\u4e2a\u6570\u5b57N,\u4ee3\u8868\u6709N\u4e2a\u77e9\u5f62. <br \/>\u63a5\u4e0b\u6765N\u884c,\u6bcf\u884c\u56db\u4e2a\u6570,\u4ee3\u8868\u77e9\u5f62\u7684\u5750\u6807.<\/p>\n<p><strong>Output <\/strong><\/p>\n<p> \u8f93\u51fa\u9762\u79ef\u5e76<\/p>\n<p><strong>Sample Input <\/strong><\/p>\n<p>2<br \/>10 10 20 20<br \/>15 15 25 30<\/p>\n<p><strong>Sample Output <\/strong><\/p>\n<p>225<\/p>\n<p><strong>Source <\/strong><\/p>\n<p>\u8fd9\u662f\u5f88\u7ecf\u5178\u7684\u9898\u76ee\u4e86\u3002\u79bb\u6563\u5316\u4e4b\u540e\u7528\u626b\u63cf\u7ebf\u626b\u8fc7\u53bb\uff0c\u7528\u7ebf\u6bb5\u6811\u7ef4\u62a4\u5f53\u524d\u4e0e\u626b\u63cf\u7ebf\u76f8\u4ea4\u7684\u77e9\u5f62\u7684\u957f\u5ea6\u5e76\u3002\u5c31\u53ef\u4ee5\u964d\u7ef4\u4e86\u3002\u3002<br \/>\u4e0d\u8fc7\u6211\u60b2\u5267\u4e86\u3002\u6570\u7ec4\u5f00\u5c0f\u4e86\u56e7\u3002\u3002WA\u4e86\u597d\u51e0\u6b21\u3002\u3002<br \/>Code\uff1a<br \/>#include&lt;cstdio&gt;<br \/>#include&lt;iostream&gt;<br \/>#include&lt;algorithm&gt;<br \/>#include&lt;string&gt;<br \/>#include&lt;vector&gt;<br \/>#include&lt;cstring&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>#define pb push_back<br \/>using namespace std;<br \/>const int inf=~0U&gt;&gt;1,maxn=10000;<br \/>int n;<br \/>int Y[maxn*2];<br \/>struct Event<br \/>{<br \/>    int x,l,r,d;<br \/>    Event(){}<br \/>    Event(int _x,int _l,int _r,int _d):x(_x),l(_l),r(_r),d(_d){}<br \/>    bool operator&lt;(const Event&amp;o)const<br \/>    {<br \/>        return x&lt;o.x;<br \/>    }<br \/>}E[maxn*2];<br \/>void Init()<br \/>{<br \/>    scanf(&quot;%d&quot;,&amp;n);<br \/>    int x[2],y[2],cnt=0;<br \/>    rep(i,n)<br \/>    {<br \/>        rep(j,2)scanf(&quot;%d %d&quot;,x+j,y+j),Y[cnt++]=y[j];<br \/>        E[2*i]=Event(x[0],y[0],y[1],1);<br \/>        E[2*i+1]=Event(x[1],y[0],y[1],-1);<br \/>    }<br \/>}<br \/>int Cover[8*maxn]={0},Sum[8*maxn]={0};<br \/>void change(int t,int l,int r,int a,int b,int d)<br \/>{<br \/>    if(a&gt;=r||b&lt;=l) return;<br \/>    if(a&lt;=l&amp;&amp;b&gt;=r)Cover[t]+=d;<br \/>    else change(t*2,l,(l+r)\/2,a,b,d),change(t*2+1,(l+r)\/2,r,a,b,d);<br \/>    if(Cover[t]&gt;0)<br \/>        Sum[t]=Y[r]-Y[l];<br \/>    else<br \/>        Sum[t]=(l+1==r)?0:(Sum[t*2]+Sum[t*2+1]);<br \/>}<br \/>void Work()<br \/>{<br \/>    n&lt;&lt;=1;<br \/>    sort(Y,Y+n);<br \/>    rep(i,n)<br \/>    {<br \/>        E[i].l=lower_bound(Y,Y+n,E[i].l)-Y;<br \/>        E[i].r=lower_bound(Y,Y+n,E[i].r)-Y;<br \/>    }<br \/>    sort(E,E+n);int last=E[0].x;long long Ans=0;<br \/>    rep(i,n)<br \/>    {<br \/>        Event now=E[i];<br \/>        if(now.x!=last)<br \/>        {<br \/>            Ans+=(long long)(Sum[1])*(now.x-last);<br \/>            last=now.x;<br \/>        }<br \/>        change(1,0,n-1,now.l,now.r,now.d);<br \/>    }<br \/>    cout&lt;&lt;Ans&lt;&lt;endl;<br \/>}<br \/>int main()<br \/>{<br \/>    \/\/freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    Init();<br \/>    Work();<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Baltic2001]Mars Maps Time Limit:5000MS&#160; Memory Limit:65536KTotal Submit:19 Accepted:7 Case Time Limit:1000MS Description \u7ed9\u51faN\u4e2a\u77e9\u5f62,N&lt;=10000.\u5176\u5750\u6807\u4e0d\u8d85\u8fc710^9.\u6c42\u5176\u9762\u79ef\u5e76 Input \u5148\u7ed9\u51fa\u4e00\u4e2a\u6570\u5b57N,\u4ee3\u8868\u6709N\u4e2a\u77e9\u5f62. \u63a5\u4e0b\u6765N\u884c,\u6bcf\u884c\u56db\u4e2a\u6570,\u4ee3\u8868\u77e9\u5f62\u7684\u5750\u6807. Output \u8f93\u51fa\u9762\u79ef\u5e76 Sample Input 210 10 20 2015 15 25 30 Sample Output 225 Source \u8fd9\u662f\u5f88\u7ecf\u5178\u7684\u9898\u76ee\u4e86\u3002\u79bb\u6563\u5316\u4e4b\u540e\u7528\u626b\u63cf\u7ebf\u626b\u8fc7\u53bb\uff0c\u7528\u7ebf\u6bb5\u6811\u7ef4\u62a4\u5f53\u524d\u4e0e\u626b\u63cf\u7ebf\u76f8\u4ea4\u7684\u77e9\u5f62\u7684\u957f\u5ea6\u5e76\u3002\u5c31\u53ef\u4ee5\u964d\u7ef4\u4e86\u3002\u3002\u4e0d\u8fc7\u6211\u60b2\u5267\u4e86\u3002\u6570\u7ec4\u5f00\u5c0f\u4e86\u56e7\u3002\u3002WA\u4e86\u597d\u51e0\u6b21\u3002\u3002Code\uff1a#include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)#define pb push_backusing namespace std;const int inf=~0U&gt;&gt;1,maxn=10000;int n;int Y[maxn*2];struct Event{ int x,l,r,d; Event(){} Event(int _x,int _l,int _r,int _d):x(_x),l(_l),r(_r),d(_d){} bool operator&lt;(const Event&amp;o)const [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/171"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}