不醒人室

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;

}

相关推荐
在书中成长1 分钟前
HarmonyOS 小游戏《对战五子棋》开发第8篇 - GomokuEngine核心引擎设计(三):五子连珠判定算法
算法·华为·harmonyos
Let's Chat Coding13 分钟前
MAC 消息认证码:同时验证来源和完整性
算法·哈希算法
cc.ChenLy2 小时前
算法从入门到精通实战指南
算法
Jerry9 小时前
LeetCode 160. 相交链表
算法
Jerry9 小时前
LeetCode 19. 删除链表的倒数第 N 个结点
算法
金銀銅鐵9 小时前
费马小定理
python·数学·算法
技术不好的崎鸣同学11 小时前
[ACTF2020 新生赛]Exec 思路及解法
算法·安全·web安全
Full Stack Developme12 小时前
Java LRU 与 LFU 算法及应用
java·开发语言·算法
Jerry13 小时前
LeetCode 707. 设计链表
算法