青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋    

 

題目地址:

     http://acm.hdu.edu.cn/showproblem.php?pid=1892 

題目描述:

代碼
See you~

Time Limit: 
5000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 
921    Accepted Submission(s): 291


Problem Description
Now I am leaving hust acm. In the past two and half years, I learned so many knowledge about Algorithm and Programming, and I met so many good friends. I want to say sorry to Mr, Yin, I must leave now 
~~>.<~~. I am very sorry, we could not advanced to the World Finals last year. 
When coming into our training room, a lot of books are 
in my eyes. And every time the books are moving from one place to another one. Now give you the position of the books at the early of the day. And the moving information of the books the day, your work is to tell me how many books are stayed in some rectangles. 
To make the problem easier, we divide the room into different grids and a book can only stayed 
in one grid. The length and the width of the room are less than 1000. I can move one book from one position to another position, take away one book from a position or bring in one book and put it on one position. 
 

Input
In the first line of the input file there 
is an Integer T(1<=T<=10), which means the number of test cases in the input file. Then N test cases are followed. 
For each test 
casein the first line there is an Integer Q(1<Q<=100,000), means the queries of the case. Then followed by Q queries. 
There are 
4 kind of queries, sum, add, delete and move. 
For example: 
S x1 y1 x2 y2 means you should tell me the total books of the rectangle used (x1,y1)
-(x2,y2) as the diagonal, including the two points. 
A x1 y1 n1 means I put n1 books on the position (x1,y1) 
D x1 y1 n1 means I move away n1 books on the position (x1,y1), 
if less than n1 books at that position, move away all of them. 
M x1 y1 x2 y2 n1 means you move n1 books from (x1,y1) to (x2,y2), 
if less than n1 books at that position, move away all of them. 
Make sure that at first, there 
is one book on every grid and 0<=x1,y1,x2,y2<=1000,1<=n1<=100
 

Output
At the beginning of each 
case, output "Case X:" where X is the index of the test case, then followed by the "S" queries. 
For each 
"S" query, just print out the total number of books in that area. 
 

Sample Input
2
3
1 1 1 1
1 1 2
1 1 1 1
3
1 1 1 1
1 1 2
1 1 1 2
 

Sample Output
Case 
1:
1
3
Case 
2:
1
4

 

題目分析 :

   一道二維樹狀數(shù)組 的裸題, 只是需要對(duì)坐標(biāo)做些處理即可, 另外, 初始化的時(shí)候 原來(lái) com[i][j] = lowbit (i) * lowbit (j);      WA 好多次, 直接用的modify(i,j,1)

好了,  直接代碼吧, 代碼過(guò)長(zhǎng), 內(nèi)存多了一點(diǎn)點(diǎn) , HDU 第二     

2HUT-MiYu156MS8044K3172BC++

 

 /*

MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋

          http://www.cnblog.com/MiYu

Author By : MiYu

Test      : 1

Program   : 1892

*/


#include <iostream>

#include <cmath>

#include <algorithm>

using namespace std;

#define lowbit(x) (x&(-x))

int T,N;

const int MAX = 1001;

int mat[1002][1002];

int com[1002][1002];

void modify ( int x,int y, int n )

{

     while ( x <= MAX ){

           int t = y;

           while ( t <= MAX ){

                  com[x][t] += n;

                  t += lowbit(t); 

           } 

           x += lowbit(x);

     } 

}

int quy ( int x, int y )

{

     int sum = 0;

     while ( x > 0 ){

           int t = y;

           while ( t > 0 ){

                  sum += com[x][t];

                  t -= lowbit(t); 

           } 

           x -= lowbit(x);

     } 

     return sum; 

}

inline bool scan_d(int &num)

{

        char in;bool IsN=false;

        in=getchar();

        if(in==EOF) return false;

        while(in!='-'&&(in<'0'||in>'9')) in=getchar();

        if(in=='-'){ IsN=true;num=0;}

        else num=in-'0';

        while(in=getchar(),in>='0'&&in<='9'){

                num*=10,num+=in-'0';

        }

        if(IsN) num=-num;

        return true;

}

int main ()

{

      scan_d(T);{

            int ca = 1;

            while ( T -- ){

                   printf ( "Case %d:\n",ca++ );

                   scan_d(N);  char s[5];  int a,b,x,y,m,res,maxx,maxy,minx,miny;

                   for ( int i = 1; i <= MAX; ++ i )

                        for ( int j = 1; j <= MAX; ++ j )

                              com[i][j] = lowbit(i) * lowbit(j), mat[i][j] = 1;

                   for ( int i = 1; i <= N;  ++ i ){

                         scanf ( "%s",s );

                         switch ( s[0] ){

                                case 'S' : scan_d(a);scan_d(b);scan_d(x);scan_d(y); minx = min ( a,x );miny=min(b,y);maxx=max(a,x)+1;maxy=max(b,y)+1;

                                           res = 0;  res += quy( maxx,maxy ); res -= quy (maxx,miny); res -= quy(minx,maxy); res += quy(minx,miny);

                                           printf ( "%d\n",res ); break;   

                                case 'A' : scan_d(x);scan_d(y);scan_d(a);x++;y++; modify ( x,y,a ); mat[x][y] += a; break;

                                case 'D' : scan_d(x);scan_d(y);scan_d(a);x++;y++; if ( mat[x][y] >= a ) { modify ( x,y,-a ); mat[x][y] -= a; }

                                                                        else  { modify ( x,y,-mat[x][y] ); mat[x][y] = 0; } break;   

                                case 'M' : scan_d(a);scan_d(b);scan_d(x);scan_d(y);scan_d(m);a++;b++;x++;y++; if ( mat[a][b] >= m )

                                                                                  {  mat[a][b] -= m; mat[x][y] += m; modify ( a,b,-m ); modify ( x,y,m ); }

                                                                                  else { modify ( a,b,-mat[a][b] ); modify ( x,y,mat[a][b] ); mat[x][y] += mat[a][b]; mat[a][b] = 0; } break;

                         }

                   } 

            } 

    }

    return 0;

}


 

 

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲——在线| 亚洲欧美日韩精品久久亚洲区| 久久精品噜噜噜成人av农村| 亚洲午夜三级在线| 在线视频欧美精品| 一区二区欧美在线观看| 妖精成人www高清在线观看| 亚洲精品一区在线观看香蕉| 亚洲日本va在线观看| 欧美在线看片| 久久久最新网址| 99re6热在线精品视频播放速度| 欧美激情第六页| 亚洲欧美日韩国产| 亚洲高清在线精品| 欧美久久九九| 亚洲黄色性网站| 欧美日韩一区在线视频| 日韩香蕉视频| 亚洲乱码视频| 香蕉亚洲视频| 久久在线免费观看| 欧美视频在线不卡| 激情亚洲一区二区三区四区| av不卡在线观看| 午夜伦理片一区| 欧美激情bt| 亚洲女人天堂成人av在线| 久久久久久久久久久久久9999| 欧美日韩国产999| 在线高清一区| 欧美亚洲综合久久| 亚洲韩国青草视频| 欧美在线播放一区| 欧美日韩国产亚洲一区| 国语对白精品一区二区| 亚洲精品一区二| 久久久久综合网| 日韩午夜三级在线| 欧美精品久久天天躁| 一区二区视频在线观看| 亚洲一区日韩在线| 欧美高清在线一区二区| 欧美一区二区成人6969| 欧美多人爱爱视频网站| 国产综合色产在线精品| 亚洲欧美日韩国产成人| 91久久精品国产| 玖玖精品视频| 亚洲电影在线免费观看| 久久av一区| 亚洲自拍都市欧美小说| 欧美日韩福利| 亚洲一区二区三区精品视频| 亚洲三级影院| 欧美**人妖| 伊人久久久大香线蕉综合直播 | 艳女tv在线观看国产一区| 久久精品一区中文字幕| 亚洲一区在线观看视频| 国产精品久久二区| 亚洲中无吗在线| 亚洲高清免费视频| 男人的天堂亚洲在线| 亚洲免费观看高清在线观看 | 欧美日韩在线一区| 在线看不卡av| 欧美大片一区二区| 欧美风情在线观看| 中日韩视频在线观看| 亚洲视频在线一区| 国产日韩精品视频一区二区三区| 久久er99精品| 久久深夜福利免费观看| 亚洲美女在线一区| 99riav1国产精品视频| 欧美天堂亚洲电影院在线播放| 在线综合+亚洲+欧美中文字幕| 亚洲久久视频| 欧美午夜一区二区三区免费大片| 亚洲欧美成人| 久久精品三级| 99re视频这里只有精品| 亚洲影视综合| 亚洲国产高清一区| 日韩一级欧洲| 国产视频亚洲| 麻豆久久久9性大片| 欧美jjzz| 亚洲伊人第一页| 欧美一区观看| 亚洲国产另类 国产精品国产免费| 亚洲精品日韩激情在线电影| 国产精品久久久一区二区| 久久久精品一品道一区| 欧美国产第二页| 欧美中文在线免费| 欧美激情麻豆| 久久精品国产欧美亚洲人人爽| 麻豆久久精品| 久久精品一二三| 欧美日韩免费观看一区二区三区| 先锋a资源在线看亚洲| 久久久久久久综合| 亚洲一区二区高清视频| 久久激情婷婷| 亚洲欧美中日韩| 欧美国产高清| 男同欧美伦乱| 国产欧美日韩精品丝袜高跟鞋| 欧美国产日本在线| 国产日韩精品一区二区浪潮av | 亚洲欧美日本国产有色| 亚洲第一页在线| 亚洲欧美日本精品| 亚洲午夜一区二区三区| 麻豆成人综合网| 久久久久亚洲综合| 国产免费观看久久黄| 日韩亚洲欧美中文三级| 亚洲国产欧美另类丝袜| 欧美在线观看网址综合| 亚洲综合色婷婷| 欧美日韩精品一区二区三区四区| 欧美69wwwcom| 一区在线影院| 欧美激情按摩在线| 亚洲在线成人| 久久久7777| 欧美午夜不卡在线观看免费 | 久久婷婷久久| 久久精品欧洲| 欧美高清成人| 中文在线不卡视频| 久久久久久夜| 欧美日本免费| 国产日韩欧美亚洲| 一区二区三区.www| 巨乳诱惑日韩免费av| 一本久久a久久精品亚洲| 久久不射中文字幕| 欧美视频一区在线| 亚洲欧洲精品一区二区三区不卡 | 亚洲日产国产精品| 久久精品二区亚洲w码| 亚洲精品欧洲| 欧美黑人国产人伦爽爽爽| 国产综合视频| 久久成年人视频| 午夜欧美大片免费观看| 国产精品久久久久久久9999| 亚洲黄色成人久久久| 久久久综合免费视频| 久久久久欧美| 亚洲黄页视频免费观看| 国产一区二区精品久久99| 在线视频一区观看| 正在播放亚洲一区| 国产精品女主播一区二区三区| 99re亚洲国产精品| 亚洲一区二区三| 国产亚洲人成网站在线观看| 久久一区中文字幕| 免费一区二区三区| 亚洲欧美经典视频| 久久av资源网| 亚洲黄色精品| 在线视频精品一区| 在线欧美日韩| 一本色道久久综合狠狠躁篇怎么玩 | 久久久精品动漫| 精品9999| 一区二区三区成人| 亚洲大片av| 亚洲人妖在线| 黄色一区二区在线| 亚洲美女毛片| 在线观看91精品国产麻豆| 亚洲免费在线精品一区| 一本色道久久88综合日韩精品| 欧美专区18| 欧美一区不卡| 国产精品高潮在线| 亚洲免费观看高清完整版在线观看| 在线播放日韩欧美| 欧美一区91| 久久伊伊香蕉| 国产精品中文字幕在线观看| 亚洲欧洲在线视频| 一级成人国产| 欧美日韩亚洲一区三区| 亚洲人成免费| 99视频一区二区| 欧美日韩视频在线| 一区二区免费看| 亚洲影院在线| 欧美亚州一区二区三区| 一区二区欧美在线| 久久精品国产成人| 久久精品主播|