• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 74,  comments - 33,  trackbacks - 0
            City Horizon
            Time Limit: 2000MS Memory Limit: 65536K
            Total Submissions: 4976 Accepted: 1195

            Description

            Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the beautiful silhouettes formed by the rectangular buildings.

            The entire horizon is represented by a number line with N (1 ≤ N ≤ 40,000) buildings. Building i's silhouette has a base that spans locations Ai through Bi along the horizon (1 ≤ Ai < Bi ≤ 1,000,000,000) and has height Hi (1 ≤ Hi ≤ 1,000,000,000). Determine the area, in square units, of the aggregate silhouette formed by all N buildings.

            Input

            Line 1: A single integer: N
            Lines 2..N+1: Input line i+1 describes building i with three space-separated integers: Ai, Bi, and Hi

            Output

            Line 1: The total area, in square units, of the silhouettes formed by all N buildings

            Sample Input

            4
            2 5 1
            9 10 4
            6 8 2
            4 6 3

            Sample Output

            16

            Hint

            The first building overlaps with the fourth building for an area of 1 square unit, so the total area is just 3*1 + 1*4 + 2*2 + 2*3 - 1 = 16.

            Source


            USACO 2007 Open Silver

            這道題目屬于區間覆蓋,和count colour那一道題目屬于同一類型,我就偷懶了,就直接把那道題的代碼直接copy過來,
            沒想到在改的時候,多刪了一句話導致TLE了20+次,很不happy
            主要思路代碼如下:
            void?Build(int?now,int?l,int?r){
            ????ST[now].l
            =l,ST[now].r=r,ST[now].h=0,ST[now].mark=true;
            ????
            if(l+1>=r)return;
            ????
            int?mid=(l+r)>>1;
            ????Build(
            2*now,l,mid);
            ????Build(
            2*now+1,mid,r);????
            ????
            return?;
            }

            void?insert(int?now,int?l,int?r,int?h){????
            ????
            if(ST[now].mark&&ST[now].h>h)return;
            ????
            if(ST[now].mark&&ST[now].l==l&&ST[now].r==r){
            ????????ST[now].h
            =h;return?;
            ????}
            ????
            ????
            if(ST[now].mark&&ST[now].l+1<ST[now].r){
            ????????ST[
            2*now].h=ST[2*now+1].h=ST[now].h;
            ????????ST[
            2*now].mark=ST[2*now+1].mark=true;
            ????????ST[now].mark
            =false;
            ????}

            ????
            int?mid=(ST[now].l+ST[now].r)>>1;
            ????
            if(l>=mid)insert(2*now+1,l,r,h);
            ????
            else?if(r<=mid)insert(2*now,l,r,h);
            ????
            else?{????
            ????????insert(
            2*now,l,mid,h);
            ????????insert(
            2*now+1,mid,r,h);
            ????}
            ????
            ????
            return?;
            }

            posted on 2009-04-08 14:57 KNIGHT 閱讀(116) 評論(0)  編輯 收藏 引用
            <2009年1月>
            28293031123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久婷婷是五月综合色狠狠| 久久综合狠狠综合久久综合88 | 综合久久给合久久狠狠狠97色 | 久久久久人妻精品一区| 久久久久99精品成人片直播| 久久久久中文字幕| 色诱久久久久综合网ywww| 亚洲综合久久综合激情久久| 久久天天婷婷五月俺也去| 91精品国产综合久久久久久| 中文字幕无码久久久| 国产成人久久777777| 精品蜜臀久久久久99网站| 久久无码精品一区二区三区| 久久综合视频网| 狠狠色噜噜狠狠狠狠狠色综合久久| 久久久噜噜噜久久| 国产成人无码精品久久久免费| 久久亚洲国产精品成人AV秋霞| 国产成人精品久久一区二区三区 | 久久国产免费观看精品| 亚洲国产精品成人AV无码久久综合影院| 久久婷婷五月综合97色一本一本 | AV无码久久久久不卡蜜桃| 丰满少妇人妻久久久久久4| 久久夜色精品国产噜噜噜亚洲AV| 日日狠狠久久偷偷色综合0| 久久久久九九精品影院| 国产精品久久久99| 久久久久99精品成人片| 91久久香蕉国产熟女线看| 国产69精品久久久久99| 欧美精品一区二区精品久久 | 久久国产免费观看精品3| 日韩精品久久久久久久电影蜜臀| 国产成人综合久久精品红| 婷婷国产天堂久久综合五月| 久久综合鬼色88久久精品综合自在自线噜噜 | 国产亚洲美女精品久久久| 精品久久久久久久久久久久久久久| 久久久久四虎国产精品|