#3733. New Home
如何使用Google Home与Apple Home联动 #生活技巧# #数码产品使用技巧# #智能设备联网教程#
题意五福街是一条笔直的道路,这条道路可以看成一个数轴,街上每个建筑物的坐标都可以用一个整数来表示。小明是一位时光旅行者,他知道在这条街上,在过去现在和未来共有 n n n 个商店出现。第 i i i 个商店可以使用四个整数 x i , t i , a i , b i x_i, t_i, a_i, b_i xi,ti,ai,bi 描述,它们分别表示:商店的坐标、商店的类型、商店开业的年份、商店关闭的年份。
小明希望通过时光旅行,选择一个合适的时间,住在五福街上的某个地方。他给出了一份他可能选择的列表,上面包括了 q q q 个询问,每个询问用二元组(坐标,时间)表示。第 i i i 对二元组用两个整数 l i , y i l_i, y_i li,yi 描述,分别表示选择的地点 l i l_i li 和年份 y i y_i yi 。
现在,他想计算出在这些时间和地点居住的生活质量。他定义居住的不方便指数为:在居住的年份,离居住点最远的商店类型到居住点的距离。类型 t t t 的商店到居住点的距离定义为:在指定的年份,类型 t t t 的所有营业的商店中,到居住点距离最近的一家到居住点的距离。我们说编号为 i i i 的商店在第 y y y 年在营业当且仅当 a i ≤ y ≤ b i a_i \leq y \leq b_i ai≤y≤bi 。注意,在某些年份中,可能在五福街上并非所有 k k k 种类型的商店都有至少一家在营业。在这种情况下,不方便指数定义为 −1。你的任务是帮助小明求出每对(坐标,时间)二元组居住的不方便指数。
范围子任务 1(5 分): n , q ≤ 400 n,q\leq 400 n,q≤400
子任务 2(7 分): n , q ≤ 6 × 1 0 4 , k ≤ 400 n,q\leq 6\times 10^4,k\leq 400 n,q≤6×104,k≤400
子任务 3(10 分): n , q ≤ 3 × 1 0 5 n,q\leq 3\times 10^5 n,q≤3×105,对于所有的商店 a i = 1 , b i = 1 0 8 a_i=1,b_i=10^8 ai=1,bi=108
子任务 4(23 分): n , q ≤ 3 × 1 0 5 n,q\leq 3\times 10^5 n,q≤3×105,对于所有的商店 a i = 1 a_i=1 ai=1
子任务 5(35 分): n , q ≤ 6 × 1 0 4 n,q\leq 6\times 10^4 n,q≤6×104
子任务 6(20 分): n , q ≤ 3 × 1 0 5 n,q\leq 3\times 10^5 n,q≤3×105
题解问题可转化为求以一个点为中心,最短的一段区间,使这个区间出现过所有类型的商店。
显然先二分区间长度,乍一看似乎难以用数据结构维护,其实有一个很巧妙的方法:记录每一个点前一个与它类型相同的点p,设区间为[l,r],问题就变成不能有r后的p在l之前,即使r后面的点的p都在l之后,用线段树区间查询最小值即可。
网址:#3733. New Home https://www.yuejiaxmz.com/news/view/1009408
相关内容
Home Automation SystemWhat's New at LivingPlaces.com
Manufacture Price Tuya Zigbee Smart Home Automation System Smart Home Products 1 Gang Wifi Smart Switch Touch Wall Switch - Buy Smart Home Automation System smart Switch For Smart Home touch Wall Switch Product on Alibaba.com
DIY Home Decor Market Share, Analysis
Home Furnishing Organizing and Storage Tips
Latest Transparent Glass Vase Flower Vase For Decoration Decorative Items Home Decor - Buy Glass Vase flower Vase For Decoration decorative Items Home Decor Product on Alibaba.com
Teejoin Remote Control Wifi Switch Work With Tuya Alexa Google Home Automation System Smart Home Device
Android P Auto版本Home画面解析
new concept 3=04 The double life of Alfred Bloggs
Chengde Greenline Home Products Co.ltd. Imp data And Contact