[NKU]sweet @ Google && TopCoder && CodeForces

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            33 Posts :: 1 Stories :: 15 Comments :: 0 Trackbacks
          題意:給一個方格的1E9*1E9的地圖,以及若干炸彈,每個炸彈的功能是將某行/某列的所有東西消滅,求若干炸彈依次下去,每次消滅了多少東西……
          STL硬搞即可……
           1 #include <cstdio>
           2 #include <set>
           3 #include <map>
           4 
           5 using namespace std;
           6 typedef multiset<int> sint;
           7 typedef map<int, multiset<int> > line;
           8 
           9 line x;
          10 line y;
          11 
          12 int bomb(line &x, line &y, int pos) {
          13     int ret = x[pos].size();
          14     for (sint::iterator ii = x[pos].begin();
          15             ii != x[pos].end();
          16             ii++) {
          17         y[*ii].erase(pos);
          18     }
          19     x[pos].clear();
          20     return ret;
          21 }
          22 
          23 int main() {
          24     for (;;) {
          25         int n,m;
          26         scanf("%d%d",&n,&m);
          27         if (n + m == 0break;
          28         x.clear();
          29         y.clear();
          30         while (n--) {
          31             int tx,ty;
          32             scanf("%d%d",&tx,&ty);
          33             x[tx].insert(ty);
          34             y[ty].insert(tx);
          35         }
          36         while (m--) {
          37             int ctrl,pos;
          38             scanf("%d%d",&ctrl,&pos);
          39             printf("%d\n",ctrl == 0 ? bomb(x,y,pos) : bomb(y,x,pos));
          40         }
          41         printf("\n");
          42     }
          43     return 0;
          44 }
          posted on 2011-09-10 17:46 sweetsc 閱讀(982) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 贡觉县| 山阳县| 雅安市| 黔西县| 前郭尔| 大英县| 滨州市| 元阳县| 乌兰察布市| 江西省| 台江县| 武陟县| 安义县| 广州市| 江达县| 博客| 阳高县| 德化县| 洞头县| 济宁市| 封丘县| 吉安县| 民县| 宿松县| 承德市| 息烽县| 修文县| 泰宁县| 赣榆县| 平顺县| 东兰县| 江都市| 永平县| 新密市| 滦平县| 大余县| 北海市| 望奎县| 商城县| 汉阴县| 两当县|