1. 程式人生 > >hdu1698 Just a Hook 線段樹 延時更新

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 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.

相關推薦

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

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

HDU1698 Just a Hook 線段成段更新

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

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

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 線段入門題複習

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=1698 Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (

hdu1698 Just a Hook 線段更新延遲標記

Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is mad

HDU1698 Just a Hook(線段區間更新、區間查詢)

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

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次修改後的整個區間的值之和。 題解: 線段樹。 區間更新

hdu1698 Just a Hook 線段成段替換

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

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

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

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

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

HDU 1698 Just a Hook 線段 區間更新

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