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

ACM___________________________

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

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜

MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋    

 

題目地址:

     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

 

題目分析 :

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

好了,  直接代碼吧, 代碼過長, 內存多了一點點 , HDU 第二     

2HUT-MiYu156MS8044K3172BC++

 

 /*

MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋

          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| 亚洲精品专区| 欧美一区=区| 欧美久久影院| 国产综合色产| 亚洲网友自拍| 免费91麻豆精品国产自产在线观看| 亚洲国产成人久久综合一区| 亚洲视频国产视频| 欧美片网站免费| 影音先锋亚洲精品| 小黄鸭精品aⅴ导航网站入口| 免费欧美在线| 先锋亚洲精品| 国产精品一二一区| 在线性视频日韩欧美| 欧美激情一区在线| 久久久久五月天| 国产亚洲一二三区| 午夜伦欧美伦电影理论片| 亚洲人成艺术| 欧美不卡一卡二卡免费版| 国产亚洲欧美一区二区三区| 亚洲性色视频| 日韩视频亚洲视频| 欧美激情综合亚洲一二区| 在线观看国产一区二区| 久久精品观看| 午夜视频久久久| 国产精品一区二区久久国产| 日韩一二三区视频| 91久久久在线| 欧美精品国产精品| 99riav久久精品riav| 欧美激情精品久久久久久变态| 欧美中文在线观看| 国内自拍视频一区二区三区| 欧美一区二区精品| 亚洲欧美在线一区二区| 国产片一区二区| 久久国产夜色精品鲁鲁99| 亚洲人成免费| 亚洲欧美日韩视频二区| 久久在精品线影院精品国产| 午夜精品久久久久久久久久久久| 国产精品久久久久久av福利软件| 一本一本a久久| 亚洲网站在线播放| 国产美女精品人人做人人爽| 欧美在线视频在线播放完整版免费观看 | 在线欧美三区| 欧美高清成人| 欧美精品七区| 亚洲先锋成人| 性伦欧美刺激片在线观看| 国产亚洲一区在线| 免费日韩成人| 欧美日韩亚洲三区| 欧美一区午夜视频在线观看| 久久成人精品无人区| 在线日韩中文字幕| 亚洲精品社区| 国产视频一区免费看| 免费不卡欧美自拍视频| 欧美精品一线| 欧美在线观看一区二区| 久久亚洲美女| 亚洲一区二区三区国产| 午夜精品在线观看| 亚洲国产精品久久久久秋霞影院 | 亚洲欧美激情视频| 精品91免费| 亚洲精品一级| 国产亚洲精品自拍| 亚洲激情视频在线播放| 国产伦精品一区二区三区高清版| 久久综合婷婷| 欧美无砖砖区免费| 美日韩精品视频| 国产精品第一页第二页第三页| 快射av在线播放一区| 欧美精品久久久久久久免费观看 | 亚洲国产成人91精品| 国产精品扒开腿做爽爽爽视频| 久久精品30| 国产精品狠色婷| 欧美成人一区二免费视频软件| 欧美日韩在线三级| 久久伊人精品天天| 国产精品扒开腿做爽爽爽软件 | 国产精品永久| 久久久亚洲高清| 欧美成人午夜影院| 羞羞视频在线观看欧美| 亚洲精品在线视频| 久久er精品视频| 香蕉成人啪国产精品视频综合网| 蜜桃av综合| 麻豆久久婷婷| 国产日韩av高清| 亚洲无吗在线| 亚洲一区二区三区免费观看| 裸体一区二区| 久久综合色影院| 国语自产精品视频在线看| 亚洲欧美成人综合| 午夜精品99久久免费| 欧美日韩中文字幕精品| 久久午夜国产精品| 国产在线精品一区二区夜色| 午夜免费日韩视频| 久久久久久婷| 影音先锋成人资源站| 欧美综合国产| 久久五月激情| 亚洲国产精品黑人久久久| 久久久久一区| 欧美成人精品高清在线播放| 黄色国产精品| 久久亚洲国产成人| 欧美激情中文不卡| 亚洲精品一区在线观看| 欧美韩国日本一区| 亚洲精品日韩久久| 午夜精品久久久久久久久久久久久 | 一区二区三区欧美在线观看| 欧美精品成人91久久久久久久| 欧美成人官网二区| 亚洲欧洲在线播放| 欧美日韩一区二| 亚洲一区免费看| 久久经典综合| 亚洲国产小视频在线观看| 女人天堂亚洲aⅴ在线观看| 亚洲高清视频的网址| 国产精品99久久久久久久女警 | 国产精品欧美激情| 亚洲香蕉在线观看| 久久爱www| 亚洲经典视频在线观看| 欧美三级乱码| 香蕉久久国产| 亚洲第一精品在线| 亚洲字幕一区二区| 精品av久久707| 欧美连裤袜在线视频| 亚洲欧美日韩国产成人| 免费在线亚洲欧美| 亚洲一区视频在线观看视频| 国产区日韩欧美| 欧美xx视频| 亚洲欧美国产不卡| 亚洲国产人成综合网站| 性欧美在线看片a免费观看| 国产精品一区二区三区免费观看 | 亚洲精品综合精品自拍| 欧美新色视频| 久久午夜精品一区二区| 日韩亚洲一区二区| 美女福利精品视频| 亚洲免费一在线| 亚洲国产精品电影| 国产日产欧美一区| 欧美色区777第一页| 老色批av在线精品| 亚洲欧美日韩精品久久久| 亚洲人成亚洲人成在线观看| 久久久亚洲影院你懂的| 亚洲视频一二| 亚洲精品久久7777| 韩国精品在线观看| 国产精品国产三级国产专播品爱网 | 久久精品国产视频| 一级成人国产| 亚洲国产欧美国产综合一区 | 亚洲夜晚福利在线观看| 亚洲日本成人| 欧美国产一区二区| 免费视频一区| 久久亚洲一区二区| 久久久国产成人精品|