bzoj3878
当初只会暴力,现在差不多觉得水了
显然离线处理,对输入的数排序然后会发现不管怎么修改都是结果总是单调不降的
对于每次处理,我们只要找到那段越界的即可
显然上线段树,话说jsoi这么喜欢线段树?
下面在bzoj上过不去,因为pascal编译器处理比较严格,可能某处爆了int64,我也懒得查了,本地是能过的
type node=record
mi,mx,att,mul,an:int64;
end; var tree:array[..*] of node;
ans,b,c:array[..] of longint;
a:array[..] of int64;
ch:array[..] of char;
m,f,t,i,n:longint; procedure swap(var a,b:longint);
var c:longint;
begin
c:=a;
a:=b;
b:=c;
end; procedure sort(l,r:longint);
var i,j:longint;
x,y:int64; begin
i:=l;
j:=r;
x:=a[(l+r) shr ];
repeat
while a[i]<x do inc(i);
while x<a[j] do dec(j);
if not(i>j) then
begin
y:=a[i]; a[i]:=a[j]; a[j]:=y;
swap(c[i],c[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end; procedure cal(i,x,y:longint;x1,x2,x3:int64);
begin
with tree[i] do
begin
mi:=mi*x1+x2*a[x]+x3;
mx:=mx*x1+x2*a[y]+x3;
mul:=mul*x1;
att:=att*x1;
an:=an*x1;
att:=att+x2;
an:=an+x3;
end;
end; procedure build(i,l,r:longint);
var m:longint;
begin
tree[i].mi:=a[l];
tree[i].mx:=a[r];
tree[i].mul:=;
if l<>r then
begin
m:=(l+r) shr ;
build(i*,l,m);
build(i*+,m+,r);
end;
end; procedure push(i,l,r:longint);
var m:longint;
begin
m:=(l+r) shr ;
with tree[i] do
begin
cal(i*,l,m,mul,att,an);
cal(i*+,m+,r,mul,att,an);
mul:=;
att:=;
an:=;
end;
end; procedure max(i,l,r:longint);
var m:longint;
begin
if l=r then cal(i,l,l,,,t)
else begin
m:=(l+r) shr ;
push(i,l,r);
if tree[i*].mx>t then
begin
cal(i*+,m+,r,,,t);
max(i*,l,m);
end
else max(i*+,m+,r);
tree[i].mx:=tree[i*+].mx;
tree[i].mi:=tree[i*].mi;
end;
end; procedure min(i,l,r:longint);
var m:longint;
begin
if l=r then cal(i,l,l,,,f)
else begin
m:=(l+r) shr ;
push(i,l,r);
if tree[i*+].mi<f then
begin
cal(i*,l,m,,,f);
min(i*+,m+,r);
end
else min(i*,l,m);
tree[i].mx:=tree[i*+].mx;
tree[i].mi:=tree[i*].mi;
end;
end; procedure ask(i,l,r:longint);
var m:longint;
begin
if l=r then
ans[c[l]]:=tree[i].mx
else begin
m:=(l+r) shr ;
push(i,l,r);
ask(i*,l,m);
ask(i*+,m+,r);
end;
end; begin
readln(m,f,t);
for i:= to m do
readln(ch[i],b[i]);
readln(n);
for i:= to n do
begin
readln(a[i]);
if a[i]>t then a[i]:=t;
if a[i]<f then a[i]:=f;
c[i]:=i;
end;
sort(,n);
build(,,n);
for i:= to m do
if ch[i]='+' then
begin
cal(,,n,,,b[i]);
if tree[].mx>t then max(,,n);
end
else if ch[i]='-' then
begin
cal(,,n,,,-b[i]);
if tree[].mi<f then min(,,n);
end
else if ch[i]='*' then
begin
cal(,,n,b[i],,);
if tree[].mx>t then max(,,n);
end
else begin
cal(,,n,,b[i],);
if tree[].mx>t then max(,,n);
end;
ask(,,n);
for i:= to n do
writeln(ans[i]);
end.
bzoj3878的更多相关文章
- BZOJ3878: [Ahoi2014&Jsoi2014]奇怪的计算器
BZOJ3878: [Ahoi2014&Jsoi2014]奇怪的计算器 Description [故事背景] JYY有个奇怪的计算器,有一天这个计算器坏了,JYY希望你能帮助他写 一个程序来模 ...
- 2018.07.25 bzoj3878: [Ahoi2014&Jsoi2014]奇怪的计算器(线段树)
传送门 线段树综合. 让我想起一道叫做siano" role="presentation" style="position: relative;"&g ...
- [暑假的bzoj刷水记录]
(这篇我就不信有网站来扣) 这个暑假打算刷刷题啥的 但是写博客好累啊 堆一起算了 隔一段更新一下. 7月27号之前刷的的就不写了 , 写的累 代码不贴了,可以找我要啊.. 2017.8.27upd ...
随机推荐
- JSON的基本格式以及与JavaScript之间的转换
JSON的基本格式以及与JavaScript之间的转换 近来,发现很多人写json格式的数据时,总是没有达到JSON的规范,虽然在语言要求不严格的情况下能够通过, 但是,难免会遇到这样那样的问题,到时 ...
- 九度OJ 1056--最大公约数 1439--Least Common Multiple 【辗转相除法】
题目地址:http://ac.jobdu.com/problem.php?pid=1056 题目描述: 输入两个正整数,求其最大公约数. 输入: 测试数据有多组,每组输入两个正整数. 输出: 对于每组 ...
- 【转】使用DevExpress的WebChartControl控件绘制图表(柱状图、折线图、饼图)
第一次写博,没什么经验,主要是把最近自己对Dev的一些研究贴出来大家共同探讨,有不足之处望大家帮忙斧正. WebChartControl是DevExpress控件群下的一个Web图表控件,它使用非常的 ...
- 前端资源多个产品整站一键打包&包版本管理(三)—— gulp分流
问题: 当我们一个工作台里面有好几个项目的时候,我们要为项目的前端资源进行打包,但是,gulpfile只有一个,如果我们把所有的打包都放在同一个文件里面,首先文件会越来越大,而且不便于管理,这时,我们 ...
- eclipse中配置maven的web项目
提高效率,一般都会使用IED如eclipse来帮助开发.eclipse中单独建立一个web项目或者是maven项目是可以通过插件很容易完成的,但是如果要结合2者,就需要先建立一个,然后再转换或使原型. ...
- VB6-系统打印常识
在一次做图片打印的时候,对位置的调整老是不得法,后来通过CBM666老师的帮助才解决问题,分享以下他给的帮助. , , picA.Width , picA.Height Printer.End ...
- 一步步学习ASP.NET MVC3 (14)——Route路由
请注明转载地址:http://www.cnblogs.com/arhat 由于今天是星期六,所以多写几篇,感觉前几天的忙碌没有及时发布文章,趁着周末老魏尽力的多写几篇文章.因为本系列基本上快结束了,所 ...
- Java 中正确使用 hashCode 和 equals 方法
在这篇文章中,我将告诉大家我对hashCode和equals方法的理解.我将讨论他们的默认实现,以及如何正确的重写他们.我也将使用Apache Commons提供的工具包做一个实现. 目录: hash ...
- entity framework in mysql
To start using Entity Framework 6 and Visual Studio 2013 is necessary to install MySQL for Visual St ...
- iOS8上放大缩小的动画
CGAffineTransformMakeScale这个方法我们以前经常使用,但是在IOS8上出现问题了 [UIView animateWithDuration:0.3 animations:^{ b ...