题目链接

很裸的题, 唯一需要注意的就是询问时给出的区间并不是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. C++ 获取UUID

    #include <string> #include <stdio.h> #if defined(WIN32)||defined(WINCE)||defined(WIN64) ...

  2. svn服务器配置小记

    在这里/opt/svndata/repos1创建svn版本库svnadmin create /opt/svndata/repos1 创建成功后会在/opt/svndata/repos1目录下生成con ...

  3. 判断浏览器 IE 11

    var getOs=function()  {   try {  var u = window.navigator.userAgent.toLocaleLowerCase(),  msie = /(m ...

  4. jqeruy的append一个有趣的用法(挪移控件位置)

    使用:$(放置的容器).append($(需要迁移的控件)) 需求:列表中点击编辑可以在无刷修改 以前的方法是在列表中的每条数据直接放置控件.但是这个地区选择控件是服务器自定义控件不可以放置在列表的循 ...

  5. js关闭 window.open 打开的页面

    1.关闭 当前页面 window.opener = null; window.open('', '_self', ''); window.close(); 但是在FF中就是不行: 2.项目中情况是通过 ...

  6. java通过JNI接口调用C语言-初级

    JNI(java native interface):即java本地调用C的接口. 先看整体运行: 下面是过程: #vim test.java public class test{ public na ...

  7. SQL Server 向堆表中插入数据的过程

    堆表中  IAM 记录着的数据页,表的各个数据页之间没有联系.也就是说一个页面它不会知道自己的前一页是谁,也不知道自己的后一页是谁. 插入数据时先找到IAM页,再由pfs(page free spac ...

  8. Oracle EBS-SQL (BOM-1):检查供应类型错误.sql

    --检查供应类型错误 SELECT MSI.SEGMENT1                物料编码, MSI.DESCRIPTION             物料描述, DECODE(MSI.WIP ...

  9. 11417 - GCD

    Problem A GCD Input: Standard Input Output: Standard Output Given the value of N, you will have to f ...

  10. 每天学点Linux:一

    软链接和硬链接: 软链接,又称符号链接,它的原理是通过一个文本文件记录真实文件在系统中的位置,然后在文件操作的时候通过该地址查找原文件然后对其操作.类似于Windows里面的快捷方式.软链接可以链接不 ...