[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 閱讀(992) 評論(0)  編輯  收藏

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


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 博客| 古浪县| 博湖县| 巧家县| 襄城县| 峨边| 遂溪县| 汉阴县| 武定县| 蓝山县| 金寨县| 政和县| 商城县| 宣化县| 台中市| 昆明市| 延吉市| 台山市| 巴里| 遂溪县| 岗巴县| 乌拉特后旗| 正定县| 四平市| 肥城市| 临沂市| 登封市| 奉贤区| 乌拉特前旗| 上高县| 嫩江县| 都兰县| 治县。| 樟树市| 怀柔区| 郴州市| 海兴县| 宜阳县| 西乡县| 海城市| 宣汉县|