追求女神------------思维(奇偶性)
解析:
t秒内,从(0,0)走到(x,y) 说明t和(x+y)的奇偶性必须保持一致性且t>=(x+y)
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int t,n;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct node
{
int k,x,y;
}a[N];
bool check(int time ,int x,int y,int lastx,int lasty)
{
bool f = false;
for(int i=0;i<4;i++){
int xx = dx[i]+x;
int yy = dy[i]+x;
if(xx>=0 && yy>=0){
int dis = xx+yy-(lastx+lasty);
if((time-dis)%2){
f=true;
}
}
}
return f;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d %d %d",&a[i].k,&a[i].x,&a[i].y);
int time = 0;
int lx=0,ly=0;
bool f = true;
for(int i=1;i<=n;i++){
time = a[i].k-time;
int dis = abs(a[i].x-lx) + abs(a[i].y-ly);
if((time&1)^(dis&1) || dis>time) {
f=false;
break;
}
time=a[i].k;lx=a[i].x;ly=a[i].y;
}
if(f) puts("Yes");
else puts("No");
}
}