1. 程式人生 > >Just a Hook 線段樹--成段更新

Just a Hook 線段樹--成段更新

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.

相關推薦

hdu 1698 Just a Hook 線段更新

void log ++ ase scan efi nbsp code upd 線段樹功能:update:成段替換 成段更新去要用到延遲標記,具體調試代碼就容易懂些 #include <iostream> #include <string>

HDU-1698 Just a Hook 線段更新

題目連結 #include "stdio.h" const int maxn = 100050; int n,x,y,z; struct Node { int val; }tree[maxn*4]; void pushup( int t ) { tree

HDU1698 Just a Hook 線段更新

基礎的線段樹成段更新,學習了notonlysuccess dalao的程式碼後寫的 #include<iostream> #include<cstdio> #include<cstring> #include<ctime> #

Just a Hook 線段--更新

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 stic

HDU1698 Just a Hook(線段替換)

Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 28728 Accep

hdu1698 Just a Hook 線段替換

題意:給你T組資料,N個數(初始時每個數的值為1),M個操作,每個操作把區間[a,b]裡的數更新為c,問最後這N個數的和是多少 分析: 因為只是最後查詢總區間的和,所以只需要更新就可以了 #incl

hdu1698 Just a Hook(線段,區間更新)

題目連結:http://acm.split.hdu.edu.cn/showproblem.php?pid=1698 題意: 某個鉤子由n個小鉤子組成,有q個操作,將某個區間內的小鉤子的材料改變,有金銀銅三中材料,每種材料價錢不同。問最後這個鉤子的價值 注意,題目中預設初

hdu1698 Just a Hook (線段,區間更新

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

HDU 1698 Just a Hook 線段(區間更新,詢問總值)

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 sti

Just a Hook (線段,區間更新

hook有三種stick,分別為1號,2號, 3號,長度分別為1,2,3;T個測試樣例, N個stick,Q個操作,每次操作改變x-y區間內stick的值,最後求和; 話不多說,程式碼奉上: #inc

hdu1698 Just a Hook 線段 延時更新

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 sti

Just a Hook ——線段(區間更新

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 stic

HDU 1698 Just a Hook線段更新

there clas class rec std sts present script metal 題目網址:http://acm.hdu.edu.cn/showproblem.php?pid=1698 題目: Problem Description In the ga

HDU 1698 線段更新 Just a Hook

Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8016    Accepted Sub

HDU 1698 Just a Hook 線段 區間更新

不同 描述 感覺 ring 這也 deque deb %d total   題目鏈接: http://acm.hdu.edu.cn/showproblem.php?pid=1698   題目描述: 區間更新, 最後求出1 ~ n 之和     解題思路: 這裏涉及到區間

Just a Hook 線段 區間更新

output nod ins long repr actually max dota metal Just a Hook In the game of DotA, Pudge’s meat hook is actually the most horrible thing

POJ 3468 A Simple Problem with Integers 線段更新

sca query string int open print ring cnblogs pac 線段樹功能   update:成段更新 query:區間求和 #include <iostream> #include <string>

E - Just a Hook (線段+區間更新)

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

1698 Just a Hook 線段區間更新

    線段樹區間更新,有個懶惰標記,每次更新不進行到底,,用懶惰標記使得更新延遲到下次需要更新或者詢問到的時候。線段樹的精髓在於能不向下更新,儘可能利用子樹的根的資訊去獲取整棵子樹的資訊。 #in

HDOJ 1698 Just a Hook (線段區間更新求區間和)

setv[o]表示o結點以下的所有兒子節點上f都沒有被更新。 #include<cstdio> using namespace std; #define ls o<<1 #de