经典的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开公司的更多相关文章

  1. [BZOJ 1568][JSOI2008]Blue Mary开公司

    [BZOJ 1568][JSOI2008]Blue Mary开公司 题意 \(n\) 次操作, 维护一个一次函数集合 \(S\). 有两种操作: 给定 \(b\) 和 \(k\), 向 \(S\) 中 ...

  2. 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司

    1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 602  Solved: 214[Submit ...

  3. bzoj 1568 [JSOI2008]Blue Mary开公司 超哥线段树

    [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 1808  Solved: 639[Submit][Sta ...

  4. bzoj千题计划219:bzoj1568: [JSOI2008]Blue Mary开公司

    http://www.lydsy.com/JudgeOnline/problem.php?id=1568 写多了就觉着水了... #include<cstdio> #include< ...

  5. 1568: [JSOI2008]Blue Mary开公司

    1568: [JSOI2008]Blue Mary开公司 题目描述 传送门 题目分析 简单分析可以发现就是不停给出了\(n\)条直线,要求每次给出一条直线后求出所有直线在横坐标为\(x\)时\(y\) ...

  6. 1568: [JSOI2008]Blue Mary开公司(超哥线段树)

    1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 1198  Solved: 418 Descr ...

  7. 【BZOJ-1568】Blue Mary开公司 李超线段树 (标记永久化)

    1568: [JSOI2008]Blue Mary开公司 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 557  Solved: 192[Submit ...

  8. 【BZOJ1568】[JSOI2008]Blue Mary开公司(李超线段树)

    [BZOJ1568][JSOI2008]Blue Mary开公司(李超线段树) 题面 BZOJ 洛谷 题解 是模板题啊. #include<iostream> #include<cs ...

  9. 【BZOJ1568】[JSOI2008]Blue Mary开公司 线段树

    [BZOJ1568][JSOI2008]Blue Mary开公司 Description Input 第一行 :一个整数N ,表示方案和询问的总数.  接下来N行,每行开头一个单词“Query”或“P ...

  10. [Luogu] P4254 [JSOI2008]Blue Mary开公司

    题目背景 Blue Mary 最近在筹备开一家自己的网络公司.由于他缺乏经济头脑,所以先后聘请了若干个金融顾问为他设计经营方案. 题目描述 万事开头难,经营公司更是如此.开始的收益往往是很低的,不过随 ...

随机推荐

  1. 【2016-10-10】【坚持学习】【Day1】【观察者模式】

    今天学习了观察者模式 定义: 一个实体变化会影响其他实体变化 例子: 红绿灯与汽车 红绿灯是观察目标 汽车是实际观察者 灯的变化会影响车是停止还是前进. 例子: 游戏中,一个战队由若干队员组成,当其中 ...

  2. 全息眼镜HoloLens可快速捕捉真人3D图像

    http://www.d9soft.com/zixun/62287.html 北京时间3月28日午间消息,微软研发部门开发出一种新的3D视频捕捉系统“Holoportation”,可以实现将某人3D图 ...

  3. 转:Eclipse SVN插件比较 Subclipse vs Subversive

    结论:还是用久经考验的 Subclipse http://www.wkii.org/eclipse-svn-plugins-subclipse-vs-subversive.html

  4. zoj 1610

    Count the Colors Time Limit: 2 Seconds      Memory Limit: 65536 KB Painting some colored segments on ...

  5. page-cache层

    pagecache层内存管理 如果使用page,尤其对于32位系统来说,kmap & kunmap,可以把做struct *page与虚拟地址的映射 用kmap做一个临时的映射,然后通过kun ...

  6. Razor 模板自己渲染出结果 string

    using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNet ...

  7. [转]PHP 下使用 ZeroMQ 和 protobuf

    FROM : http://www.68idc.cn/help/makewebs/php/20150118175432.html 前言 这个记录总的来说分两部分: 搭建环境. 简单使用教程. 搭建环境 ...

  8. Microsoft.Owin.Security.OAuth搭建OAuth2.0授权服务端

    Microsoft.Owin.Security.OAuth搭建OAuth2.0授权服务端 目录 前言 OAuth2.0简介 授权模式 (SimpleSSO示例) 使用Microsoft.Owin.Se ...

  9. zabbix-proxy3.0.4编译安装

    数据库配置: innodb_file_per_table=1   安装mysql rpm -ivh http://dev.mysql.com/get/mysql-community-release-e ...

  10. QT QT练习一

    界面中通过三个 QLineEdit控件,一个QPushButton实现+ - * /四则运算,点击pushbutton后将运算结果显示在QLabel控件上. #ifndef WIDGET_H #def ...