F - Box in Box

首先,每个长方体的\(h,w,d\)都是可以任意互换的,所以我们考虑用\(a_0,a_1,a_2\)来代替它们(\(a_0\leq a_1\leq a_2\))

然后可以发现一个规律,我们肯定是用\(a_0\)和\(a_0\)比较,\(a_1\)和\(a_1\)比较,\(a_2\)和\(a_2\)比较

那么现在显然就是三位偏序,可以上\(CDQ\)了,先对\(a_0\)进行排序,但是因为题目要求的是严格大于,所以在\(CDQ\)时,\(mid\)不一定是取\(\frac{l+r}2\),而是一个使得\(mid\)的\(a_0\)和\(mid+1\)的\(a_0\)不相同的,尽量靠近中间的位置

因为若当前区间的\(l\)的\(a_0\)和\(r\)的\(a_0\)都相等了,我们就不用管这个区间了,所以即使我们并没有在下标上进行二分,但是我们相当于在\(a_0\)的值域上进行了二分(并不是严格二分,只是一个相当于在二分的过程),所以复杂度没有问题

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,lsh[N],tot;
struct node{
int a[3];
bool operator < (const node &other)const{
return a[0]<other.a[0];
}
}cn[N];
bool cmp(node a,node b){
return a.a[1]<b.a[1];
}
map<int,int> st,ed;
int c[N];
void add(int x,int y){
for(;x<=tot;x+=x&-x) c[x]+=y;
}
int ask(int x){
int ans=0;
for(;x;x-=x&-x) ans+=c[x];
return ans;
}
void solve(int l,int r){
if(cn[l].a[0]==cn[r].a[0]) return;
int mid=l+r>>1;
if(cn[mid].a[0]==cn[mid+1].a[0]){
int len1=st[cn[mid].a[0]]-l,len2=r-ed[cn[mid].a[0]];
if(len1<len2) mid=ed[cn[mid].a[0]];
else mid=st[cn[mid].a[0]]-1;
}
solve(l,mid),solve(mid+1,r);
sort(cn+l,cn+mid+1,cmp),sort(cn+mid+1,cn+r+1,cmp);
int a=l,b=mid+1;
for(;b<=r;++b){
while(a<=mid&&cn[a].a[1]<cn[b].a[1]) add(cn[a].a[2],1),++a;
if(ask(cn[b].a[2]-1)){ puts("Yes"); exit(0); }
}
for(int i=l;i<a;++i) add(cn[i].a[2],-1);
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i) scanf("%d%d%d",&cn[i].a[0],&cn[i].a[1],&cn[i].a[2]),sort(cn[i].a,cn[i].a+3),lsh[++tot]=cn[i].a[2];
sort(cn+1,cn+n+1),sort(lsh+1,lsh+tot+1),tot=unique(lsh+1,lsh+tot+1)-lsh-1;
for(int i=1;i<=n;++i){
if(!st[cn[i].a[0]]) st[cn[i].a[0]]=i;
ed[cn[i].a[0]]=i;
cn[i].a[2]=lower_bound(lsh+1,lsh+tot+1,cn[i].a[2])-lsh;
}
solve(1,n);
puts("No");
return 0;
}

[abc309 F] Box in Box的更多相关文章

  1. js中box和box()的区别

    window.onload = function(){ var input = document.getElementByTagName('input')[0]; input.onclick = bo ...

  2. ABC130 Task F. Minimum Bounding Box

    题目链接 题解 最小的 bounding box 一定可以在四个时间段的最左端点和最右端点之间取到. 举例言之,设四个时间段分别是 (2, 5), (7, 10), (4, 9), ( 10, 20) ...

  3. AtCoder Beginner Contest 130 F Minimum Bounding Box 三分法求极值(WA)

    题意:给n个点的起始坐标以及他们的行走方向,每一单位时间每个点往它的方向移动一单位.问最小能包围所有点的矩形. 解法:看到题目求极值,想了想好像可以用三分法求极值,虽然我也不能证明面积是个单峰函数. ...

  4. win10系统在执行“ vagrant box add centos7 vagrant-centos-7.box”添加box时,报错“Vagrant failed to initialize at a very early stage: Failed to locate the powershell executable on the available PATH. ”

    这个意思是:在有效的路径中未能执行PowerShell命令. 请检查PowerShell的安装和有效的路径,然后再尝试重新运行这个命令. 在环境变量path中添加powershell的路径,例如:C: ...

  5. [JS Compose] 0. Understand 'Box' or 'Container', they are just like Array!

    We'll examine how to unnest function calls, capture assignment, and create a linear data flow with a ...

  6. edge box

    先介绍一下matlab与c混合编程 主要步骤: 使用c语言编写函数 利用mexFunction()函数创建C与matlab接口 从Matlab中编译函数 # include <mex.h> ...

  7. HDU - 2475:Box(splay维护森林)

    There are N boxes on the ground, which are labeled by numbers from 1 to N. The boxes are magical, th ...

  8. virtualbox+vagrant学习-2(command cli)-1-vagrant box命令

    vagrant box 这是用于管理(添加.删除等)boxes的命令. box 是一个打包好的操作系统,是一个后缀名为 .box 的文件,其实是一个压缩包,里面包含了 Vagrant 的配置信息和 V ...

  9. [JS Compose] 1. Refactor imperative code to a single composed expression using Box

    After understanding how Box is, then we are going to see how to use Box to refacotr code, to un-nest ...

  10. NOIP 模拟 box - 费用流 / 匈牙利

    题目大意: 给出n(\(\le 200\))个盒子,第i个盒子长\(x_i\),宽\(y_i\),一个盒子可以放入长宽都大于等于它的盒子里,并且每个盒子里只能放入一个盒子(可以嵌套),嵌套的盒子的占地 ...

随机推荐

  1. MD5加密BASE64加解密

    MD5需要引入system.Hash,BASE64需要引入System.NetEncoding,这两个单元应该只有高版本的DELPHI IDE才有 (貌似XE5以上版本才有).如果是D7的话,找第三方 ...

  2. 使用ssh连接virtual Box里的虚拟机

    使用ssh连接virtual Box里的虚拟机 需求:virtual Box提供的文件拖放功能在从虚拟机拖向主机时,会出现一些卡顿,因此考虑使用ssh代替其文件传输功能. 高级 -> 端口转发 ...

  3. Microsoft.NETCore.App 版本不一致导致的运行失败

    场景重现 今天新建了一个 ASP.NET Core 的项目, 通过 Web Deploy 顺利发布到IIS上后, 但访问时出现如下异常: 异常原因 通过手动执行dotnet命令发现运行框架版本不一致? ...

  4. 【开源推荐】AI Interviewer:基于Spring-Alibaba-AI的智能面试官系统(附GitHub实战教程)

    项目背景 作为开发者,你是否经历过: 技术面试时因紧张发挥失常? 刷了1000+LeetCode却不会表达解题思路? 花费上千元购买模拟面试服务? 今天推荐的AI Interviewer开源项目,正是 ...

  5. HTB打靶记录-TheFrizz

    信息收集 nmap -sV -sC -O 10.10.11.60 Nmap scan report for 10.10.11.60 Host is up (0.63s latency). Not sh ...

  6. Linux shutdown 命令

    Linux shutdown 命令可以用来进行关机程序,并且在关机以前传送讯息给所有使用者正在执行的程序,shutdown 也可以用来重开机. 使用权限:系统管理者. 语法 shutdown [-t ...

  7. kette介绍-Step之Table input

    表输入(Table Input)介绍: Table input用于将数据源的数据加载到Kettle转换中的行集,可以说是数 据从持久化到内存的一种加载变换,故名为输入.加载内部过程,就是通过JDBC ...

  8. Less中实现响应式设计的4种高效方案(手机、平板、电脑端)

    下是4种纯Less实现的响应式方案,均封装成可复用方法. 方案1:基础设备混合封装 // 定义设备断点变量 @mobile-max: 767px; @tablet-min: 768px; @table ...

  9. 解决Ubuntu 20.04升级后gnome-control-center设置程序无法打开问题

    解决Ubuntu 20.04升级后gnome-control-center设置程序无法打开问题 Ubuntu 20.04 系统升级后,发现gnome设置程序无法正常打开了. 在终端运行命令查看错误信息 ...

  10. IDEA在检查更新的时候报错 Connection Error Failed to load plugins from 'https://plugins.jetbrains.com/idea': org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 3; 文档中根元素前面的标记必须格式正确。

    问题: IDEA在更新的时候报错 Connection Error Failed to load plugins from 'https://plugins.jetbrains.com/idea': ...