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

ACM___________________________

______________白白の屋
posts - 182, comments - 102, trackbacks - 0, articles - 0
<2010年9月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

常用鏈接

留言簿(24)

隨筆分類(332)

隨筆檔案(182)

FRIENDS

搜索

積分與排名

最新隨筆

最新評論

閱讀排行榜

評論排行榜

MiYu原創(chuàng), 轉(zhuǎn)帖請注明 : 轉(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)的線段樹,  成段更新 ,......     具體看 代碼 注釋 .

 

代碼如下 :

 /*

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)前線段是否被覆蓋, 如果true, 表示這一段線段的值都為 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 ){ //線段被覆蓋, 標(biāo)記 cov 為true  

seg[rt].cov = true;

seg[rt].col = val;

return ;

}

if ( seg[rt].cov ){ //如果線段曾經(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 ){  // 線段如果是被覆蓋的 , 直接返回這一段區(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[未登錄]  回復(fù)  更多評論   

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ù)  更多評論   

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

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

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

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

2010-10-30 07:56 by MiYu
我覺得 哪方法 很牛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>
            久久久久久久999精品视频| 99re6这里只有精品| 亚洲欧美文学| 日韩一区二区免费高清| 国产一区二区三区高清播放| 欧美日韩一区二区三区免费| 久热精品在线视频| 欧美尤物一区| 亚洲欧美成人一区二区三区| 99精品视频免费观看| 亚洲高清二区| 欧美va日韩va| 久久欧美中文字幕| 欧美专区18| 欧美亚洲免费电影| 亚洲欧美日韩一区在线| 在线综合亚洲欧美在线视频| 亚洲乱码国产乱码精品精可以看| 亚洲高清资源综合久久精品| 黄色一区三区| 激情视频一区二区| 激情综合网激情| 韩国女主播一区| 黄色亚洲在线| 极品少妇一区二区三区| 国模私拍视频一区| 国内精品**久久毛片app| 国产日韩欧美综合一区| 国产午夜精品久久久久久免费视| 国产噜噜噜噜噜久久久久久久久| 国产精品三区www17con| 国产精品免费视频xxxx| 国产精品一区二区久久精品| 国产视频久久| 国内精品久久久久久久影视蜜臀 | 欧美激情1区2区| 免费在线观看成人av| 欧美阿v一级看视频| 亚洲电影av| 亚洲日本在线观看| 夜夜嗨av色一区二区不卡| 久久影音先锋| 久久视频一区二区| 久久一区二区三区超碰国产精品| 久久色在线观看| 免费试看一区| 亚洲精品1区2区| 日韩午夜精品视频| 亚洲伊人观看| 久久精品人人做人人爽电影蜜月| 久久综合电影| 欧美美女喷水视频| 国产精品视频福利| 国内精品久久久久影院薰衣草| 亚洲第一精品福利| 一本色道久久综合亚洲精品按摩 | 久久久久亚洲综合| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久亚洲综合色| 欧美国产亚洲视频| 一本色道久久综合一区| 欧美制服丝袜第一页| 欧美不卡福利| 国产精品人成在线观看免费| 在线观看成人小视频| 一本大道久久a久久精二百| 欧美在线观看一区| 欧美国产综合视频| 亚洲欧美国产77777| 免费在线观看日韩欧美| 国产精品久久久久久久久| 一区免费观看视频| 亚洲婷婷综合久久一本伊一区| 久久久久在线| 一本久久a久久免费精品不卡| 久久精品中文| 国产精品久久久久久久久久免费看 | 欧美国产日产韩国视频| 国产欧美日韩精品在线| 亚洲三级免费| 久久久av网站| 99国产精品视频免费观看一公开| 久久精品国产一区二区三区| 欧美日韩综合精品| 亚洲高清av| 久久动漫亚洲| 亚洲最新色图| 欧美h视频在线| 国内一区二区在线视频观看| 亚洲一区二区三区中文字幕在线| 欧美高清日韩| 久久精品72免费观看| 国产精品激情电影| 一本久久综合亚洲鲁鲁五月天| 美日韩丰满少妇在线观看| 亚洲一区在线观看免费观看电影高清| 欧美成年人视频网站欧美| 国产专区精品视频| 亚洲欧美一区二区原创| 亚洲精品乱码久久久久久蜜桃麻豆 | 国内精品国语自产拍在线观看| 亚洲桃色在线一区| 亚洲福利视频二区| 久久久在线视频| 国产一区二区精品久久99| 亚洲一区二区免费视频| 亚洲黄网站在线观看| 久久久一区二区三区| 国产一区二区三区久久久久久久久 | 亚洲激情自拍| 蜜臀av一级做a爰片久久| 黄色成人片子| 久久久久久久网| 香蕉乱码成人久久天堂爱免费| 国产精品二区影院| 中国女人久久久| 亚洲日本中文| 欧美人成在线| av成人动漫| 亚洲精品一二区| 99国产一区| 蜜臀av在线播放一区二区三区| 亚洲女爱视频在线| 国产精品美腿一区在线看| 一本大道久久a久久精品综合| 亚洲国产视频直播| 欧美精品电影| 日韩亚洲不卡在线| 亚洲精品欧美精品| 欧美日韩精品一区二区在线播放| 亚洲精品系列| 亚洲精品一区二区三区四区高清 | 欧美日韩国产限制| 99在线热播精品免费| 99精品免费| 国产精品―色哟哟| 久久精品免费看| 久久精品国产在热久久| 亚洲成色777777在线观看影院| 欧美成人精品在线观看| 欧美黄色视屏| 亚洲第一综合天堂另类专| 免费91麻豆精品国产自产在线观看| 久久夜色精品国产噜噜av| 亚洲黄色一区| 日韩一二在线观看| 国产精品午夜春色av| 久久久无码精品亚洲日韩按摩| 久久久久在线观看| 99视频一区二区| 亚洲一区二区视频在线观看| 国产一二三精品| 亚洲国产成人av好男人在线观看| 欧美日韩1区2区3区| 性欧美大战久久久久久久免费观看 | 亚洲人成在线观看| 一区二区三区福利| 国内自拍一区| 亚洲精品国产视频| 国产精品久久久久婷婷| 噜噜噜91成人网| 欧美日韩免费网站| 久久国产综合精品| 欧美黑人在线播放| 久久国产精品色婷婷| 欧美成在线视频| 欧美一区二区在线观看| 免费成年人欧美视频| 亚洲欧美日韩一区在线| 久久先锋影音av| 亚洲永久网站| 久久综合激情| 午夜欧美精品久久久久久久| 久热精品在线视频| 欧美永久精品| 欧美片第一页| 美女国产精品| 国产乱肥老妇国产一区二| 亚洲高清精品中出| 精品福利av| 欧美成人精品一区| 亚洲中无吗在线| 在线精品亚洲| 亚洲国产精品一区在线观看不卡 | 揄拍成人国产精品视频| 欧美一区二区啪啪| 欧美伊人影院| 国产精品色午夜在线观看| 99精品福利视频| 在线视频你懂得一区 | 日韩午夜激情av| 欧美阿v一级看视频| 欧美国产日韩亚洲一区| 亚洲国产精品久久久久| 六月婷婷一区| 欧美黑人一区二区三区| 亚洲人午夜精品免费| 欧美jjzz| 亚洲精品美女| 亚洲性感激情|