经典的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. LoadRunner11.0下载及安装链接~(By网络)

    Download and install O(∩_∩)O: http://www.jb51.net/softjc/71256.html

  2. 第28章 行为型模式大PK

    27.1 策略模式 VS 命令模式 27.1.1 策略模式实现压缩算法 //行为型模式大PK——策略模式和命令模式 //实例:用策略模式实现压缩算法 #include <iostream> ...

  3. AC日记——整理药名 openjudge 1.7 15

    15:整理药名 总时间限制:  1000ms 内存限制:  65536kB 描述 医生在书写药品名的时候经常不注意大小写,格式比较混乱.现要求你写一个程序将医生书写混乱的药品名整理成统一规范的格式,即 ...

  4. 为什么使用Sass

    为什么使用Sass 作为前端(html.javascript.css)的三大马车之一的css,一直以静态语言存在,HTML5火遍大江南北了.javascript由于NODE.JS而成为目前前后端统一开 ...

  5. ORCHARD 是什么?

    官网 http://orchard.codeplex.com 教程 http://www.cnblogs.com/sunjunlin/p/3876693.html [翻译]从头开始编写一个Orchar ...

  6. [No00000F]Excel快捷键大全 Excel2013/2010/2007/2003常用快捷键大全

    一个软件最大的用处是提高工作效率,衡量一个软件的好坏,除了是否出名之外,最主就是能否让一个新手更快的学会这个软件和提高工作速度.就拿Excel表格来说吧,平常办公中我们经常会用它来制作表格,统计数据或 ...

  7. 适配ipone5

    PROJECT和TARGETS都需要设置

  8. C#的匿名方法

    匿名方法是在初始化委托时内联声明的方法. 例如下面这两个例子: 不使用匿名方法的委托: using System; using System.Collections.Generic; using Sy ...

  9. JavaScript Boolean 对象

    JavaScript Boolean 对象 Boolean 对象 Boolean 对象用于转换一个不是 Boolean 类型的值转换为 Boolean 类型值 (true 或者false). Bool ...

  10. 移动开发webapp开发常用meta设置手机浏览器全屏模式

    1.WebApp全屏模式: <meta name="viewport" content="width=device-width,initial-scale=1.0, ...