每次求上一个区间能到的最远的地方,然后与当前区间求交集。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
#define LL long long
#define N 110
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, m;
scanf("%d%d", &n, &m);
int stal, star, flag = 1;
stal = star = m;
int t, l, r, temp = 0;
while (n--)
{
scanf("%d%d%d", &t, &l, &r);
temp = t - temp;
stal -= temp, star += temp;
temp = t;
stal = max(stal, l), star = min(star, r);
if (stal > star)flag = 0;
}
if (flag)printf("YES\n");
else printf("NO\n");
}
return 0;
}