锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美日韩爆操,久久精品导航,欧美日韩精品一本二本三本http://m.shnenglu.com/MiYu/category/14861.html ______________鐧界櫧銇眿zh-cnTue, 16 Nov 2010 20:50:44 GMTTue, 16 Nov 2010 20:50:44 GMT60HDU 3468 HDOJ 3468 A Simple Problem with Integers ACM 3468 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/11/16/133824.htmlMiYuMiYuTue, 16 Nov 2010 13:28:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/11/16/133824.htmlhttp://m.shnenglu.com/MiYu/comments/133824.htmlhttp://m.shnenglu.com/MiYu/archive/2010/11/16/133824.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/133824.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/133824.html闃呰鍏ㄦ枃

MiYu 2010-11-16 21:28 鍙戣〃璇勮
]]>
PKU 2528 POJ 2528 Mayor's posters ( 綰挎鏍?紱繪暎鍖?) ACM 2528 IN PKUhttp://m.shnenglu.com/MiYu/archive/2010/10/15/PKU-2528.htmlMiYuMiYuFri, 15 Oct 2010 03:12:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/15/PKU-2528.htmlhttp://m.shnenglu.com/MiYu/comments/129997.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/15/PKU-2528.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/129997.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/129997.html闃呰鍏ㄦ枃

MiYu 2010-10-15 11:12 鍙戣〃璇勮
]]>
PKU 2352 POJ 2352 Stars ( 綰挎鏍?wèi)鐗?) ACM 2352 IN PKUhttp://m.shnenglu.com/MiYu/archive/2010/10/13/PKU-2352-POJ-2352-Stars-ACM-2352-IN-PKU.htmlMiYuMiYuWed, 13 Oct 2010 14:29:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/13/PKU-2352-POJ-2352-Stars-ACM-2352-IN-PKU.htmlhttp://m.shnenglu.com/MiYu/comments/129780.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/13/PKU-2352-POJ-2352-Stars-ACM-2352-IN-PKU.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/129780.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/129780.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

棰樼洰鍦板潃 :

http://poj.org/problem?id=2352

棰樼洰鎻忚堪:

Stars
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 14814Accepted: 6404

Description

Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars. 

For example, look at the map shown on the figure above. Level of the star number 5 is equal to 3 (it's formed by three stars with a numbers 1, 2 and 4). And the levels of the stars numbered by 2 and 4 are 1. At this map there are only one star of the level 0, two stars of the level 1, one star of the level 2, and one star of the level 3. 

You are to write a program that will count the amounts of the stars of each level on a given map.

Input

The first line of the input file contains a number of stars N (1<=N<=15000). The following N lines describe coordinates of stars (two integers X and Y per line separated by a space, 0<=X,Y<=32000). There can be only one star at one point of the plane. Stars are listed in ascending order of Y coordinate. Stars with equal Y coordinates are listed in ascending order of X coordinate. 

Output

The output should contain N lines, one number per line. The first line contains amount of stars of the level 0, the second does amount of stars of the level 1 and so on, the last line contains amount of stars of the level N-1.

Sample Input

5
1 1
5 1
7 1
3 3
5 5

Sample Output

1
2
1
1
0
 涓庢爲(wèi)鐘舵暟緇勭殑瑙f硶涓鏍?  鏌ヨ鏇存柊灝卞彲浠ヤ簡. 
	鏍?wèi)鐘舵暟缁?瑙f硶浼犻侀棬 : http://www.cnblogs.com/MiYu/archive/2010/08/26/1808963.html 
浠g爜濡備笅 : 
/*
Mail to   : miyubai@gamil.com
Link      : http://www.cnblogs.com/MiYu  || http://m.shnenglu.com/MiYu
Author By : MiYu
Test      : 1
Complier  : g++ mingw32-3.4.2
Program   : POJ_2352
Doc Name  : Stars
*/
//#pragma warning( disable:4789 )
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;
struct P{
       int x, y;
}p[15010];
int seg[100000];
int NN = 32768, res[15010];
int get ( int &n ) {
    int i = 1;
    while ( i < n ) i << 1;
    return i;    
}
void modify ( int &pos ) {
     pos += NN;
     seg[pos] ++;
     while ( pos > 1 ) {
           if ( ~pos & 1 ) seg[pos>>1] ++;
           pos >>= 1;
     }
}
int query ( int pos ) {
     pos += NN;  
     int sum = seg[pos];
     while ( pos > 1 ) {
            if ( pos & 1 ) {
                 sum += seg[pos>>1];  
            }      
            pos >>= 1;
     }   
     return sum;
}
int main ()
{
    int N;
    while ( scanf ( "%d", &N ) == 1 ) {
           int pos;
           memset ( res, 0, sizeof ( res ) );
           memset ( seg, 0, sizeof ( seg ) );
           for ( int i = 0; i < N; ++ i ) {
                  scanf ( "%d%*d", &pos );
                  res[ query ( pos ) ] ++;
                  modify ( pos );   
           }   
           for ( int i = 0; i < N; ++ i ) {
                printf ( "%d\n", res[i] );     
           } 
    }
    return 0;
}

 



MiYu 2010-10-13 22:29 鍙戣〃璇勮
]]>
HDU 3016 HDOJ 3016 Man Down ACM 3016 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/10/13/HDU-2871-HDOJ-2871-Memory-Control-ACM-2871-IN-HDU.htmlMiYuMiYuWed, 13 Oct 2010 13:26:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/13/HDU-2871-HDOJ-2871-Memory-Control-ACM-2871-IN-HDU.htmlhttp://m.shnenglu.com/MiYu/comments/129775.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/13/HDU-2871-HDOJ-2871-Memory-Control-ACM-2871-IN-HDU.html#Feedback2http://m.shnenglu.com/MiYu/comments/commentRss/129775.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/129775.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

棰樼洰鍦板潃 :

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

棰樼洰鎻忚堪:

Man Down

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 618    Accepted Submission(s): 197


Problem Description
The Game “Man Down 100 floors” is an famous and interesting game.You can enjoy the game from 
http://hi.baidu.com/abcdxyzk/blog/item/16398781b4f2a5d1bd3e1eed.html

We take a simplified version of this game. We have only two kinds of planks. One kind of the planks contains food and the other one contains nails. And if the man falls on the plank which contains food his energy will increase but if he falls on the plank which contains nails his energy will decrease. The man can only fall down vertically .We assume that the energy he can increase is unlimited and no borders exist on the left and the right.

First the man has total energy 100 and stands on the topmost plank of all. Then he can choose to go left or right to fall down. If he falls down from the position (Xi,Yi),he will fall onto the nearest plank which satisfies (xl <= xi <= xr)(xl is the leftmost position of the plank and xr is the rightmost).If no planks satisfies that, the man will fall onto the floor and he finishes his mission. But if the man’s energy is below or equal to 0 , he will die and the game is Over.

Now give you the height and position of all planks. And ask you whether the man can falls onto the floor successfully. If he can, try to calculate the maximum energy he can own when he is on the floor.(Assuming that the floor is infinite and its height is 0,and all the planks are located at different height).
 

Input
There are multiple test cases.

For each test case, The first line contains one integer N (2 <= N <= 100,000) representing the number of planks.

Then following N lines representing N planks, each line contain 4 integers (h,xl,xr,value)(h > 0, 0 < xl < xr < 100,000, -1000 <= value <= 1000), h represents the plank’s height, xl is the leftmost position of the plank and xr is the rightmost position. Value represents the energy the man will increase by( if value > 0) or decrease by( if value < 0) when he falls onto this plank.
 

Output
If the man can falls onto the floor successfully just output the maximum energy he can own when he is on the floor. But if the man can not fall down onto the floor anyway ,just output “-1”(not including the quote)
 

Sample Input
4 10 5 10 10 5 3 6 -100 4 7 11 20 2 2 1000 10
 

Sample Output
140
 

 /*

  棰樼洰鎻忚堪:  

          涓嶅悓楂樺害澶勬湁涓嶅悓鐨勬按騫蟲澘錛岃煩鍒拌鏉夸細(xì)鏈夎閲忓彉鍖杤錛?/p>

          闂綋涓涓漢浠庢渶楂樻澘寮濮嬶紝鍙互鍚戝乏鎴栬呭悜鍙籌紝

          绔栫洿璺沖埌涓嬮潰鐨勬澘錛屾眰涓嬭惤鍒板湴闈㈢殑鏈澶ц閲忥紝鎴栬?1銆?/p>

          綰挎鏍?dp  

          闇瑕佺敤綰挎鏍?wèi)鏌ヨ寰楀埌姣忎釜鏉跨殑涓や釜绔偣涓嬭惤鍚庝細(xì)鍒板摢涓澘锛?/p>

          鐒跺悗鏍規(guī)嵁榪欎釜浠庢渶楂樼殑寮濮媎p灝卞彲浠ヤ簡

          dp[i] = max ( dp[i], dp[i^].v )  // dp[i^] 浠h〃鑳借蛋鍒?i 鐨勭嚎孌?nbsp;

/* 


/*

Mail to   : miyubai@gamil.com

Link      : http://www.cnblogs.com/MiYu  || http://m.shnenglu.com/MiYu

Author By : MiYu

Test      : 1

Complier  : g++ mingw32-3.4.2

Program   : HDU_3016

Doc Name  : Man Down

*/

//#pragma warning( disable:4789 )

#include <iostream>

#include <fstream>

#include <sstream>

#include <algorithm>

#include <string>

#include <set>

#include <map>

#include <utility>

#include <queue>

#include <stack>

#include <list>

#include <vector>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <ctime>

using namespace std;

struct seg_tree {

    int id, left, right;

    int mid () { return ( left + right )>>1; }  

}seg[333333];

inline void creat ( int x, int y, int rt = 1 ) {

     seg[rt].left = x;

     seg[rt].right = y;

     //0 浠h〃鍦伴潰 鍏朵粬鐨勮嚜鐒舵暟浠h〃鍚勫眰鐨勬湪鏉跨紪鍙? -1 浠h〃鏈夊鏉$嚎孌佃鐩?nbsp;

     seg[rt].id = 0;                  

     if ( x == y ) return ;

     int mid = seg[rt].mid();

     creat ( x, mid, rt << 1 );

     creat ( mid + 1, y, rt << 1 | 1 );     

}

inline void modify ( int x, int y, int id, int rt = 1 ) {

     //鎵懼埌浜嗙嚎孌? 鐩存帴淇敼ID 瑕嗙洊鎺?nbsp;

     if ( seg[rt].left == x && seg[rt].right == y ) {

         seg[rt].id = id;

         return;   

     }

     int LL = rt << 1, RR = rt << 1 | 1, mid = seg[rt].mid();

     // 鍓嶉潰娌℃湁return鎺? 閭d箞榪欐潯綰挎鑲畾鏄瑕嗙洊鐨? 灝嗗畠鐨勬爣璁頒笅浼犲悗鏍囪涓?1 

     if ( seg[rt].id != -1 ) {      

         seg[LL].id = seg[RR].id = seg[rt].id;          

         seg[rt].id = -1;

     }      

     if ( y <= mid ) modify ( x, y, id, LL ); //鍒嗘淇敼 

     else if ( x > mid ) modify ( x, y, id, RR );

     else {

          modify ( x, mid, id, LL );

          modify ( mid + 1, y, id, RR );     

     }

}

inline int query ( int pos, int rt = 1 ) {   // 鏌ヨ Pos 鎵鍦ㄧ嚎孌電殑 id  

    if ( seg[rt].id != -1 ) return seg[rt].id; //綰挎琚鐩?鐩存帴榪斿洖 ID 

    int LL = rt << 1, RR = rt << 1 | 1, mid = seg[rt].mid();

    if ( pos <= mid ) return query ( pos, LL );             //鍒嗘鏌ヨ 

    else return query ( pos, RR );    

}

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;

}

struct Plank {

       int x,y,h,v,left,right; 

       //鎸夐珮鎺掑簭       

       friend bool operator < ( const Plank &a, const Plank &b ) {

              return a.h < b.h;

       }

}pk[100010];

int dp[100010];

int main ()

{

    int N, M;

    creat ( 1, 100000 );

    while ( scan_d ( N ) ) {

           M = -1;

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

                scan_d ( pk[i].h );scan_d ( pk[i].x );scan_d ( pk[i].y );scan_d ( pk[i].v );

                if ( pk[i].y > M ) M = pk[i].y;       // 璁板綍 鍖洪棿鏈澶у? 鍔犻熺敤鐨?nbsp;

           }

           modify  ( 1, M, 0 );

           sort ( pk + 1, pk + N + 1 );               // 鎸夐珮鎺掑簭 

           memset ( dp, 0, sizeof ( dp ) );

           dp[N] = 100 + pk[N].v;

           // 鑷簳鍚戜笂 鏇存柊 綰挎, 璁板綍 姣忔潯綰挎 宸﹀彸绔偣鑳藉埌杈劇殑 綰挎 ID 

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

                int x = pk[i].left = query ( pk[i].x );

                int y = pk[i].right = query ( pk[i].y );

                modify ( pk[i].x, pk[i].y, i );

           }

           int res = -1;

           //鑷《鍚戜笅 DP    dp[i] = max ( dp[i], dp[i^].v )  

           // dp[i^] 浠h〃鑳借蛋鍒?i 鐨勭嚎孌?nbsp;

           for ( int i = N; i >= 1; -- i ) {   

               if ( dp[ pk[i].left ] < dp[i] + pk[ pk[i].left ].v )

                    dp[ pk[i].left ] = dp[i] + pk[ pk[i].left ].v;

               if ( dp[ pk[i].right ] < dp[i] + pk[ pk[i].right ].v )

                    dp[ pk[i].right ] = dp[i] + pk[ pk[i].right ].v; 

           } 

           printf ( "%d\n",dp[0] > 0 ? dp[0] : -1 );

    }

    return 0;

}


 

 



MiYu 2010-10-13 21:26 鍙戣〃璇勮
]]>
HDU 2871 HDOJ 2871 Memory Control ACM 2871 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/10/07/128951.htmlMiYuMiYuThu, 07 Oct 2010 13:49:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/07/128951.htmlhttp://m.shnenglu.com/MiYu/comments/128951.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/07/128951.html#Feedback1http://m.shnenglu.com/MiYu/comments/commentRss/128951.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/128951.html闃呰鍏ㄦ枃

MiYu 2010-10-07 21:49 鍙戣〃璇勮
]]>
PKU 3667 HDOJ 3667 Hotel ACM 3667 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/10/07/128936.htmlMiYuMiYuThu, 07 Oct 2010 09:36:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/07/128936.htmlhttp://m.shnenglu.com/MiYu/comments/128936.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/07/128936.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/128936.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/128936.html闃呰鍏ㄦ枃

MiYu 2010-10-07 17:36 鍙戣〃璇勮
]]>
HDU 1540 HDOJ 1540 Tunnel Warfare ACM 1540 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/10/06/128767.htmlMiYuMiYuWed, 06 Oct 2010 03:06:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/06/128767.htmlhttp://m.shnenglu.com/MiYu/comments/128767.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/06/128767.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/128767.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/128767.html闃呰鍏ㄦ枃

MiYu 2010-10-06 11:06 鍙戣〃璇勮
]]>
綰挎鏍?wèi)鐨勪竴縐嶇畝鍖栧疄鐜癧杞琞 by 韙忛洩璧ゅ厰 http://m.shnenglu.com/MiYu/archive/2010/10/04/128568.htmlMiYuMiYuMon, 04 Oct 2010 08:11:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/04/128568.htmlhttp://m.shnenglu.com/MiYu/comments/128568.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/04/128568.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/128568.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/128568.html

 杞澆鑷?nbsp;http://www.cnitblog.com/cockerel/archive/2006/09/13/16806.html

鐩鎬俊瀵圭畻娉曡璁℃垨鑰呮暟鎹粨鏋勬湁涓瀹氫簡瑙g殑浜哄綰挎鏍?wèi)閮戒笉浼?xì)澶檶鐢熴傚畠鏄兘澶熷湪log(MaxLen)鏃墮棿鍐呭畬鎴愮嚎孌電殑娣誨姞銆佸垹闄ゃ佹煡璇㈢瓑鎿嶄綔銆備絾涓鑸殑瀹炵幇閮芥湁鐐瑰鏉傦紙鎴戣嚜鍐欑殑鏄閫掑綊鐨勶紝姣旇緝澶氳錛夈傝岀嚎孌墊爲(wèi)搴旂敤涓湁涓縐嶆槸涓撻棬閽堝鐐圭殑銆傦紙鐐規(guī)爲(wèi)錛燂級瀹冪殑瀹炵幇鍗撮潪甯哥畝鍗曘?br>銆銆榪欑鏁版嵁緇撴瀯鏈変粈涔堢敤錛熸垜浠厛鏉ヨ冭檻涓涓嬩笅闈㈢殑闇姹傦紙鍏ㄩ儴瑕佹眰鍦↙ogN鏃墮棿鍐呭畬鎴愶級錛氬浣曠煡閬撲竴涓偣鍦ㄤ竴涓偣闆嗛噷鐨勫ぇ灝?#8220;鎺掑悕”錛熷緢綆鍗曪紝寮涓涓偣鏁扮粍錛屾帓涓簭錛屽啀浜屽垎鏌ユ壘灝辮浜嗭紱濡備綍鍦ㄤ竴涓偣闆嗗唴鍔ㄦ佸鍒犵偣錛熶篃寰堢畝鍗曪紝寮勪釜騫寵 鏍?wèi)灏辫浜嗗Q堟湰鏉ュ鉤琛℃爲(wèi)姣旂嚎孌墊爲(wèi)澶嶆潅寰楀錛屼絾鑷粠涓栫晫涓婃湁浜哠TL set榪欎箞涓ソ涓滀笢錛屽氨……^_^錛夐偅濡傛灉鎴戞棦瑕佸姩鎬佸鍒犵偣錛屼篃瑕侀殢鏃舵煡璇㈠埌涓涓偣鐨勬帓鍚嶅憿錛熼偅瀵逛笉璧鳳紝鍙兘灝辮鍑哄姩鍒版垜浠殑“鐐規(guī)爲(wèi)”浜嗐?br>銆銆鍏跺疄鐜板師鐞嗗緢綆鍗曪細(xì)姣忓綋澧炲姞錛堟垨鍒犻櫎錛変竴涓ぇ灝忎負(fù)X鐨勭偣鏃訛紝灝卞湪鏍?wèi)涓婃氛d姞錛堟垨鍒犻櫎錛変竴鏉?X,MaxLen)鐨勭嚎孌碉紙涓嶅惈绔偣錛夛紝褰撹鏌ヨ涓涓偣鐨勬帓鍚嶆椂錛屽彧瑕佺湅鐪嬪叾涓婃湁澶氬皯鏉$嚎孌靛氨鍙互浜嗐傞拡瀵硅繖涓闇姹傦紝榪欓噷鏈変釜闈炲父綆鍗曠殑瀹炵幇錛堣浠ヤ笅浠g爜錛屽崄澶氳錛屽鐭簡鍚э紵錛夊叾涓璫lear()鐢ㄤ簬娓呯┖鐐歸泦錛沘dd()鐢ㄤ簬娣誨姞涓涓偣錛沜ntLs()榪斿洖灝忎簬n鐨勭偣鐨勪釜鏁幫紝涔熷氨鏄痭鐨勫崌搴忔帓鍚嶏紝綾諱技鍦癱ntGt鏄檷搴忔帓鍚嶃?br>銆銆榪欎釜鐐規(guī)爲(wèi)鏈変粈涔堢敤鍛紵鍏朵腑涓涓簲鐢ㄦ椂鍦∣(NlogN)鏃墮棿鍐呮眰鍑轟竴涓帓鍒楃殑閫嗗簭鏁幫紙http://acm.zju.edu.cn/show_problem.php?pid=1484錛屼綘鏈夋洿濂界殑綆楁硶鍚楋紵嬈㈣繋浜ゆ祦錛夋柟娉曟槸姣忚鍒頒竴涓暟x錛屽氨璁╅嗗簭鏁?=cntGt(x);鐒跺悗鍐峚dd(x)銆?br>銆銆榪欎釜瀹炵幇榪樺彲浠ヨ繘琛屼竴浜涙墿灞曘傛瘮濡傚垹闄el(int n)錛屽彧瑕佹妸add(int n)涓殑++size鎹㈡垚--size錛屾妸a[i/2]++鏀規(guī)垚a[i/2]--鍗沖彲銆傚彟澶栬繕鍙互閫氳繃浜屽垎鏌ユ壘鍔熻兘鍦∣(logN)鏃墮棿鍐呮煡鍒版帓鍚嶇n鐨勭偣鐨勫ぇ灝忋傚簲璇ヤ篃鍙互涓夊洓琛屽唴鎼炲畾銆?/p>

 template < int  N > // 琛ㄧず鍙敤鍖洪棿涓篬0,N)錛屽叾涓璑蹇呴』鏄?鐨勫箓鏁?  
 
class  PointTree {
    
 int  a[ 2 * N];
    
 int  size; 
    
 void  clear() { memset( this , 0 , sizeof ( * this ));}  
    
 void  add( int  n) {
        
 int  i = N + n;  ++ size; 
        
 for ( ++ a[i]; i > 1 ; i /= 2 )
            
 if ( ~ i & 1 ) a[i / 2 ] ++ ;
    }
 
 
    
 int  cntLs( int  n) { // 緇熻灝忎簬  
 
         int  i = N + n,c = 0  // 鑻ョ粺璁″皬浜庣瓑浜庡垯c=a[i];  
 
         for (; i > 1 ; i /= 2 
            
 if (i & 1 ) c += a[i / 2 ];
         
 return  c;
    }
 

     
 int  cntGt( int  n)  return  size - a[N + n] - cntLs(n); }  
}
 

銆銆鍡瘇~~涓轟簡瑙?/span>http://acm.zju.edu.cn/show_problem.php?pid=2425榪欎竴棰橈紝榪樻槸鎶婁笂榪頒袱涓墿灞曠粰瀹炵幇浜嗗暒錛屾灉鐒朵笉闅撅細(xì)
錛堟帴涓婏級
    
void del(int n){
        
if(!a[n+=N])return;
        
--size;
        
for(--a[n]; n>1; n/=2)
            
if(~n&1)--a[n/2];
    }

    
/*  瑙e喅錛氭眰鐐歸泦涓i灝忕殑鏁?鐢?鏁拌搗)
     *    娉ㄦ剰錛氬鏋渋>=size 榪斿洖N-1 
     
*/
 
    
int operator[](int n){
        
int i=1;
        
while(i<N){
            
if(n<a[i]) i*=2;
            
else n-=a[i], i=i*2+1;
        }

        
return i-N;    
    }
    
};  
//闄勪竴涓祴璇曠▼搴?/span>
#include<iostream.h>
T
<8192> t;  
int main(){
    
char c; int n;
    
while(cin>>c){
           
if(c=='c') t.clear();
           
else{
               cin
>>n;
               
if(c=='a') t.add(n);
               
if(c=='d') t.del(n);
               
if(c=='q') cout<<t[n]<<endl;
           }
    
    }
    
               
    
return 0;
}
  
姹傜偣闆嗛噷n鐨勪釜鏁頒簡!
int cntEQ(int n){
    
return a[N+n];
}

P.S.錛?/span>
銆銆鍦ㄥ啓瀹岃繖綃囨枃绔犱竴孌墊椂闂村悗錛屾垜璁よ瘑浜嗗彟涓縐嶅姛鑳戒笂姣旇緝綾諱技鐨勬暟鎹粨鏋勶紝鍙仛“鏍?wèi)鐘舵暟缁?#8221;銆傚畠浠湁涓嶅皯鐩鎬技涔嬪錛?/span>
  • 閽堝鐐歸泦鐨勫鐞嗭紙娣誨姞銆佸垹闄ゃ佹煡鎵撅級錛?/li>
  • 鐩鎬技鐨勬椂絀哄鏉傚害錛坙ogN鏃墮棿錛?N絀洪棿錛夛紱
  • 鐩鎬技鐨勭紪紼嬪鏉傚害錛堥兘姣旂嚎孌墊爲(wèi)綆鐭緱澶氾級錛?/li>

鍥犳錛屾墍鏈夊彲浠ョ敤鏍?wèi)鐘舵暟缁勮В鍐崇殑闂閮藉彲浠ョ敤杩欎?#8220;鐐規(guī)爲(wèi)”鏉ヨВ鍐籌紝鍙﹀瀹冭繕鏈変互涓嬪ソ澶勶細(xì)

  • 鏇寸洿瑙傜殑杞Щ錛堜釜浜烘劅鍙楋紝涓嶄竴瀹氳鍚屾剰錛夛紱
  • 鍚屾椂鏀寔鑷笅鑰屼笂鍜岃嚜涓婅屼笅涓ょ鏂瑰悜鐨勬煡鎵懼拰鏇存柊錛岃屽悗鑰呮爲(wèi)鐘舵暟緇勪笉鏀寔錛屾墍浠ユ爲(wèi)鐘舵暟緇勪笉鎻愪緵鏌愪簺鍔熻兘錛屾瘮濡傝O(logN)姹傜偣闆嗕腑絎琸灝忔暟銆?/li>

posted on 2006-09-13 19:54 韙忛洩璧ゅ厰 



MiYu 2010-10-04 16:11 鍙戣〃璇勮
]]>
HDU 2795 HDOJ 2795 Billboard ACM 2795 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/09/26/127809.htmlMiYuMiYuSun, 26 Sep 2010 14:15:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/09/26/127809.htmlhttp://m.shnenglu.com/MiYu/comments/127809.htmlhttp://m.shnenglu.com/MiYu/archive/2010/09/26/127809.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/127809.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/127809.html

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

棰樼洰鍦板潃:

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

棰樼洰鎻忚堪:

Billboard

Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 733    Accepted Submission(s): 340


Problem Description
At the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in the dining room menu, and other important information.

On September 1, the billboard was empty. One by one, the announcements started being put on the billboard.

Each announcement is a stripe of paper of unit height. More specifically, the i-th announcement is a rectangle of size 1 * wi.

When someone puts a new announcement on the billboard, she would always choose the topmost possible position for the announcement. Among all possible topmost positions she would always choose the leftmost one.

If there is no valid location for a new announcement, it is not put on the billboard (that's why some programming contests have no participants from this university).

Given the sizes of the billboard and the announcements, your task is to find the numbers of rows in which the announcements are placed.
 

Input
There are multiple cases (no more than 40 cases).

The first line of the input file contains three integer numbers, h, w, and n (1 <= h,w <= 10^9; 1 <= n <= 200,000) - the dimensions of the billboard and the number of announcements.

Each of the next n lines contains an integer number wi (1 <= wi <= 10^9) - the width of i-th announcement.
 

Output
For each announcement (in the order they are given in the input file) output one number - the number of the row in which this announcement is placed. Rows are numbered from 1 to h, starting with the top row. If an announcement can't be put on the billboard, output "-1" for this announcement.
 

Sample Input
3 5 5 2 4 3 3 3
 

Sample Output
1 2 1 3 -1
 

 

涓寮濮嬫病鎯蟲槑鐧芥庝箞鍋?,  浠旂粏鎯充簡鎯?   鍐嶆 璇婚鍚?鍙戠幇 , n <= 200000;  涔熷氨鏄  鏈澶?涔熷氨 200000 鏉″箍鍛?, 浣犲氨綆楁瘡琛岃創(chuàng)涓寮?,

鏈澶氫篃灝辮創(chuàng)鍒?200000 琛?  鎵浠? 涓嶈琚? h <= 10^9  嬈℃柟鍚撳埌浜? ,璁や負(fù) 綰挎鏍?wèi)寮涓嶄簡閭d箞澶х殑鏁扮粍  . 鍙寮 200000 灝卞彲浠ヤ簡 .

 

鍏朵粬鐨?娌′粈涔?濂借鐨?, 鐭ラ亾榪欎釜 灝辯洿鎺?鏆?鍚?............灝嗚繎 7000MS .=姘磋繃.................   g++鎻愪氦 榪樺崕涓界殑 閫佸嚭浜?涓嬈?TLE....

C++  姘磋繃浜?............

 

//    涓鐩存病鏄庣櫧 涓轟粈涔堟垜鐨?浠g爜閫熷害 閭d箞 鎱?  鏌ヨ鍚?鏇存柊 鐨勬椂闂存槸 2000MS 宸﹀彸  , 鎴戠殑 鏄?鏌ヨ 灝辨洿鏂頒簡,

绔熺劧瑕?灝嗚繎 7000MS ? 闈炲父 閮侀椃 ,  涓嶄俊閭殑 緇х畫 媯鏌?浠g爜, 鍦?鐬簡 1鍝ュ皬鏃跺悗 , 蹇界劧鎯沖埌 : 鎶?cout 鏀規(guī)垚

printf 浼?xì)鎬庢牱?   緇撴灉 :  1640 MS  AC ..............楝肩煡閬撲粬鐨?鏁版嵁閲忔湁澶氬ぇ..... cout 鍜?printf

绔熺劧 宸簡 5000 MS 鐨勬椂闂?...........鏃犺

浠g爜濡備笅 :

 

 /*

Coded By  : MiYu

Link      : http://www.cnblogs.com/MiYu  || http://m.shnenglu.com/MiYu

Author By : MiYu

Test      : 1

Program   : 2795

*/

//#pragma warning( disable:4789 )

#include <iostream>

#include <algorithm>

#include <string>

#include <set>

#include <map>

#include <utility>

#include <queue>

#include <stack>

#include <list>

#include <vector>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

using namespace std;


struct ADV {

       int left, right, val;

       int mid () { return ( left + right ) >> 1; }     

}adv[800000];

int N, W, H, w;

void creat ( int l, int r, int rt = 1 ){

     adv[rt].left = l;

     adv[rt].right = r;

     adv[rt].val = W;

     if ( l == r )

        return ;

     int mid = adv[rt].mid();

     creat ( l, mid, rt << 1 );

     creat ( mid + 1, r, ( rt << 1 ) + 1 );

}

void add ( int rt = 1, int wei = w ){

    if ( wei <= adv[rt].val ){

         if ( adv[rt].left == adv[rt].right ){

              adv[rt].val -= wei;

              //cout << adv[rt].left << endl;  //鏉叿鐨?鍦版柟

printf ( "%d\n", adv[rt].left ); 

              return ;     

         } else if ( adv[rt<<1].val >= wei ) {

                add ( rt << 1 );

                adv[rt].val = max ( adv[rt<<1].val, adv[(rt<<1)+1].val );     

         } else {

                add ( ( rt << 1 ) + 1 );

                adv[rt].val = max ( adv[rt<<1].val, adv[(rt<<1)+1].val );        

         }   

    } else {

           //cout << -1 << endl;      //鏉叿鐨勫湴鏂?/span>

puts ( "-1" );   

    }   

}

inline bool scan_ud(int &num)

{

    char in;

    in=getchar();

    if(in==EOF) return false;

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

    num=in-'0';

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

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

    }

    return true;

}

int main ()

{

    while ( scan_ud (H)&&scan_ud (W)&&scan_ud (N) ) {

           if ( H > 200000 )

               H = 200010;

           creat ( 1, H );

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

                scan_ud (w);

                add ( );     

           }      

    }

    return 0;

}

 

 

 

 

鍙?闄勪笂 鍌誨唇  紲炵墰 浠g爜 :

 

#include <iostream>

#include <algorithm>

#include <string>

#include <set>

#include <map>

#include <utility>

#include <queue>

#include <stack>

#include <list>

#include <vector>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#define FF(i,a) for( int i = 0 ; i < a ; i ++ )

#define FOR(i,a,b) for( int i = a ; i < b ; i ++ )

#define LL(a) a<<1

#define RR(a) a<<1|1

template<class T> inline void checkmin(T &a,T b) {if(a < 0 || a > b)a = b;}

template<class T> inline void checkmax(T &a,T b) {if(a < b) a = b;}

using namespace std;

struct Node {

int val;

int idx;

friend bool operator < (Node a , Node b) {

if(a.val == b.val) {

return a.idx > b.idx;

}

return a.val < b.val;

}

}error;

 

struct Seg_Tree{

int left,right;

Node node;

int mid() {

return (left + right)>>1;

}

}tt[800000];

 

int n , h , m;

 

void build(int l,int r,int idx) {

tt[idx].left = l;

tt[idx].right = r;

tt[idx].node.idx = l;

tt[idx].node.val = h;

if(l == r) return ;

int mid = tt[idx].mid();

build(l,mid,LL(idx));

build(mid+1,r,RR(idx));

}

 

void update(int l,int r,int val,int idx) {

if(l <= tt[idx].left && r >= tt[idx].right) {

tt[idx].node.val += val;

return ;

}

int mid = tt[idx].mid();

if(l <= mid) update(l,r,val,LL(idx));

if(mid < r) update(l,r,val,RR(idx));

tt[idx].node = max(tt[LL(idx)].node,tt[RR(idx)].node);

}

 

Node query(int w,int idx) {

if(tt[idx].node.val < w) {

return error;

}

if(tt[idx].left == tt[idx].right) {

return tt[idx].node;

}

if(tt[LL(idx)].node.val >= w) {

return query(w,LL(idx));

} else {

return query(w,RR(idx));

}

}

 

int main() {

error.idx = -1;

while(scanf("%d%d%d",&n,&h,&m) == 3) {

checkmin(n,m);

build(1,n,1);

while(m --) {

int w;

scanf("%d",&w);

Node ret = query(w,1);

printf("%d\n",ret.idx);

if(ret.idx != -1) {

update(ret.idx,ret.idx,-w,1);

}

}

}

return 0;

 

 



MiYu 2010-09-26 22:15 鍙戣〃璇勮
]]>
HDOJ 1698 HDU 1698 Just a Hook ACM 1698 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/09/17/126829.htmlMiYuMiYuFri, 17 Sep 2010 02:09:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/09/17/126829.htmlhttp://m.shnenglu.com/MiYu/comments/126829.htmlhttp://m.shnenglu.com/MiYu/archive/2010/09/17/126829.html#Feedback4http://m.shnenglu.com/MiYu/comments/commentRss/126829.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/126829.html闃呰鍏ㄦ枃

MiYu 2010-09-17 10:09 鍙戣〃璇勮
]]>
HDOJ 1754 HDU 1754 I Hate It ACM 1754 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/09/15/126668.htmlMiYuMiYuWed, 15 Sep 2010 08:08:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/09/15/126668.htmlhttp://m.shnenglu.com/MiYu/comments/126668.htmlhttp://m.shnenglu.com/MiYu/archive/2010/09/15/126668.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/126668.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/126668.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

棰樼洰鍦板潃:

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

棰樼洰鎻忚堪:

銆銆

I Hate It

Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6306    Accepted Submission(s): 2267


Problem Description
寰堝瀛︽牎嫻佽涓縐嶆瘮杈冪殑涔?fàn)鎯傝佸笀浠緢鍠滄璇㈤棶錛屼粠鏌愭煇鍒版煇鏌愬綋涓紝鍒嗘暟鏈楂樼殑鏄灝戙?br>榪欒寰堝瀛︾敓寰堝弽鎰熴?br>
涓嶇浣犲枩涓嶅枩嬈紝鐜板湪闇瑕佷綘鍋氱殑鏄紝灝辨槸鎸夌収鑰佸笀鐨勮姹傦紝鍐欎竴涓▼搴忥紝妯℃嫙鑰佸笀鐨勮闂傚綋鐒訛紝鑰佸笀鏈夋椂鍊欓渶瑕佹洿鏂版煇浣嶅悓瀛︾殑鎴愮嘩銆?/div>
 

Input
鏈鐩寘鍚緇勬祴璇曪紝璇峰鐞嗗埌鏂囦歡緇撴潫銆?br>鍦ㄦ瘡涓祴璇曠殑絎竴琛岋紝鏈変袱涓鏁存暟 N 鍜?M ( 0<N<=200000,0<M<5000 )錛屽垎鍒唬琛ㄥ鐢熺殑鏁扮洰鍜屾搷浣滅殑鏁扮洰銆?br>瀛︾敓ID緙栧彿鍒嗗埆浠?緙栧埌N銆?br>絎簩琛屽寘鍚玁涓暣鏁幫紝浠h〃榪橬涓鐢熺殑鍒濆鎴愮嘩錛屽叾涓i涓暟浠h〃ID涓篿鐨勫鐢熺殑鎴愮嘩銆?br>鎺ヤ笅鏉ユ湁M琛屻傛瘡涓琛屾湁涓涓瓧絎?C (鍙彇'Q'鎴?U') 錛屽拰涓や釜姝f暣鏁癆錛孊銆?br>褰揅涓?Q'鐨勬椂鍊欙紝琛ㄧず榪欐槸涓鏉¤闂搷浣滐紝瀹冭闂甀D浠嶢鍒癇(鍖呮嫭A,B)鐨勫鐢熷綋涓紝鎴愮嘩鏈楂樼殑鏄灝戙?br>褰揅涓?U'鐨勬椂鍊欙紝琛ㄧず榪欐槸涓鏉℃洿鏂版搷浣滐紝瑕佹眰鎶奍D涓篈鐨勫鐢熺殑鎴愮嘩鏇存敼涓築銆?br>
 

Output
瀵逛簬姣忎竴嬈¤闂搷浣滐紝鍦ㄤ竴琛岄噷闈㈣緭鍑烘渶楂樻垚緇┿?/div>
 

Sample Input
5 6 1 2 3 4 5 Q 1 5 U 3 6 Q 3 4 Q 4 5 U 2 9 Q 1 5
 

Sample Output
5 6 5 9
Hint
Huge input,the C function scanf() will work better than cin
 

 

鎰熻濂戒箙娌℃湁A棰樹簡 , 鏈榪戜竴鐩存病鏈夌姸鎬?  璞嗚眴涔熻漿琛屼簡, 閮侀椃.......    鍥犱負(fù)鎵撶畻 涓撶簿 鏁版嵁緇撴瀯鏂歸潰,

鎵浠ヨ繖鍑犲ぉ涓鐩撮兘鍦ㄥ涔?鏁版嵁緇撴瀯, 鍐嶄竴嬈″涔?fàn)浜?綰挎鏍? 浠ュ墠鍙細(xì)鐢ㄥ畠鏉?鏇存柊鐐?姹傚拰 , 鐜板湪緇堜簬姘翠簡涓

涓?RMQ 鐨勮8棰樹簡, HAPPY 涓涓?...

瀵逛簬 RMQ 鐨勯鐩? 鐪婸PT 涓婇潰鐨?DP 鎴戠洿鎺?rz浜?..........琛ㄧずDP鍙細(xì)鍋氭按棰?... 榪欐柟闈㈣繕鏄氦緇?br>

YCH 鍚?   涓嶈繃鐪嬩簡 sh菐宕?/a> 澶х 鍗氬鐨?綰挎鏍?wèi)涓撹緫鍚? 鍙戠幇 鐢ㄧ嚎孌墊爲(wèi)澶勭悊 榪欑被闂 闈炲父鏂逛究, 淇敼鏌ヨ

閮芥槸 O (logN)鐨?,  紼嶇◢浼樺寲浜嗕笅杈撳叆, 234MS AC ........

 

浠g爜濡備笅 :

浠g爜
/*
Coded By  : MiYu
Link      : 
http://www.cnblogs.com/MiYu  || http://m.shnenglu.com/MiYu
Author By : MiYu
Test      : 1
Program   : 1754
*/
//#pragma warning( disable:4789 )
#include 
<iostream>
#include 
<algorithm>
#include 
<string>
#include 
<set>
#include 
<map>
#include 
<utility>
#include 
<queue>
#include 
<stack>
#include 
<list>
#include 
<vector>
#include 
<cstdio>
#include 
<cstdlib>
#include 
<cstring>
#include 
<cmath>
using namespace std;
inline 
int max ( int a, int b ){
    
return a > b ? a : b;
}
typedef 
struct seg_Tree {
    
int left, right;
    
int mid() { return (left+right)>>1; }
    
int max;
}S;
S seg[
605000];
int key[200010];
int creat ( int left, int right, int root = 1 ){
    seg[root].left 
= left;    
    seg[root].right 
= right; 
    
if ( left == right )
        
return seg[root].max = key[left];
    
int mid = seg[root].mid();
    
return seg[root].max = max ( creat ( left, mid, root << 1 ),creat ( mid + 1, right, ( root << 1 ) + 1 ) );
}

void modify ( int val, int pos, int r = 1 ){
    
if ( seg[r].left == seg[r].right ){
        seg[r].max 
= val;
        
return;
    }
    
int mid = seg[r].mid();
    
if ( pos <= mid ){
        modify ( val, pos, r 
<< 1 );
    } 
else {
        modify ( val, pos, ( r 
<< 1 ) + 1 );
    }
    seg[r].max 
= max ( seg[r<<1].max, seg[ (r<<1+ 1 ].max );
}

int quy ( int left, int right, int r = 1 ){
    
if ( seg[r].left == left && seg[r].right == right ){
        
return seg[r].max;
    }
    
int mid = seg[r].mid();
    
if ( right <= mid  ){
        
return quy ( left, right, r << 1 );
    } 
else if ( left > mid ) {
        
return quy ( left, right, (r << 1+ 1 );
    } 
else {
        
return max ( quy ( left, mid, r << 1 ), quy ( mid + 1, right, (r << 1+ 1 ) );
    }
}
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 ()
{
    
int N, M, x, y;
    
while ( scan_d(N) && scan_d(M) ){
        
for ( int i = 1; i <= N; ++ i ){
            scan_d( key[i] );    
        }
        creat ( 
1, N );  
        while ( M -- ){
            
char ask[5];
            scanf ( 
"%s", ask );
            scan_d(x);
            scan_d(y);
            
switch ( ask[0] ){
                
case 'Q':    printf ( "%d\n", quy ( x,y ) );
                            
break;
                
case 'U':    modify ( y, x );
            }
        }
    }
    
return 0;
}

/*
5 6
1 2 3 4 5
Q 1 5
U 3 6
Q 3 4
Q 4 5
U 2 9
Q 1 5
*/


 

 




MiYu 2010-09-15 16:08 鍙戣〃璇勮
]]>HDOJ 1166 HDU 1166 鏁屽叺甯冮樀 (綰挎鏍?wèi)瑙f?ACM 1166 IN HDUhttp://m.shnenglu.com/MiYu/archive/2010/09/04/125867.htmlMiYuMiYuSat, 04 Sep 2010 04:53:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/09/04/125867.htmlhttp://m.shnenglu.com/MiYu/comments/125867.htmlhttp://m.shnenglu.com/MiYu/archive/2010/09/04/125867.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/125867.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/125867.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

鍏堝墠鍋氫簡榪欎竴棰? 涓嶈繃鏄敤 鏍?wèi)鐘舵暟缁勫仛鐨? 瀵逛簬榪欎竴綾誨瀷鐨勯鐩篃鏉ヨ闈炲父鏂逛究蹇嵎. 鍏蜂綋鍦板潃 : http://www.cnblogs.com/MiYu/archive/2010/08/25/1808441.html

 

榪欏嚑澶╁浜?綰挎鏍?, 涓嶆槸寰堟槑鐧藉畠鐨勭敤閫?鍜?浣跨敤鏂規(guī)硶,  鍥犱負(fù) 鍚 鏍?wèi)鐘舵暟缁勬?綰挎鏍?wèi)鐨?涓縐嶇壒孌婃儏鍐?( 閮ㄥ垎璧勬枡鏄繖涔堣鐨?) .  浜庢槸灝卞張鍋氫簡涓嬈¤繖涓鐩?

涓嶈繃浣跨敤鐨勬槸綰挎鏍?wèi)鐨?鏂規(guī)硶 :

浠g爜濡備笅 :

浠g爜
/*
MiYu鍘熷垱, 杞笘璇鋒敞鏄?nbsp;: 杞澆鑷?nbsp;______________鐧界櫧銇眿
          
http://www.cnblog.com/MiYu
Author By : MiYu
Test      : 3
Program   : 1166
*/

#include 
<iostream>
#include 
<algorithm>
using namespace std;
typedef 
struct Line{ //綰挎鏍?wèi)缁撴瀯浣?br>        friend struct optLine;
        Line () { sum 
= 0; left = right = NULL; };
        
int l,r,sum;
        
struct Line *left, *right;
}L;
typedef 
struct optLine { //綰挎鏍?wèi)鎿嶄綔缁撴?br>       void Creat ( struct Line *node, int beg, int end );
       
void modify ( struct Line *node, int pos,int val );
       
int quy ( struct Line *node, int beg, int end );     
}OPT;
void optLine::Creat ( struct Line *node, int beg, int end ){ //寤烘爲(wèi)
     node
->= beg;  node->= end;
     
if ( beg == end ) return;
     
int mid = ( node->+ node->r ) >> 1;
     L 
*= new L;  L *= new L;
     node
->left = p; node->right = q;
     Creat ( p, beg, mid );   Creat ( q, mid 
+ 1, end );          
}
void optLine::modify ( struct Line *node, int pos, int val ){ //淇敼
     
if ( pos >= node->&& pos <= node->r ) node->sum += val;
     
if ( node->== node->r ) return;
     
int mid = ( node->+ node->r ) >> 1;
     
if ( mid >= pos ) modify ( node->left, pos, val );
     
else if ( mid < pos ) modify ( node->right, pos,val );
}
int optLine::quy ( struct Line *node, int beg, int end ){ //鏌ヨ
    
int sum = 0;  int mid = ( node->+ node->r ) >> 1;
    
if ( node->== beg && node->== end ) return node->sum;
    
if ( mid >= end ) return sum += quy ( node->left, beg,end );
    
else if ( beg > mid ) return sum += quy ( node->right, beg, end ); 
    
else {
          
return sum += quy ( node->left, beg, mid ) + quy ( node->right, mid+1,end );     
    }   
}
inline 
bool scan_ud(int &num) 
{
        
char in;
        
in=getchar();
        
if(in==EOF) return false;
        
while(in<'0'||in>'9'in=getchar();
        num
=in-'0';
        
while(in=getchar(),in>='0'&&in<='9'){
                num
*=10,num+=in-'0';
        }
        
return true;
}
int main ( int T, int N )
{
    scan_ud ( T );
    
for ( int ca = 1; ca <= T ; ++ ca ){
         printf ( 
"Case %d:\n",ca );
         scan_ud ( N );    OPT opt;  L 
*root = new L;   int val,x,y;
         opt.Creat ( root, 
1, N );  
         
for ( int i = 1; i <= N; ++ i ){
              scan_ud ( val );  opt.modify ( root, i, val );    
         }
         
char ask[10];  
         
while ( scanf ( "%s", ask ), ask[0!= 'E' ){
                scanf ( 
"%d%d",&x,&y );
                
switch ( ask[0] ){
                        
case 'Q':  printf ( "%d\n",opt.quy ( root, x,y ) ); break;
                        
case 'A':  opt.modify ( root, x, y ); break;
                        
case 'S':  opt.modify ( root, x, -y ); break;      
                }      
         }
    }
    
return 0;
}

 

 



MiYu 2010-09-04 12:53 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
              亚洲网站视频| 美女主播一区| 亚洲一区二区三区中文字幕在线 | 欧美精品麻豆| 欧美成人午夜影院| 欧美日韩免费一区| 国产精品久久91| 国产亚洲欧美日韩精品| 好吊妞这里只有精品| 亚洲国产免费| 这里只有精品在线播放| 欧美一区午夜视频在线观看| 久久午夜精品一区二区| 亚洲丶国产丶欧美一区二区三区| 久久久久久久综合色一本| 欧美国产精品专区| 亚洲一二三区精品| 久久亚洲欧美| 国产精品乱码久久久久久| 1769国产精品| 午夜伦理片一区| 亚洲电影网站| 性欧美xxxx大乳国产app| 免费欧美在线| 国产欧美日韩视频一区二区三区| 1024日韩| 久久精品欧美| 99成人在线| 久久一区二区三区av| 国产精品国产精品| 在线观看欧美视频| 午夜一级久久| 亚洲精品美女久久久久| 亚洲视频香蕉人妖| 国产农村妇女毛片精品久久麻豆 | 乱人伦精品视频在线观看| 日韩一本二本av| 久久人人爽人人| 国产日韩欧美不卡| 这里只有精品视频在线| 亚洲国产精选| 蜜桃视频一区| 一区二区三区在线视频播放| 欧美亚洲视频| 99pao成人国产永久免费视频| 久久久久高清| 国产一区在线播放| 香港久久久电影| 一区二区精品在线观看| 欧美成人免费全部| 亚洲国产精品综合| 久久综合综合久久综合| 欧美亚洲日本网站| 国产日韩欧美夫妻视频在线观看| 午夜一区不卡| 亚洲欧美综合国产精品一区| 国产精品久久久久久超碰| 亚洲视频狠狠| 一本久道久久综合婷婷鲸鱼| 欧美日韩另类丝袜其他| 一区二区三区高清| 一区二区三区精品| 国产精品日日做人人爱| 午夜久久久久久| 亚洲自拍偷拍色片视频| 国产精品视频网站| 久久久www| 久久资源av| 亚洲欧洲日本国产| 亚洲国产天堂久久综合网| 欧美激情第一页xxx| 亚洲精品久久久久中文字幕欢迎你| 蜜乳av另类精品一区二区| 猛男gaygay欧美视频| 99re热精品| 一本色道久久综合亚洲精品按摩| 欧美四级剧情无删版影片| 在线视频精品一| 亚洲乱码国产乱码精品精98午夜| 欧美视频中文字幕在线| 亚洲欧美日产图| 久久久久久久综合狠狠综合| 亚洲电影自拍| 亚洲人成人一区二区在线观看| 欧美国产成人在线| 亚洲一区二区伦理| 午夜免费电影一区在线观看| 国产综合网站| 欧美日韩国产综合新一区| 国产色视频一区| 欧美xart系列高清| 欧美日韩一区自拍| 久久精品国产在热久久| 免费欧美日韩国产三级电影| 亚洲综合精品| 久久久亚洲成人| 亚洲午夜国产一区99re久久| 欧美一区在线视频| 这里只有精品视频| 久久er99精品| 一区二区三区国产精品| 久久精品国产清高在天天线| 亚洲毛片一区| 欧美一区二区视频在线| 国产精品99久久久久久有的能看| 久久成人国产| 亚洲欧美在线另类| 欧美精品97| 女女同性女同一区二区三区91| 国产精品久久综合| 亚洲精品在线电影| 亚洲第一视频| 久久电影一区| 久久精品亚洲乱码伦伦中文| 欧美午夜精品一区二区三区| 亚洲国产小视频在线观看| 好吊视频一区二区三区四区| 亚洲永久字幕| 亚洲视频www| 欧美精品在线观看| 欧美国产视频一区二区| 国产自产2019最新不卡| 亚洲男女自偷自拍| 亚洲已满18点击进入久久| 欧美大片在线看| 欧美成人午夜77777| 激情欧美一区| 久久精品主播| 久久久视频精品| 国产目拍亚洲精品99久久精品 | 欧美性色综合| 99国产一区| 在线视频精品一| 欧美日韩色一区| 亚洲美女中出| 日韩一级在线观看| 欧美精品久久一区| 最新亚洲电影| 一区二区三区精品在线| 欧美日韩综合网| 中文av字幕一区| 午夜精品久久久久久久久| 欧美午夜免费电影| 亚洲一区二区三区高清| 欧美一二区视频| 国产在线拍偷自揄拍精品| 久久精品日韩| 亚洲国产成人一区| 亚洲午夜日本在线观看| 欧美视频久久| 亚洲欧美日本伦理| 麻豆精品网站| 经典三级久久| 欧美v日韩v国产v| 欧美大片在线看| 影音先锋在线一区| 免费观看亚洲视频大全| 亚洲国产高清aⅴ视频| 一区二区国产日产| 国产精品免费一区二区三区观看| 亚洲一区亚洲二区| 久久综合九色综合久99| 亚洲日本激情| 国产精品乱码一区二三区小蝌蚪| 亚洲欧美日产图| 欧美高清视频在线观看| 日韩视频欧美视频| 国产精品综合视频| 另类激情亚洲| 日韩一区二区电影网| 久久久久国产一区二区| 亚洲精品国产拍免费91在线| 欧美午夜电影在线| 久久大香伊蕉在人线观看热2| 亚洲高清三级视频| 欧美伊人久久大香线蕉综合69| 亚洲第一区中文99精品| 国产精品久久久久影院亚瑟| 久久躁狠狠躁夜夜爽| 日韩视频永久免费| 久久久久久夜精品精品免费| 中国女人久久久| 国产专区精品视频| 欧美视频第二页| 久久综合久久综合这里只有精品| 99伊人成综合| 欧美成人综合| 西西裸体人体做爰大胆久久久| 亚洲第一中文字幕在线观看| 国产精品久久二区二区| 老**午夜毛片一区二区三区| 亚洲一区二区在| 亚洲日本精品国产第一区| 久久久国产成人精品| 在线视频精品一区| 亚洲国产欧洲综合997久久| 国产自产精品| 国产午夜亚洲精品羞羞网站| 欧美日韩亚洲三区| 欧美黄色视屏|