• <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>

            superman

            聚精會神搞建設 一心一意謀發展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            ZOJ 1128 - Atlantis

            Posted on 2008-03-13 21:05 superman 閱讀(383) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ
              1 /* Accepted 1128 C++ 00:00.02 848K */
              2 #include <stdio.h>
              3 #include <iostream>
              4 
              5 using namespace std;
              6 
              7 template <typename T>
              8 class queue
              9 {
             10 private:
             11     int len;
             12     struct node
             13     {
             14         T item;
             15         node *next;
             16     }*front, *rear;
             17 public:
             18     queue()
             19     {
             20         len = 0;
             21         front = rear = NULL;
             22     }
             23     int size()
             24     {
             25         return len;
             26     }
             27     bool empty()
             28     {
             29         return len == 0;
             30     }
             31     void push(const T & item)
             32     {
             33         node *= new node;
             34         p -> item = item;
             35         p -> next = NULL;
             36         if(empty())
             37             front = rear = p;
             38         else
             39         {
             40             rear -> next = p;
             41             rear = p;
             42         }
             43         len++;
             44     }
             45     void pop(T & item)
             46     {
             47         node *= front;
             48         if(len == 1)
             49             front = rear = NULL;
             50         else
             51             front = front -> next;
             52         item = p -> item;
             53         delete p;
             54         len--;
             55     }
             56 };
             57 
             58 struct Rect
             59 {
             60     double x1, y1, x2, y2;
             61 };
             62 
             63 queue<Rect> rects;
             64 
             65 inline void addRect(double x1, double y1, double x2, double y2)
             66 {
             67     Rect tmp = {x1, y1, x2, y2};
             68     rects.push(tmp);
             69 }
             70 
             71 int main()
             72 {
             73     //freopen("p1128.in", "r", stdin);
             74     
             75     cout.setf(ios_base::showpoint);
             76     cout.setf(ios_base::fixed);
             77     cout.precision(2);
             78     
             79     int n, m = 1;
             80     double x1, y1, x2, y2;
             81     while((cin >> n) && n)
             82     {
             83         cin >> x1 >> y1 >> x2 >> y2;
             84         
             85         addRect(x1, y1, x2, y2);
             86         
             87         Rect tmp;
             88         for(int i = 2; i <= n; i++)
             89         {
             90             cin >> x1 >> y1 >> x2 >> y2;
             91             
             92             int k = rects.size();
             93             while(k--)
             94             {
             95                 rects.pop(tmp);
             96                 
             97                 if(x1 > tmp.x2 || x2 < tmp.x1 || y1 > tmp.y2 || y2 < tmp.y1)
             98                 {
             99                     rects.push(tmp);
            100                     continue;
            101                 }
            102                 
            103                 if(x1 >= tmp.x1 && x2 <= tmp.x2 && y1 >= tmp.y1 && y2 <= tmp.y2)
            104                     continue;
            105                 
            106                 if(x1 > tmp.x1)
            107                 {
            108                     addRect(tmp.x1, tmp.y1 , x1, tmp.y2);
            109                     tmp.x1 = x1;
            110                 }
            111                 if(x2 < tmp.x2)
            112                 {
            113                     addRect(x2, tmp.y1, tmp.x2, tmp.y2);
            114                     tmp.x2 = x2;
            115                 }
            116                 if(y1 > tmp.y1)
            117                     addRect(tmp.x1, tmp.y1, tmp.x2, y1);
            118                 if(y2 < tmp.y2)
            119                     addRect(tmp.x1, y2, tmp.x2, tmp.y2);
            120             }
            121             addRect(x1, y1, x2, y2);
            122         }
            123         double ans = 0.00000000;
            124         while(rects.empty() == false)
            125         {
            126             rects.pop(tmp);
            127             ans += (tmp.x2 - tmp.x1) * (tmp.y2 - tmp.y1);
            128         }
            129         cout << "Test case #" << m++ << endl;
            130         cout << "Total explored area: ";
            131         cout << ans << endl;
            132         cout << endl;
            133     }
            134     
            135     return 0;
            136 }
            137 
            久久精品国产日本波多野结衣| 99久久人妻无码精品系列蜜桃| 国产亚洲美女精品久久久| 色88久久久久高潮综合影院| 日本免费久久久久久久网站| 亚洲人成无码久久电影网站| 国产精品美女久久久久久2018 | 久久夜色精品国产欧美乱| 色婷婷综合久久久久中文| 伊人热人久久中文字幕| 一本久久免费视频| 欧美久久综合性欧美| 国内精品伊人久久久久777| 亚洲国产精品久久久久婷婷老年| 免费久久人人爽人人爽av| 日韩精品国产自在久久现线拍| 久久精品国产日本波多野结衣 | 国产精品岛国久久久久| 欧美午夜精品久久久久久浪潮| 久久亚洲中文字幕精品有坂深雪| 欧美性大战久久久久久| 国产亚州精品女人久久久久久| 久久99精品久久久久久动态图| 一级a性色生活片久久无少妇一级婬片免费放 | 久久精品国产亚洲一区二区| 久久亚洲国产成人影院网站| 7国产欧美日韩综合天堂中文久久久久 | 精品99久久aaa一级毛片| 粉嫩小泬无遮挡久久久久久| 久久强奷乱码老熟女网站| 久久综合成人网| 久久久久无码精品| 亚洲AV伊人久久青青草原| 人妻无码精品久久亚瑟影视| 久久伊人五月天论坛| 日本精品久久久久影院日本| 久久er国产精品免费观看8| 久久久久亚洲精品男人的天堂| 99热热久久这里只有精品68| 精品无码人妻久久久久久| 久久国产午夜精品一区二区三区|