uoj#119. 【UR #8】决战圆锥曲线
可以认为数据基本随机,于是可以直接用线段树维护,对每个询问在线段树上进行剪枝搜索。
#include<bits/stdc++.h>
typedef long long i64;
char ib[],*ip=ib,ob[],*op=ob;
int _(){
int x=;
while(*ip<)++ip;
while(*ip>)x=x*+*ip++-;
return x;
}
void pr(i64 x){
int ss[],sp=;
do ss[++sp]=x%;while(x/=);
while(sp)*op++=ss[sp--]+;
*op++=;
}
i64 max(i64 a,i64 b){return a>b?a:b;}
int n,m,seed,_l,_r;
i64 A,B,C,ans;
int mt(){
seed=(seed*100000005ll+)%;
return seed/;
}
struct node{
node*lc,*rc;
int L,R,M;
int rv;
i64 y1,y2,xy1,xy2;
void _rv(){
std::swap(y1,y2);
std::swap(xy1,xy2);
rv^=;
}
void dn(){
if(rv){
rv=;
lc->_rv();
rc->_rv();
}
}
void up(){
y1=max(lc->y1,rc->y1);
y2=max(lc->y2,rc->y2);
xy1=max(lc->xy1,rc->xy1);
xy2=max(lc->xy2,rc->xy2);
}
void init(int v){
y1=v,y2=-v;
xy1=i64(L)*y1,xy2=i64(L)*y2;
}
void chg(){
if(L==R)return init(A);
dn();
(_l<=M?lc:rc)->chg();
up();
}
void rev(){
if(_l<=L&&R<=_r)return _rv();
dn();
if(_l<=M)lc->rev();
if(_r>M)rc->rev();
up();
}
i64 cal(){
return A*R+B*y1+C*xy1;
}
void find(i64 v){
if(_l>R||_r<L||v<=ans)return;
if(L==R)return void(ans=v);
dn();
i64 vl=lc->cal(),vr=rc->cal();
if(vl>vr)lc->find(vl),rc->find(vr);
else rc->find(vr),lc->find(vl);
}
}ns[],*np=ns,*rt;
node*build(int L,int R){
node*w=np++;
w->L=L,w->R=R;
if(L<R){
int M=w->M=L+R>>;
w->lc=build(L,M);
w->rc=build(M+,R);
w->up();
}else w->init(mt()%);
return w;
}
int main(){
fread(ib,,sizeof(ib),stdin);
n=_(),m=_(),seed=_();
rt=build(,n);
while(m--){
int o=_();
if(o=='C'-){
_l=mt()%n+,A=mt()%;
rt->chg();
}else{
_l=mt()%n+,_r=mt()%n+;
if(_l>_r)std::swap(_l,_r);
if(o=='R'-){
rt->rev();
}else{
A=_(),B=_(),C=_();
ans=;
if(A|B|C)rt->find(rt->cal());
pr(ans);
}
}
}
fwrite(ob,,op-ob,stdout);
return ;
}
uoj#119. 【UR #8】决战圆锥曲线的更多相关文章
- uoj#119. 【UR #8】决战圆锥曲线(线段树+复杂度分析)
题解 传送门 题解 然而要我来说我感觉只是个爆搜啊-- //minamoto #include<bits/stdc++.h> #define R register #define ll l ...
- UOJ 【UR #5】怎样跑得更快
[UOJ#62]怎样跑得更快 题面 这个题让人有高斯消元的冲动,但肯定是不行的. 这个题算是莫比乌斯反演的一个非常巧妙的应用(不看题解不会做). 套路1: 因为\(b(i)\)能表达成一系列\(x(i ...
- UOJ #22 UR #1 外星人
LINK:#22. UR #1 外星人 给出n个正整数数 一个初值x x要逐个对这些数字取模 问怎样排列使得最终结果最大 使结果最大的方案数又多少种? n<=1000,x<=5000. 考 ...
- UOJ.52.[UR #4]元旦激光炮(交互 思路)
题目链接 \(Description\) 交互库中有三个排好序的,长度分别为\(n_a,n_b,n_c\)的数组\(a,b,c\).你需要求出所有元素中第\(k\)小的数.你可以调用至多\(100\) ...
- UOJ【UR #12】实验室外的攻防战
题意: 给出一个排列$A$,问是否能够经过以下若干次变换变为排列$B$ 变换:若${A_i> A_i+1}$,可以${swap(A_i,A_i+1)}$ 考虑一个数字从A排列到B排列连出来的路径 ...
- ZJOI2019Round#1
考的这么差二试基本不用去了 不想说什么了.就把这几天听课乱记的东西丢上来吧 这里是二试乱听课笔记ZJOI2019Round#2 ZJOI Round#1 Day1 M.<具体数学>选讲 罗 ...
- 【UOJ#33】【UR#2】树上GCD 有根树点分治 + 容斥原理 + 分块
#33. [UR #2]树上GCD 有一棵$n$个结点的有根树$T$.结点编号为$1…n$,其中根结点为$1$. 树上每条边的长度为$1$.我们用$d(x,y)$表示结点$x,y$在树上的距离,$LC ...
- uoj #118. 【UR #8】赴京赶考 水题
#118. [UR #8]赴京赶考 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://uoj.ac/problem/118 Description ...
- uoj #31. 【UR #2】猪猪侠再战括号序列 贪心
#31. [UR #2]猪猪侠再战括号序列 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://uoj.ac/problem/31 Descript ...
随机推荐
- Prime Test(POJ 1811)
素数判定的模板题,运用米勒-罗宾素数判定,然后用Pollard_Rho法求出质因数.使用相应的模板即可,不过注意存储质因子的数组需要使用vector,并且使用long long类型存储,不然存储不下, ...
- Tomcat建立多个应用(Web Server),多个主机,多个站点的方法
https://blog.csdn.net/chungle2011/article/details/52317433 http://piperzero.iteye.com/blog/1475773 转 ...
- 顺平讲try catch finally throw throws(精华)
try catch finally 有点像if else语句 还有像javascript的服务器执行成功后的回调函数,success:function(){ 进行处理 }; throws的意思是将异 ...
- gdb入门
下面是我自己写的一个测试用例 a.c #include<stdio.h> int add(int a,int b){ return a+b; } int main(){ int n=add ...
- centos7配置lamp成功安装过
linux+apache+mysql/mariadb+php 首先apache的安装: yum install httpd 接着mysql/mariadb的安装: yum install mysql ...
- Behavior Designer 学习
http://www.opsive.com/ 简单Demo Sequence Selector Chase Enemy enemy:player:
- Sql server日期函数用法
SQL日期函数 SQL日期函数中的类型码可以为0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 ,20,21,22,23,24,25,100,101,102,103,104,105 ...
- Laya播放unity特效
杭州-fun 2017/12/5 20:47:12 其实网上就有你搜下就有了现成的脚本,设置帧数和截取时间它会截屏并保存成贴图导入laya生成atlas就能用了 就是unity的截屏功能 就 ...
- bfprt
bfprt //找第k小的数 #include <iostream> #include <vector> #include <algorithm> using na ...
- mvn+spring+webapp模板
idea新建项目,选择maven-archetype-webapp 在main目录下创建java resource 文件夹,赋予特殊文件夹 pom.xml 添加 <!--Spring框架核心库 ...