不醒人室

1004 不醒人室 (hdu.edu.cn)

#include<bits/stdc++.h>

#define int long long

using namespace std;

const int N = 2e5+10;

int n, m;

struct node{

int l, r, s;

}stN;

bool cmp(node x, node y){

return x.l < y.l;

}

void solve(){

int cnt = 0;

cin >> n >> m;

for(int i = 0; i < n; i ++){

int x, y;

cin >> x >> y;

stcnt ++ = {x, y, 1};

}

for(int i = 0; i < m; i ++){

int x, y;

cin >> x >> y;

stcnt ++ = {x, y, 0};

}

sort(st, st+cnt, cmp);

for(int i = 1; i < cnt; i ++){

if(sti.l < sti-1.r){

cout << "No\n";

return ;

}

}

int x = 0;

for(int i = 0; i < cnt; i ++){

if(sti.s)

{

if(x < sti.r)

{

cout << "No\n";

return ;

}

}

else

{

x = sti.r+2*(sti.r-sti.l);

}

}

cout << "Yes\n";

}

signed main(){

ios::sync_with_stdio(0);

cin.tie(0), cout.tie(0);

int T = 1;

cin >> T;

while(T --){

solve();

}

return 0;

}

相关推荐
ValhallaCoder11 分钟前
Leetcode-hot100(2026.08.17)
python·算法·leetcode
泡沫冰@29 分钟前
GO 语言基础
开发语言·算法·golang
luj_17681 小时前
元设计的诱惑与现实
c语言·开发语言·c++·经验分享·算法
小星星闪亮登场2 小时前
ST表--倍增思想
开发语言·数据结构·c++·算法·思维
马可家的菠萝2 小时前
Vue3 + Canvas 手绘笔记工程化实践:别把画布只当成一张 PNG
前端·vue.js·算法
watersink2 小时前
机器学习极大似然估计与EM算法
人工智能·算法·机器学习
叠层归一研究院2 小时前
如何用程序搭建一个 AGI 种子系统(一):从向量种子到无限生长引擎
人工智能·python·算法·机器学习·agi
科学实验家2 小时前
并 查集
算法
xiaohebang3 小时前
流失预测模型设计:行为特征分析算法选型
大数据·数据结构·经验分享
AI服务老曹3 小时前
视觉算法模型管理性能优化指南:多版本平滑升级、灰度与快速回滚实战
算法·性能优化