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 線段 區間更新

不同 描述 感覺 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

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

HDU1698 Just a Hook 線段區間更新

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

HDU-1698 Just a Hook 線段區間更新

題意:一個長度為n的線段,q個操作,每個操作x,y,z是指把區間[x,y]內的值修改為z,最後求線段值的和。 思路:增加懶惰標誌,每次更新操作只更新到這個區間節點而不是這個區間的所有葉子結點。例如操作1,5,2。只更新到節點[1,5]而不是他的五個葉子結點

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(線段區間更新區間查詢)

題目連結 題意 在 DotA 遊戲中,帕吉的肉鉤是很多英雄最害怕的東西。鉤子由連續若干段的等長金屬棒製成。 現在帕吉對鉤子由一些操作: 我們將金屬棒 1~n 依次編號,帕吉可以把編號 x~y 的金屬棒變成銅棒、銀棒、金棒。 每段銅棒的價值是 1;每

HDU 1698 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 made

HDOJ1698 Just a Hook 線段區間更新

分析:一道比較裸的線段樹區間更新題,對比正常的線段樹問題,主要是每一次都對節點進行直接賦值,另外注意初始值為1。 程式碼: #include <iostream> #include <cstdio> #include <cstring&

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(線段區間更新)

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 線段 區間更新 懶操作

題目連結: 題意: 輸入一個n表示一段長度為n的區間,有n個編號為1~n的點,初始值全部為1。 有q個操作, 每個操作有3個數:l,r,v表示將區間l~r的所有元素修改為v。 求經過q次修改後的整個區間的值之和。 題解: 線段樹。 區間更新

HDU 1698 Just a Hook 線段區間修改

題意: 給定N個數,初始化全部為1. 一種操作,區間修改。把區間[L,R]內所有數字修改為另一個值X Q次操作之後,求區間[1,N]的和 分析: 簡單的線段樹區間修改操作應用題 具體實現見程式碼 #

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

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