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

ACM___________________________

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

常用鏈接

留言簿(24)

隨筆分類(lèi)(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

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

 

 

 

題目地址 :

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

題目描述 : 

Just a Hook

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3841    Accepted Submission(s): 1675


Problem Description
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.



Now Pudge wants to do some operations on the hook.

Let us number the consecutive metallic sticks of the hook from 1 to N. For each operation, Pudge can change the consecutive metallic sticks, numbered from X to Y, into cupreous sticks, silver sticks or golden sticks.
The total value of the hook is calculated as the sum of values of N metallic sticks. More precisely, the value for each kind of stick is calculated as follows:

For each cupreous stick, the value is 1.
For each silver stick, the value is 2.
For each golden stick, the value is 3.

Pudge wants to know the total value of the hook after performing the operations.
You may consider the original hook is made up of cupreous sticks.
 

Input
The input consists of several test cases. The first line of the input is the number of the cases. There are no more than 10 cases.
For each case, the first line contains an integer N, 1<=N<=100,000, which is the number of the sticks of Pudge’s meat hook and the second line contains an integer Q, 0<=Q<=100,000, which is the number of the operations.
Next Q lines, each line contains three integers X, Y, 1<=X<=Y<=N, Z, 1<=Z<=3, which defines an operation: change the sticks numbered from X to Y into the metal kind Z, where Z=1 represents the cupreous kind, Z=2 represents the silver kind and Z=3 represents the golden kind.
 

Output
For each case, print a number in a line representing the total value of the hook after the operations. Use the format in the example.
 

Sample Input
1 10 2 1 5 2 5 9 3
 

Sample Output
Case 1: The total value of the hook is 24.
 

 

標(biāo)準(zhǔn)的線(xiàn)段樹(shù),  成段更新 ,......     具體看 代碼 注釋 .

 

代碼如下 :

 /*

Coded By  : MiYu

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

Author By : MiYu

Test      : 1

Program   : 1698

*/

//#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;


typedef struct seg_tree{

int left, right, col;

bool cov; //標(biāo)記當(dāng)前線(xiàn)段是否被覆蓋, 如果true, 表示這一段線(xiàn)段的值都為 col. false則相反

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

}SEG;

SEG seg[300010];

void creat ( int beg, int end, int rt = 1 ){

seg[rt].left = beg;

seg[rt].right = end;

seg[rt].col =  1;

seg[rt].cov =  true;

if ( beg == end ) return;

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

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

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

}

void modify ( int beg, int end, int val, int rt = 1 ){

int LL = rt << 1;

int RR = ( rt << 1 ) + 1;

if ( seg[rt].left == beg && seg[rt].right == end ){ //線(xiàn)段被覆蓋, 標(biāo)記 cov 為true  

seg[rt].cov = true;

seg[rt].col = val;

return ;

}

if ( seg[rt].cov ){ //如果線(xiàn)段曾經(jīng)被覆蓋,  標(biāo)記 false, 將col往下傳  

seg[rt].cov = false;

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

seg[LL].cov = seg[RR].cov = true;

}

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

if ( end <= mid ){

modify ( beg, end, val, LL );

} else if ( beg > mid ) {

modify ( beg, end, val, RR );

} else {

modify ( beg, mid, val, LL );

modify ( mid + 1, end, val, RR );

}

}

int quy ( int beg, int end, int rt = 1 ){

if ( seg[rt].cov ){  // 線(xiàn)段如果是被覆蓋的 , 直接返回這一段區(qū)間的值

return ( seg[rt].right - seg[rt].left + 1 ) * seg[rt].col;

}

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

return quy ( beg, mid, rt << 1 ) + quy ( mid + 1, end, ( rt << 1 ) + 1 );

}


int main ()

{

int T, ca = 1;

scanf ( "%d", &T );

while ( T -- ){

int N;

scanf ( "%d", &N );

creat ( 1, N );

int M;

scanf ( "%d", &M );

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

int beg, end, val;

scanf ( "%d%d%d", &beg, &end, &val );

modify ( beg, end, val );

}

printf ( "Case %d: The total value of the hook is %d.\n", ca++,quy( 1, N ) );

}

    return 0;

}


/*

1

10

2

1 5 2

5 9 3

*/



/*    此為一牛人代碼 , 速度 非常快 !!!! 0rz.........

#include<stdio.h>

int a[100001][3],c[100001];

int main()

{

    int t,i,j,n,m,sum,v,w=1;

    scanf("%d",&t);

    while(t--&&scanf("%d %d",&n,&m))

    {

        sum=0;

        for(i=1;i<=m;i++)

        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);

        for(i=1;i<=n;i++)

        {

            v=1;

            for(j=m;j>=1;j--)

            {

                if(a[j][0]<=i&&a[j][1]>=i)

                {

                    v=a[j][2];

                    break;

                }

            }

            sum+=v;

        }

        printf("Case %d: The total value of the hook is %d.\n",w++,sum);

    }

}



*/

 

Feedback

# re: HDOJ 1698 HDU 1698 Just a Hook ACM 1698 IN HDU[未登錄](méi)  回復(fù)  更多評(píng)論   

2010-09-18 11:18 by bb
下面的代碼只是剛好數(shù)據(jù)不能卡把?復(fù)雜度O(n*m)~

# re: HDOJ 1698 HDU 1698 Just a Hook ACM 1698 IN HDU  回復(fù)  更多評(píng)論   

2010-09-18 11:42 by MiYu
Accepted 1698 437MS 4300K 2117 B C++
這是 線(xiàn)段樹(shù) 的 AC 判定,
Accepted 1698 218MS 1360K 630 B C++
這是后面方法的 AC 判定, 快了 一倍

# re: HDOJ 1698 HDU 1698 Just a Hook ACM 1698 IN HDU[未登錄](méi)  回復(fù)  更多評(píng)論   

2010-09-18 17:39 by bb
不是呀,只是OJ數(shù)據(jù)沒(méi)卡到這方法~~

# re: HDOJ 1698 HDU 1698 Just a Hook ACM 1698 IN HDU  回復(fù)  更多評(píng)論   

2010-10-30 07:56 by MiYu
我覺(jué)得 哪方法 很牛B =. =
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美在线一二三| 激情久久婷婷| 宅男在线国产精品| 亚洲国产视频直播| 农村妇女精品| 欧美aaa级| 欧美a级在线| 国产精品久久国产三级国电话系列| 激情综合亚洲| 亚洲一区三区在线观看| 国产真实久久| 极品av少妇一区二区| 激情综合色综合久久综合| 亚洲激情偷拍| 在线一区视频| 久久漫画官网| 亚洲国产高清在线| 亚洲人成在线免费观看| 在线天堂一区av电影| 亚洲欧美成人| 欧美福利专区| 国产精品一级久久久| 亚洲国产裸拍裸体视频在线观看乱了中文| 亚洲人人精品| 亚洲自拍啪啪| 亚洲国产综合91精品麻豆| 亚洲一级在线| 欧美精品激情在线| 亚洲国产精品久久久久| 亚洲视频在线观看| 欧美大片在线观看一区| 亚洲小说欧美另类社区| 欧美二区在线| 最新成人在线| 欧美 亚欧 日韩视频在线| 亚洲综合色婷婷| 久久免费一区| 亚洲国产成人av| 欧美高清在线视频| 久久亚洲视频| 久久久蜜桃精品| 国产有码一区二区| 久久婷婷久久一区二区三区| 亚洲欧美日韩在线综合| 国产精品日韩久久久| 亚洲摸下面视频| 亚洲欧美综合国产精品一区| 国产精品福利在线| 性做久久久久久免费观看欧美| 99re66热这里只有精品3直播| 亚洲系列中文字幕| 国产一区清纯| 亚洲人体影院| 国产女精品视频网站免费| 免费日韩成人| 亚洲高清在线观看一区| 韩国av一区二区| 亚洲第一福利视频| 欧美日韩一级片在线观看| 亚洲视频一二| 美日韩在线观看| 中文在线资源观看视频网站免费不卡| 亚洲精品影院| 亚洲高清自拍| 亚洲在线视频网站| 一本色道久久综合亚洲精品按摩| 99在线热播精品免费| 精品999成人| 欧美一区免费视频| 中文在线不卡| 欧美黄色视屏| 欧美国产一区二区在线观看 | 美日韩免费视频| 欧美香蕉大胸在线视频观看| 国产一区二区三区无遮挡| 国产日韩欧美综合在线| 91久久极品少妇xxxxⅹ软件| 美国成人毛片| 美女啪啪无遮挡免费久久网站| 亚洲国产精品一区二区三区| 亚洲国产美女精品久久久久∴| 欧美69wwwcom| 亚洲天堂成人在线观看| 亚洲午夜在线观看| 一色屋精品视频在线看| 亚洲国产精品一区二区www在线| 欧美国产高潮xxxx1819| 亚洲伊人一本大道中文字幕| 欧美一区二区三区免费视频| 在线播放国产一区中文字幕剧情欧美| 欧美激情日韩| 国产精品一区二区在线观看不卡 | 亚洲国产精品99久久久久久久久| 亚洲国产经典视频| 国产精品v欧美精品v日韩| 久久亚洲不卡| 欧美日韩在线播放三区| 久久久久久欧美| 欧美精品在线一区二区| 欧美在线观看视频一区二区三区| 久久久久久久波多野高潮日日| 日韩午夜高潮| 欧美主播一区二区三区美女 久久精品人| 亚洲精品日本| 国产精品视频一区二区高潮| 玖玖精品视频| 国产精品一区二区三区观看| 亚洲精品国产精品国自产在线 | 在线一区二区三区四区| 久久精品人人爽| 亚洲小视频在线观看| 久久伊人亚洲| 久久久久www| 国产精品久久久一本精品| 亚洲国产精品成人va在线观看| 国产精品第十页| 亚洲成人中文| 伊人精品成人久久综合软件| 亚洲欧美国产高清| 亚洲少妇最新在线视频| 久久午夜精品| 久久久人人人| 国内精品嫩模av私拍在线观看| 日韩视频在线一区二区三区| 亚洲精品国久久99热| 久久米奇亚洲| 老司机免费视频一区二区三区| 国产精品男gay被猛男狂揉视频| 亚洲精品久久久久久久久久久久| 在线看一区二区| 久久免费精品日本久久中文字幕| 欧美紧缚bdsm在线视频| 久久久久久欧美| 欧美天堂亚洲电影院在线观看| 免费高清在线视频一区·| 国产欧美在线| 午夜视频在线观看一区二区三区 | 午夜日韩视频| 国产日韩欧美在线播放| 亚洲欧美日韩精品久久久久| 亚洲一区二区三区色| 欧美亚洲第一页| 在线综合视频| 久久激情视频久久| 国产一区二区欧美日韩| 久久高清国产| 免费日韩视频| 亚洲乱码日产精品bd| 欧美另类极品videosbest最新版本| 欧美国产欧美亚洲国产日韩mv天天看完整| 久久久久久午夜| 久久久久久久综合色一本| 国产日韩三区| 男女av一区三区二区色多| 91久久精品日日躁夜夜躁欧美| 99精品国产一区二区青青牛奶| 欧美经典一区二区| 在线天堂一区av电影| 久久精品视频在线| 136国产福利精品导航网址应用| 奶水喷射视频一区| 一区二区三区四区在线| 久久久久久伊人| 亚洲欧洲精品一区二区三区| 欧美极品在线播放| 亚洲欧美日韩精品久久奇米色影视| 久久国产黑丝| 亚洲精选成人| 国产日韩在线亚洲字幕中文| 久久久久久欧美| 一本高清dvd不卡在线观看| 欧美一区二区高清在线观看| 黄色精品一区| 欧美日本精品在线| 午夜精品久久久久久久久久久久久| 免费观看成人| 亚洲综合视频网| 影音先锋久久久| 国产精品成人av性教育| 久久久精品tv| 一区二区三区四区国产精品| 久久久久国产精品一区二区| 亚洲精品日本| 欧美成年人视频网站| 亚洲在线视频观看| 亚洲国内高清视频| 午夜一区在线| 亚洲精品久久嫩草网站秘色| 国产精品久久久久久亚洲毛片| 久久se精品一区二区| 亚洲美女一区| 欧美激情小视频| 久久久久99精品国产片| 亚洲欧美韩国| 91久久精品一区二区别| 国产精品亚洲аv天堂网| 欧美久久久久久久久久| 久久久久久网址| 欧美一区二区视频网站| 鲁大师影院一区二区三区|