UOJ#191. 【集训队互测2016】Unknown

UOJ#191. 【集训队互测2016】Unknown

题目描述

Solution

二进制分组。
每一个组内维护一个斜率单调减的凸包。
因为有删点,避免出现反复横跳产生的爆炸复杂度,需要等到同一深度的下一个区间填满之后再合并当前区间。
时间复杂度O(nlg2n)O(nlg^2n)O(nlg2n)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se secondusing namespace std;template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{int f=1,x=0; char c=getchar();while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }return x*f;
}
struct Vct
{int x,y;Vct(int x1=0,int y1=0) { x=x1,y=y1; }Vct operator + (const Vct &a) { return Vct(x+a.x,y+a.y); }Vct operator - (const Vct &a) { return Vct(x-a.x,y-a.y); }ll operator * (const Vct &a) { return 1ll*x*a.y-1ll*y*a.x; }friend bool operator < (const Vct &a,const Vct &b) { return (a.x<b.x)||(a.x==b.x&&a.y<b.y); }
};
struct Convex_Hull
{vector<Vct> V;void Clear() { V.clear(); }Convex_Hull(){ Clear(); }void Push(Vct x) { int n=V.size(); while (n>=2&&(x-V[n-2])*(V[n-1]-V[n-2])<=0) V.pop_back(),n--; n++,V.PB(x); }friend Convex_Hull Merge(const Convex_Hull &x,const Convex_Hull &y){Convex_Hull ans;int i,j;for (i=0,j=0;i<x.V.size()&&j<y.V.size();) ans.Push(x.V[i]<y.V[j]?x.V[i++]:y.V[j++]);for (;i<x.V.size();) ans.Push(x.V[i++]);for (;j<y.V.size();) ans.Push(y.V[j++]);return ans;}ll Query(Vct x){int l=0,r=V.size()-1;while (l+5<r){int mid=(l+r+1)>>1;if ((V[mid]-V[mid-1])*x<=0) l=mid;else r=mid-1;}ll ans=-loo;for (int i=l;i<=r;i++) upmax(ans,x*V[i]);return ans;}
};
struct Segment_Tree
{int flag[MAXN<<1],lst[20];Convex_Hull tree[MAXN<<1];void up(int x) { flag[x]=1,tree[x]=Merge(tree[x<<1],tree[x<<1|1]); }void build(int x,int l,int r,int dep){lst[dep]=0;tree[x].Clear(),flag[x]=0;if (l==r) return;int mid=(l+r)>>1;build(x<<1,l,mid,dep+1);build(x<<1|1,mid+1,r,dep+1);}void insert(int x,int l,int r,int y,Vct z,int dep){if (r==y){if (lst[dep]) up(lst[dep]);lst[dep]=(l==r)?0:x;}if (l==r) { tree[x].Push(z); return; }int mid=(l+r)>>1;if (y<=mid) insert(x<<1,l,mid,y,z,dep+1);else insert(x<<1|1,mid+1,r,y,z,dep+1);}void erase(int x,int l,int r,int y,int dep){tree[x].Clear(),flag[x]=0;if (lst[dep]==x) lst[dep]=0;if (l==r) return; int mid=(l+r)>>1;if (y<=mid) erase(x<<1,l,mid,y,dep+1);else erase(x<<1|1,mid+1,r,y,dep+1);}ll query(int x,int l,int r,int L,int R,Vct y){int mid=(l+r)>>1;if (L<=l&&r<=R) {if (l==r||flag[x]) return tree[x].Query(y);return max(query(x<<1,l,mid,l,mid,y),query(x<<1|1,mid+1,r,mid+1,r,y));}if (R<=mid) return query(x<<1,l,mid,L,R,y);else if (L>mid) return query(x<<1|1,mid+1,r,L,R,y);else return max(query(x<<1,l,mid,L,mid,y),query(x<<1|1,mid+1,r,mid+1,R,y));}
} segment;
int main()
{int zbl=read(),Case;while (Case=read()){int n=min(300000,Case),num=0,ans=0;segment.build(1,1,n,0);while (Case--){int opt=read();if (opt==1) { int x=read(),y=read(); segment.insert(1,1,n,++num,Vct(x,y),0); }else if (opt==2) { segment.erase(1,1,n,num--,0); }else {int l=read(),r=read(),x=read(),y=read();ll t=segment.query(1,1,n,l,r,Vct(x,y));((t%=mods)+=mods)%=mods;ans^=t;}}printf("%d\n",ans);}return 0;
}

卡空间很恶心。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/315710.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

精彩回放 | 玩转 VS Code 物联网开发

"Visual Studio Code&#xff1a;物联网开发利器"技术分享圆满落下帷幕&#xff01;感谢韩老师的粉丝们&#xff01;感谢热情的观众朋友们&#xff01;点击文末阅读原文&#xff0c;可以观看视频回放~这几年物联网越来越火&#xff0c;大家都在说物联网&#xff0c;那…

LuoguP5897 [IOI2013]wombats

LuoguP5897 [IOI2013]wombats 题目描述 简要题意&#xff1a;有一个R∗CR*CR∗C的网格图&#xff0c;边有边权&#xff0c;支持修改&#xff0c;多次询问V1,V2V_1,V_2V1​,V2​&#xff0c;求点(0,V1)(0,V_1)(0,V1​)到(R−1,V2)(R-1,V_2)(R−1,V2​)的最短路&#xff08;只能…

重磅!开放EasyCharts插件源代码!

开源代码地址https://github.com/EasyChart/EasyCharts前 言不知不觉&#xff0c;Excel图表插件EasyCharts已经面世两年啦&#xff0c;今天突然发现百度网盘中的下载次数居然达到近4万&#xff0c;在这里非常感谢大家对EasyCharts的厚爱。由于工作太忙&#xff0c;时间有限&a…

构建可读性更高的 ASP.NET Core 路由

一、前言不知你在平时上网时有没有注意到&#xff0c;绝大多数网站的 URL 地址都是小写的英文字母&#xff0c;而我们使用 .NET/.NET Core MVC 开发的项目&#xff0c;因为在 C# 中类和方法名采用的是 Pascal 命名规范&#xff0c;根据 .NET 框架默认的路由规则&#xff0c;项目…

CF605C. Freelancer's Dreams

CF605C. Freelancer’s Dreams 题目描述 Solution 实际上就是给定ai,bi,A,Ba_i,b_i,A,Bai​,bi​,A,B&#xff0c;求n维向量(x1..xn)(x1..x_n)(x1..xn​)&#xff0c;使得&#xff1a; ∑i1naixi≥A∑i1nbixi≥Bminz∑ixi\sum_{i1}^na_ix_i\geq A\\ \sum_{i1}^nb_ix_i\geq B…

CF908G. New Year and Original Order

CF908G. New Year and Original Order Solution 对于一个数xxx&#xff0c;它的贡献为排序之后的值&#xff0c;例如&#xff1a;S(50394)34593∗1034∗1025∗1019S(50394)34593*10^34*10^25*10^19S(50394)34593∗1034∗1025∗1019&#xff0c;也就是每一个数值乘以若干个101…

【18】ASP.NET Core MVC 中的 Model介绍

ASP.NET Core MVC 中的 Model在本视频中&#xff0c;我们将通过一个示例讨论 ASP.NET Core MVC 中的 Model。我们希望最终从 Student 数据库表中查询特定的学生详细信息并显示在网页上&#xff0c;如下所示。MVC 中的模型包含一组表示数据的类和管理该数据的逻辑。 因此&#x…

使用 Powershell 远程连接 windows server

使用 Powershell 远程连接 windows serverIntro最近我们的开发环境增加了一个 windows 服务器&#xff0c;没有界面的&#xff0c;不能直接远程桌面连上去管理&#xff0c;需要使用 Powershell 管理&#xff0c;于是就有了这篇文章的探索。windows服务器配置以下所有命令需要在…

[BZOJ2616] SPOJ PERIODNI

[BZOJ2616] SPOJ PERIODNI 题目描述 Solution 这题有个高大上的名字——笛卡尔树DPDPDP。 然而其实就是一个简单的区间DP而已。 设fl,r,jf_{l,r,j}fl,r,j​表示当前要求的区间为[l,r][l,r][l,r]&#xff0c;已经选择了jjj个棋子的方案数&#xff0c;考虑怎么划分子问题&…

.NET Core WEB API中接口参数的模型绑定的理解

在.NET Core WEB API中参数的模型绑定方式有以下表格中的几种&#xff1a;微软官方文档说明地址&#xff1a;https://docs.microsoft.com/zh-cn/aspnet/core/web-api/?viewaspnetcore-2.1特性 绑定源[FromHeader]请求标头[FromQuery]请求查询字符串参数[FromForm]请求正文中的…

CF1004F Sonya and Bitwise OR

CF1004F Sonya and Bitwise OR Solution 感觉比较套路。 序列的前缀ororor有一个性质&#xff1a;最多变换logloglog次。 所以直接建一个线段树&#xff0c;每个区间对于前缀、后缀分别存下O(log)O(log)O(log)个断点、ororor值以及ansansans&#xff0c;这样就能够很容易地…

ASP.Net Core Razor 部署AdminLTE框架

1、AdminLTE一个基于 bootstrap 的轻量级后台模板2、AdminLTE 文档在线中文Demo&#xff1a;http://adminlte.la998.com/在线中文文档&#xff1a;http://adminlte.la998.com/documentation/index.htmlGithub&#xff1a;https://github.com/almasaeed2010/AdminLTE/releases3、…

CF1178H Stock Exchange

CF1178H Stock Exchange 题目描述 简要题意&#xff1a;给定2n2n2n个一次函数yaixbi(a,b>0)ya_ixb_i(a,b>0)yai​xbi​(a,b>0)&#xff0c;刚开始你有前nnn个函数各一个&#xff0c;在任意时刻ttt&#xff0c;xxx函数可以转换为yyy函数当且仅当axtbx>aytbya_xtb_…

.NET CORE 对接天翼云 OOS

最近&#xff0c;因公司项目需要对接天翼云OOS&#xff0c;在百度多次折腾后&#xff0c;大部分的都是基于java、php 等其他语言&#xff0c;很少基于C#语言的相关资料&#xff0c;即使有也是基于.NET Framwork开发的SDK&#xff0c;内容几乎是千篇一律&#xff0c;很少基于.NE…

盘点618 .NET 程序员必“败”书单

六月到了&#xff0c;有三个节日迎接我们&#xff0c;心中微微一盘算&#xff1a;儿童节和端午节仿佛对我们都不重要。我们期待的只有&#xff1a;618狂欢购物节&#xff01;没错一年一度的618来了,哪些书值得买&#xff1f; 小编盘点了2019年1-5月.NET 相关的图书&#xff0c;…

CF1028F. Make Symmetrical

CF1028F. Make Symmetrical 题目描述 Solution 结论1&#xff1a;两个点(x1,y1),(x2,y2)(x_1,y_1),(x_2,y_2)(x1​,y1​),(x2​,y2​)关于(0,0),(x3,y3)(0,0),(x_3,y_3)(0,0),(x3​,y3​)对称的必要条件为(x1,y1)(x_1,y_1)(x1​,y1​)和(x2,y2)(x_2,y_2)(x2​,y2​)在同一个…

ApplicationInsights的探测器尝鲜

通常我们可以依靠ApplicationInsights(以下简称ai&#xff09;来收集比如请求(request),依赖项(dependencies),异常(exception)等信息&#xff0c;但是无法收集到比如一个方法&#xff08;方法内部比如没有依赖项调用&#xff09;的信息。很多时候如果一个方法很慢&#xff0c;…

CF917C. Pollywog

CF917C. Pollywog 题目描述 Solution 看完题&#xff0c;基本的方向就是状压DP。 因为每次都是最左边的青蛙跳至多kkk步&#xff0c;容易发现任意两个青蛙之间的距离始终小于kkk。 因此可以把连续kkk个位置的空闲状态压在(kx)≤70\binom{k}{x}\leq70(xk​)≤70个二进制数中…

开源/免费界面自动化测试工具对比研究

摘要&#xff1a;随着我行自动化测试实施范围的不断扩大&#xff0c;参与界面自动化测试的应用系统越来越多。我行的应用系统现阶段多采用商用工具QTP&#xff08;UFT&#xff09;作为执行工具来进行界面自动化测试&#xff0c;采购的QTP license是有限的&#xff0c;使得资源的…

CF1119G. Get Ready for the Battle

CF1119G. Get Ready for the Battle 题目描述 Solution 妙妙构造题。 考虑这样一个过程&#xff1a;所有人一起打第一个怪&#xff0c;每次打nnn&#xff0c;最后剩下k1<nk_1<nk1​<n&#xff0c;就找一些加起来正好为k1k_1k1​的组打掉k1k_1k1​&#xff0c;剩下的…