【BZOJ 1568】【JSOI 2008】Blue Mary开公司
经典的splay维护凸壳,但是看了看zky学长的题解最后决定写线段树维护标记永久化。
Round1考到了这个之后一直没有理解标记永久化,CTSC也因为自己的缺陷丢掉了一些部分分,so sad
看来以后不懂的东西要及时学啊QwQ
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node {
double k, b; bool p;
node(int xa = 0, int ya = 0, int xb = 0, int yb = 0, bool num = 0) {
p = num;
if (xa == xb) {k = 0; b = max(ya, yb);}
else {k = (ya - yb) / (xa - xb); b = ya - xa * k;}
}
double get(int x) {return k * x + b;}
};
bool lessthan(node A, node B, double x) {
if (!A.p) return 1;
double na = A.get(x), nb = B.get(x);
return na == nb ? A.p < B.p : na < nb;
} int n = 50000;
node T[200003];
node Q(int rt, int l, int r, int pos) {
if (l == r) return T[rt];
node tmp; int mid = (l + r) >> 1;
tmp = (pos <= mid) ? Q(rt << 1, l, mid, pos) : Q(rt << 1 | 1, mid + 1, r, pos);
return lessthan(T[rt], tmp, pos) ? tmp : T[rt];
}
void ins2(int rt, int l, int r, node se) {
if (!T[rt].p) {T[rt] = se; return;}
if (lessthan(T[rt], se, l)) swap(T[rt], se);
if (l == r || T[rt].k == se.k) return; //!!!
double x = (T[rt].b - se.b) / (se.k - T[rt].k); int mid = (l + r) >> 1;
if (x < l || x > r) return;
if (x <= mid) ins2(rt << 1, l, mid, T[rt]), T[rt] = se; else ins2(rt << 1 | 1, mid + 1, r, se);
}
void ins1(int rt, int l, int r, int L, int R, node se) {
if (L <= l && r <= R) {ins2(rt, l, r, se); return;}
int mid = (l + r) >> 1;
if (L <= mid) ins1(rt << 1, l, mid, L, R, se);
if (R > mid) ins1(rt << 1 | 1, mid + 1, r, L, R, se);
} int main() {
double S, P; node tmp; int T, pos; scanf("%d", &T); char c[15];
while (~scanf("%s", c)) {
if (c[0] == 'Q') {
scanf("%d", &pos);
printf("%lld\n", (long long) (Q(1, 1, n, pos).get(pos) / 100 + 1e-8));
} else {
scanf("%lf%lf", &S, &P);
tmp.k = P; tmp.b = S - P; tmp.p = 1;
ins1(1, 1, n, 1, n, tmp);
}
}
return 0;
}
Round2加油吧ovo
【BZOJ 1568】【JSOI 2008】Blue Mary开公司的更多相关文章
- [BZOJ 1568][JSOI2008]Blue Mary开公司
[BZOJ 1568][JSOI2008]Blue Mary开公司 题意 \(n\) 次操作, 维护一个一次函数集合 \(S\). 有两种操作: 给定 \(b\) 和 \(k\), 向 \(S\) 中 ...
- 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 602 Solved: 214[Submit ...
- bzoj 1568 [JSOI2008]Blue Mary开公司 超哥线段树
[JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1808 Solved: 639[Submit][Sta ...
- bzoj千题计划219:bzoj1568: [JSOI2008]Blue Mary开公司
http://www.lydsy.com/JudgeOnline/problem.php?id=1568 写多了就觉着水了... #include<cstdio> #include< ...
- 1568: [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司 题目描述 传送门 题目分析 简单分析可以发现就是不停给出了\(n\)条直线,要求每次给出一条直线后求出所有直线在横坐标为\(x\)时\(y\) ...
- 1568: [JSOI2008]Blue Mary开公司(超哥线段树)
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 1198 Solved: 418 Descr ...
- 【BZOJ-1568】Blue Mary开公司 李超线段树 (标记永久化)
1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec Memory Limit: 162 MBSubmit: 557 Solved: 192[Submit ...
- 【BZOJ1568】[JSOI2008]Blue Mary开公司(李超线段树)
[BZOJ1568][JSOI2008]Blue Mary开公司(李超线段树) 题面 BZOJ 洛谷 题解 是模板题啊. #include<iostream> #include<cs ...
- 【BZOJ1568】[JSOI2008]Blue Mary开公司 线段树
[BZOJ1568][JSOI2008]Blue Mary开公司 Description Input 第一行 :一个整数N ,表示方案和询问的总数. 接下来N行,每行开头一个单词“Query”或“P ...
- [Luogu] P4254 [JSOI2008]Blue Mary开公司
题目背景 Blue Mary 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...
随机推荐
- NYOJ-取石子(二)
取石子(二) 时间限制:3000 ms | 内存限制:65535 KB 难度:5 描述 小王喜欢与同事玩一些小游戏,今天他们选择了玩取石子. 游戏规则如下:共有N堆石子,已知每堆中石子的数量,并且 ...
- 第18章 图元文件_18.2 增强型图元文件(emf)(1)
18.2 增强型图元文件(emf) 18.2.1 创建并显示增强型图元文件的步骤 (1)创建:hdcEMF = CreateEnhMetaFile(hdcRef,szFilename,lpRect,l ...
- AC日记——简单密码 openjudge 1.7 10
10:简单密码 总时间限制: 1000ms 内存限制: 65536kB 描述 Julius Caesar曾经使用过一种很简单的密码.对于明文中的每个字符,将它用它字母表中后5位对应的字符来代替,这 ...
- TortoiseSVN status cache占用CPU高
进程占用CPU高 每次从SVN上更新资源时,电脑都会卡死,直到资源更新完.当要Commit资源时,SVN也会卡死资源管理器,如下图所示: 解决占用CPU高的问题 1.禁用图标缓存 2.排除路径和包含路 ...
- Unity 实现物体破碎效果(转)
感谢网友分享,原文地址(How to Make an Object Shatter Into Smaller Fragments in Unity),中文翻译地址(Unity实现物体破碎效果) In ...
- Navigator 对象
Navigator 对象 Navigator 对象包含有关浏览器的信息. 注意: 没有应用于 navigator 对象的公开标准,不过所有浏览器都支持该对象. Navigator 对象属性 属性 说明 ...
- Dubbo架构设计详解
from:http://shiyanjun.cn/archives/325.html Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按照分层的方式来架构,使用这种方式可以使各个层之间解 ...
- redis采用tcmalloc导致无法释放内存的问题
from:http://wangneng-168.iteye.com/blog/2100379 redis使用tcmalloc管理内存,当删除了redis的key后,通过redis的info命令查看内 ...
- Java数据类型和变量
Java中存在2种数据类型,下面我们来详解一下: 基本数据类型: 引用数据类型: 可以用一张表来记录: 基本数据类型 整型 byte:1个字节8位,取值范围为:[-128, 127],直接写值:(by ...
- Centos6.4安装erlang并配置mysql数据库
在安装时,一定要使用Centos6.4光盘为yum源,否则可能使用了版本有问题的openssl 1.首先要先安装GCC GCC-C++ Openssl等依赖模块: yum -y install mak ...