题目链接

很裸的题, 唯一需要注意的就是询问时给出的区间并不是l<r, 需要判断然后交换一下, WA了好多发...

#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ull unsigned long long
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-;
const int mod = 1e9+;
const int inf = ;
const int dir[][] = { {-, }, {, }, {, -}, {, } };
const int maxn = ;
int maxx[][maxn<<], max_ans, n;
void pushUp(int pos, int rt) {
maxx[pos][rt] = max(maxx[pos][rt<<], maxx[pos][rt<<|]);
}
void sub_update(int sign, int pos, int y, int l, int r, int rt, int val) {
if(l == r) {
if(!sign) {
maxx[pos][rt] = max(val, maxx[pos][rt]);
} else {
maxx[pos][rt] = max(maxx[pos<<][rt], maxx[pos<<|][rt]);
}
return ;
}
int m = l+r>>;
if(y<=m)
sub_update(sign, pos, y, lson, val);
else
sub_update(sign, pos, y, rson, val);
pushUp(pos, rt);
}
void update(int x, int y, int l, int r, int rt, int val) {
if(l == r) {
sub_update(, rt, y, , n, , val);
return ;
}
int m = l+r>>;
if(x<=m)
update(x, y, lson, val);
else
update(x, y, rson, val);
sub_update(, rt, y, , n, , val);
}
void sub_query(int pos, int L, int R, int l, int r, int rt) {
if(L<=l&&R>=r) {
max_ans = max(max_ans, maxx[pos][rt]);
return ;
}
int m = l+r>>;
if(L<=m)
sub_query(pos, L, R, lson);
if(R>m)
sub_query(pos, L, R, rson);
}
void query(int LX, int RX, int LY, int RY, int l, int r, int rt) {
if(LX<=l&&RX>=r) {
sub_query(rt, LY, RY, , n, );
return ;
}
int m = l+r>>;
if(LX<=m)
query(LX, RX, LY, RY, lson);
if(RX>m)
query(LX, RX, LY, RY, rson);
}
int main()
{
int t, x, y, l, q;
char c[];
n = ;
while (cin>>q&&q) {
mem(maxx);
while(q--) {
int LX, RX, LY, RY;
double a, b;
scanf("%s", c);
max_ans = ;
if(c[] == 'I') {
scanf("%d%lf%lf", &x, &a, &b);
update(x, int(a*), , , , int(b*));
} else {
scanf("%d%d%lf%lf", &LX, &RX, &a, &b);
LY = a*, RY = b*;
if(LX>RX)
swap(LX, RX);
if(LY>RY)
swap(LY, RY);
query(LX , RX, LY, RY, , , );
if(max_ans == ) {
puts("-1");
} else {
printf("%.1f\n", 1.0*max_ans/);
}
}
}
}
}

hdu 1823 Luck and Love 二维线段树的更多相关文章

  1. HDU 1823 Luck and Love 二维线段树(树套树)

    点击打开链接 Luck and Love Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  2. HDU1823 Luck ans Love 二维线段树

    Luck and Love HDU - 1823 世界上上最远的距离不是相隔天涯海角 而是我在你面前 可你却不知道我爱你                 ―― 张小娴 前段日子,枫冰叶子给Wiskey ...

  3. [hdu1823]Luck and Love(二维线段树)

    解题关键:二维线段树模板题(单点修改.查询max) #include<cstdio> #include<cstring> #include<algorithm> # ...

  4. hdu 5465 Clarke and puzzle 二维线段树

    Clarke and puzzle Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  5. HDU 1823 Luck and Love(二维线段树)

    之前只知道这个东西的大概概念,没具体去写,最近呵呵,今补上. 二维线段树 -- 点更段查 #include <cstdio> #include <cstring> #inclu ...

  6. HDU 4819 Mosaic(13年长春现场 二维线段树)

    HDU 4819 Mosaic 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4819 题意:给定一个n*n的矩阵,每次给定一个子矩阵区域(x,y,l) ...

  7. Luck and Love(二维线段树)

    Luck and Love Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...

  8. hdu 4819 二维线段树模板

    /* HDU 4819 Mosaic 题意:查询某个矩形内的最大最小值, 修改矩形内某点的值为该矩形(Mi+MA)/2; 二维线段树模板: 区间最值,单点更新. */ #include<bits ...

  9. HDU 4819 Mosaic (二维线段树)

    Mosaic Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total S ...

随机推荐

  1. html系列教程--标题,水平线,注释以及段落

    HTML标题 标题,用来显示文章重要性的文字,包含了文章的主旨,类似于作文题目. 标题(Heading)是通过 <h1> - <h6> 等标签进行定义的,由大到小一次排列,h1 ...

  2. SQL Server 触发器2

    触发器可以做很多事情,但也会带来很多问题.使用它的技巧在于在适当的时候使用,而不要在不适当的时候使用它们. 触发器的一些常见用途如下: 弹性参照完整性:实现很多DRI不能实现的操作(例如,跨数据库或服 ...

  3. C#:读取配置文件

    以下代码演示如何读取配置文件---------------------Factory.cs----------------------------using System;using System.C ...

  4. NULL、空指针,’\0’,0的去区别

    http://blog.csdn.net/bailyzheng/article/details/7677628参考该博客 NULL是空指针常量.

  5. echo向文件中写入

    echo命令向一个文件写入内容的方法详解,感兴趣的朋友可以参考下. 覆盖型写法 (文件里原来的内容被覆盖)echo "aaa" > a.txtecho aaa > a. ...

  6. python打包成.exe工具py2exe0-----No such file or directory错误

    转自:http://justcoding.iteye.com/blog/900993 一.简介 py2exe是一个将python脚本转换成windows上的可独立执行的可执行程序(*.exe)的工具, ...

  7. 关于三星手机照相机调用适配问题Android

    因为三星手机在照相的时候,会自动将自动转化为为横屏. 这里的话 就不讲具体怎么实现的,因为在网络上是有相关的代码. 主要的是在你拍完照返回的时候,先前的界面可能会重绘,所以会导致一些问题. 我暂时的办 ...

  8. 关于wireshark的两个抓包过滤显示的基本语法

    关于wireshark的两个基本语法 关于wireshark的两个基本语法 1. Capture Filters 语法:<Protocol name><Direction>&l ...

  9. nodeJs入门笔记(二)

    js中window通常是全局变量 global 是node.js里的全局变量 node中能访问的对象一般都是 global的 属性 global 对象属性 process 用于描述当前Node 进程状 ...

  10. 航频卫士APP截图