维护一区间 \([l,r]\)

人按照时间升序

考虑 \((l_i, h_i, t_i)\),当前的所有区间与这个区间取交

推到 \(t_{i+1}\) 时,所有区间的端点向两边扩张即可

注意把空掉的区间删掉

#include <bits/stdc++.h>
using namespace std; const int N = 105;
int q,n,m,t[N],l[N],h[N]; struct interval {
int l,r;
void cut(int ql,int qr) {
l=max(l,ql);
r=min(qr,r);
}
void expand(int t) {
if(l>r) return;
l-=t;
r+=t;
}
} I; signed main() {
ios::sync_with_stdio(false);
cin>>q;
while(q--) {
cin>>n>>m;
for(int i=1;i<=n;i++) {
cin>>t[i]>>l[i]>>h[i];
}
for(int i=1;i<=n;i++) {
for(int j=1;j<i;j++) {
if(t[i]<t[j]) {
swap(t[i],t[j]);
swap(l[i],l[j]);
swap(h[i],h[j]);
}
}
}
I={m,m};
for(int i=1;i<=n;i++) {
I.expand(t[i]-t[i-1]);
I.cut(l[i],h[i]);
}
if(I.l <= I.r) puts("YES");
else puts("NO");
}
}

[CF1304C] Air Conditioner的更多相关文章

  1. Codeforces Round #620 (Div. 2) C. Air Conditioner

    Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to ma ...

  2. Codeforces 1304C. Air Conditioner

    本题直接对每个区间取并,若出现非法区间就是No 否则就是Yes #include<bits/stdc++.h> using namespace std; #define lowbit(x) ...

  3. 日常维护sql

    修复mysqlcheck -u -p --repair  pmdb prefix="/export/data/mysql/bin/mysql -u -p -e" domain=机房 ...

  4. 又是周六了-MySQL特训

    hi 又是周六,又是磨蹭个一上午~午饭后开始吧 1.MySQL -----子查询与连接(三)----- ----使用INSERT...SELECT插入记录 --数据库内容的英文版本 由于我的WAMP中 ...

  5. Correspondence / ˏkɔris'pɔndәns / dictionary10-800.doc

    I have taken courses in office administration, typing,reports and correspondence writing. Correspond ...

  6. 越狱Season 1-Episode 1: the pilot

    the pilot: 美国电视剧新剧开播都会有一个试播来测试观众对新剧的接受程度,以此来决定是否再继续播下去,也可以说是一个开端,第一集,试播 -Tattoo Artist: That's it. t ...

  7. 基于 HTML5 Canvas 的 3D 机房创建

    对于 3D 机房来说,监控已经不是什么难事,不同的人有不同的做法,今天试着用 HT 写了一个基于 HTML5 的机房,发现果然 HT 简单好用.本例是将灯光.雾化以及 eye 的最大最小距离等等功能在 ...

  8. How I explained OOD to my wife(转)

    How I explained OOD to my wife Learning Object Oriented Design principles through interesting conver ...

  9. English trip V2 - 5 Technology Teacher:Taylor Key:adjective + preposition

    In this lesson you will learn to talk about technology and innovation. 课上内容(Lesson) What is your fav ...

随机推荐

  1. css常用样式对文本的处理演练

    CSS文本属性可定义文本的外观,这是毫无疑问的,其次css可以通过以下属性改变文字的排版,比方说letter-spacing实现字符间距text-indent: 2em;完成首行缩进2字符word-s ...

  2. Android中点击按钮获取string.xml中内容并弹窗提示

    场景 AndroidStudio跑起来第一个App时新手遇到的那些坑: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103797 ...

  3. deepin系统修改IP地址记录

    今天在配置软路由的时候需要设备有线网卡为静态地址,于是便按照如下方法进行修改: 1.备份网络配置文件: sudo cp /etc/network/interfaces /etc/netword/int ...

  4. C#实现的一些常见时间格式

    string aa = DateTime.Now.ToShortDateString();//"2019/9/23" string bb = DateTime.Now.ToShor ...

  5. Django单元测试中Fixtures用法

    在使用单元测试时,有时候需要测试数据库中有数据,这时我们可以使用Django的Fixtures来生成测试数据. 基础配置 在settings.py 中配置如下内容: FIXTURE_DIRS = (' ...

  6. Python 使用OS模块调用 cmd

    在os模块中提供了两种调用 cmd 的方法,os.popen() 和 os.system()os.system(cmd) 是在执行command命令时需要打开一个终端,并且无法保存command命令的 ...

  7. Nginx架构分析(20200202)

    Nginx模块化 Nginx基于模块化设计,每个模块是一个功能实现,分布式开发,团队协作 核心模块.标准HTTP模块.可选HTTP模块.邮件模块.第三方模块 编译后的源码目录objs/ngx_modu ...

  8. 破解“低代码”的4大误区,拥抱低门槛高效率的软件开发新选择 ZT

    最近,每个人似乎都在谈论“低代码”.以美国的Outsystems.Kinvey,以及国内的活字格为代表的低代码开发平台,正在风靡整个IT世界.毕竟,能够以最少的编码快速开发应用的想法本身就很吸引人.但 ...

  9. eclipse一直不停building workplace

    找解决方案的时候自己好了 然后又卡在了updating maven project 暂无解

  10. CF #621 div.2

    三连否认跪了 T1 开了第一题水题,一遍交过 /* make by ltao */ #include <iostream> #include <cstdio> #include ...