Codeforces 12D Ball(线段树)】的更多相关文章

N ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady…
题目链接:https://cn.vjudge.net/problem/CodeForces-12D 题目大意:给你一个人的三个信息,如果存在一个人比当前人的这三个信息都大,那么这个人就会退出,问你最终有多少人退出. 具体思路:首先按照x的大小排序,大的在前面,然后对y进行离散化,其次就该使用线段树了,将y表示成区间,每一次更新的是y当前的到最大节点,然后线段树中储存的是z值,这样的话,每一次查询,在保证x变大的同时,通过对当前y+1->siz的区间的z值的最大值,就能判断了. AC代码: #in…
codeforces 12D Ball 这道题有两种做法 一种用树状数组/线段树维护区间最值,一种用map维护折线,昨天我刚遇见了一道类似的用STL维护折线的题目: 392D Three Arrays 参考题解:http://blog.csdn.net/rzo_kqp_orz/article/details/70666174 参考代码:http://codeforces.com/contest/392/submission/8930531 现在来谈谈这道题: (借一下另一题题解的图) 假设现在图…
HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #include <bits/stdc++.h> #define nmax 200000 using namespace std; struct Tree{ int l,r,val; int lazy; int mid(){ return (l+r)>>1; } }; Tree tree[nmax&…
Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题目链接]Color the ball [题目类型]线段树区间更新 &题意: N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色.但是N次以后lel…
I - Vasya and a Tree CodeForces - 1076E 其实参考完别人的思路,写完程序交上去,还是没理解啥意思..昨晚再仔细想了想.终于弄明白了(有可能不对 题意是有一棵树n个点,初始时候每个点权值都为0,m次修改,对v的叶子节点且距离小于d的都加上x 也就是v以下d层包括v自身都加上x 问最后每个点的权值 现在一想 用线段树来维护就是很自然的事了 但是要维护什么值呢 维护的就是某个深度上增加的值 先更新 后回溯取消更新 详见代码注释 #include <cstdio>…
D. Legacy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy…
Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 18696    Accepted Submission(s): 9328 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"…
传送门:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25511    Accepted Submission(s): 12393 Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele…
Color the Ball Time Limit: 2 Seconds      Memory Limit: 65536 KB There are infinite balls in a line (numbered 1 2 3 ....), and initially all of them are paint black. Now Jim use a brush paint the balls, every time give two integers a b and follow by…