Problem:


Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.

If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

1 ≤ N ≤ 10^5

0 ≤ x_i ≤ 10^5

0 ≤ y_i ≤ 10^5

1 ≤ t_i ≤ 10^5

t_i < t_{i+1} (1 ≤ i ≤ N-1)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
t_1 x_1 y_1
t_2 x_2 y_2
:
t_N x_N y_N

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at (100,100) two seconds after being at (0,0).

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No



Sample input:
2
3 1 2
6 1 1


Sample output:
Yes

Submission status: Accepted

Solution code:
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())

f = True
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dt < dist:
        f = False
    if dist%2 != dt%2:
        f = False

print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    n = int(input())
    t, x, y = 0, 0, 0
    for i in range(n):
        a, b, c = map(int, input().split())
        d = a - t
        m = abs(x - b) + abs(y - c)
        if d - m < 0 or (d - m) % 2 == 1:
            print("No")
            return
        t, x, y = a, b, c
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
def judge(t_1,x_1,y_1,t_2,x_2,y_2):
    dt=t_2-t_1 
    dx=abs(x_2-x_1) 
    dy=abs(y_2-y_1) 
    if dx+dy>dt:
        return True 
    else: 
        if (dt-dx-dy)%2 == 0:
            return False 
        else: 
            return True 
        
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))
    
t_1,x_1,y_1=0,0,0 
for i in range(n):
    t_2,x_2,y_2=data[i]
    if judge(t_1,x_1,y_1,t_2,x_2,y_2): 
        print("No") 
        break 
    t_1,x_1,y_1=t_2,x_2,y_2 
else: 
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
x,y=0,0
t=0
for i in range(n):
    T,X,Y=map(int,input().split())
    if((T-t)>=(abs(X-x)+abs(Y-y)) and (T-t)%2==(abs(x-X)+abs(Y-y))%2):
        x=X
        y=Y
        t=T
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
t=0
x=0
y=0
for i in range(n):
  t_,x_,y_=map(int,input().split())
  t=abs(t_-t)
  x=abs(x_-x)
  y=abs(y_-y)
  if x+y>t:
    print('No')
    exit()
  if t_%2!=(x_+y_)%2:
    print('No')
    exit()
  
print('Yes')

Submission status: Accepted

Solution code:
Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
x = 0
y = 0
T = 0
flag = True
for i in range(Row):
  reqT = abs(List[i][1]-x)+abs(List[i][2]-y)
  chck= List[i][0] - T - reqT
  if chck < 0 or chck % 2 == 1:
    flag = False
    break
  x = List[i][1]
  y = List[i][2]
  T = List[i][0]
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
moromoro = [list(map(int,input().split())) for _ in range(N)]
moromoro.sort()

t,x,y = 0,0,0
for i in range(N):
    time = moromoro[i][0] - t
    dx = abs(moromoro[i][1] - x)
    dy = abs(moromoro[i][2] - y)
    if  dx + dy > time:
        print('No')
        exit()
    if (time - dx - dy) % 2 == 1:
        print('No')
        exit()
    t = moromoro[i][0]
    x = moromoro[i][1]
    y = moromoro[i][2]
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txn = []
for i in range(N):
  txn.append([int(i) for i in input().split()])

ima = [0,0,0]
for i in range(N):
  dist = abs(ima[1] - txn[i][1]) + abs(ima[2] - txn[i][2])

  if dist > (txn[i][0] - ima[0]) :
    print("No")
    exit()
  
  if dist%2 != (txn[i][0] - ima[0])%2 :
    print("No")
    exit()
  
  ima = txn[i]

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
px = py = pt = 0
for i in range(n):
	t,x,y = map(int,input().split())
	d = abs(x - px) + abs(y - py)
	nt = t - pt
	if nt < d or d%2 != nt%2:
		print("No")
		exit()
	px = x
	py = y
	pt = t
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

xyz = [map(int, input().split()) for i in range(N)]
t, x, y = [list(i) for i in zip(*xyz)]



if N == 1:
    T = N
    SUM = abs(x[0] + y[0])
    if T < SUM:
        print('No')
        exit()
    elif (T % 2 == 0 and SUM % 2 != 0) or (T % 2 != 0 and SUM % 2 == 0):
        print('No')
        exit()
    else:
        print('Yes')
        exit()
    

for i in range(N-1):
    T = t[i+1] - t[i]
    X = x[i+1] - x[i]
    Y = y[i+1] - y[i]
    

    
    
    if t[0] < abs(x[0] + y[0]):
        print('No')
        exit()
    elif (t[0] % 2 == 0 and abs((x[0] + y[0])) % 2 != 0) or (t[0] % 2 != 0 and abs((x[0] + y[0])) % 2 == 0):
        print('No')
        exit()
    

    SUM = abs(X + Y)

    if T < SUM:
        print('No')
        exit()
    elif (T % 2 == 0 and SUM % 2 != 0) or (T % 2 != 0 and SUM % 2 == 0):
        print('No')
        exit()
    else:
        continue
    
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
TXY = [[0, 0, 0] for _ in range(N)]
for i in range(N):
    TXY[i] = list(map(int, input().split()))

start = 0
start_x = 0
start_y = 0
for i in range(N):
    time = TXY[i][0] - start
    walk = [0 for _ in range(time)]
    diff_x = TXY[i][1] - start_x
    diff_y = TXY[i][2] - start_y
    total = len(walk) - (abs(diff_x) + abs(diff_y))
    if total < 0:
        print("No")
        exit()
    else:
        if total % 2 != 0:
            print(("No"))
            exit()
    start = TXY[i][0]
    start_x = TXY[i][1]
    start_y = TXY[i][2]
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
x, y = 0, 0
t = 0
for i in range(n):
    ti, xi, yi = map(int, input().split())
    l = abs(xi - x + yi - y)
    if l <= ti - t and l % 2 == (ti - t) % 2:
        x, y = xi, yi
        t = ti
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
txy=[list(map(int,input().split())) for i in range(n)]
x,y=0,0
t=0
for i in range(n):
  if abs((x+y) - (txy[i][1]+txy[i][2]))%2 == abs(t-txy[i][0])%2 and abs(t-txy[i][0]) >= abs((x+y)-(txy[i][1]+txy[i][2])):
    x,y=txy[i][1],txy[i][2]
  else:
    print("No")
    exit()
  t=txy[i][0]
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
P = [[0,0,0]]
for i in range(N):
    t,x,y = map(int,input().split())
    P.append([t,x,y])
judge = True
for i in range(1,N+1):
    dt = P[i][0] - P[i-1][0]
    dist = abs(P[i][1] - P[i-1][1]) + abs(P[i][2] - P[i-1][2])
    if (dt % 2 == 0 and dist % 2 == 0 and dist <= dt) or (dt % 2 == 1 and dist % 2 == 1 and dist <= dt):
        judge = True
    else:
        judge = False
if judge:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
t = 0
xy = [0,0]
ans = 'Yes'
for i in range(N):
    ti,xi,yi = map(int,input().split())
    dt = ti - t
    dx = abs(xi - xy[0])
    dy = abs(yi - xy[1])
    if dt < dx+dy:
        ans = 'No'
    elif dt%2 != (dx+dy)%2:
        ans = 'No'
    t = ti
    xy = [xi,yi]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
pt, px, py = 0, 0, 0
can = True
for i in range(N):
    t, x, y = map(int, input().split())
    T, X, Y = t - pt, abs(x - px), abs(y - py)
    if T < X + Y or T % 2 != (X + Y) % 2:
        can = False
    pt, px, py = t, x, y
print('Yes' if can else 'No')

Submission status: Accepted

Solution code:
n=int(input())
location=list(map(str,[input() for i in range(n)]))
fail=0
for j in range(n):
    if j==0:
        a=[0,0,0]
    else:
        a=list(map(int, location[j-1].split()))
    b=list(map(int,location[j].split()))
    x=abs(a[1]-b[1])
    y=abs(a[2]-b[2])
    t=b[0]-a[0]
    if x+y<=t:
        if (x+y)%2==t%2:
            pass
        else:
            fail+=1
    else:
        fail+=1
if fail==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math
n = int(input())
#P position t time
P = [0,0]
t0 = 0
for _ in range(n):
  t,x,y = map(int, input().split( ))
  dt = t - t0
  dis = abs(x - P[0])  + abs(y - P[1])
  if dis > dt:
    print('No')
    exit()
  elif (dt - dis)%2 == 1:
    print('No')
    exit()
  t0 = t
  P = [x,y]
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

locx = 0
locy =0
time = 0
for i in range(N):
  t,x,y = map(int,input().split())
  time = t-time
  dis = abs(locx-x)+abs(locy-y)
  if (time-dis)<0 :
    print("No")
    exit()
  if (time-dis)%2 == 1:
    print("No")
    exit()
    
  
  time = t
  locx = x
  locy = y
    
  
else :
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

locx = 0
locy =0
time = 0
for i in range(N):
  t,x,y = map(int,input().split())
  nowtime = t-time
  dis = abs(locx-x)+abs(locy-y)
  if (nowtime-dis)<0 :
    print("No")
    exit()
  if (nowtime-dis)%2 == 1:
    print("No")
    exit()
    
  
  time = t
  locx = x
  locy = y
    
  
else :
  print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
T=0; X=0; Y=0;
ans="Yes"
for i in range(n):
    t,x,y=map(int,input().split())
    s=t-T
    if s >= abs(X-x)+abs(Y-y) and (s-abs(X-x)+abs(Y-y))%2==0:
        T,X,Y = t,x,y
    else:
        ans="No"
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = abs(t0 - t)
    if abs(kyori - time) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = t - t0
    if (abs(kyori - time)) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
A = [[0,0,0]]
for i in range(N):
  A.append(list(map(int, input().split())))

flag = True
for i in range(N):
  if not flag:
    break
  time = int(A[i+1][0]) - int(A[i][0])
  dist = abs(A[i+1][1] - A[i][1]) + abs(A[i+1][2] - A[i][2]) # x2-x1 + y2-y1
  if time < dist:
    flag = False
  elif time % 2 != dist % 2:
    flag = False

if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n=int(input())
a=[[0,0,0]]

for i in range(n):
  a.append(list(map(int, input().split(" "))))
for i in range(n):
  check =  a[i + 1][0] - a[i][0] - (abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2]))
  if check >= 0 and check % 2 == 0:
    continue
  else:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
T = []
XY = []


def f(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)


cx, cy = 0, 0
ct = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    d = f(cx, cy, x, y)
    # print(f'{ct=}, {t=}, {d=}')
    if d > t - ct:
        print('No')
        exit()
    if (t - ct - d) % 2 != 0:
        print('No')
        exit()
    cx, cy = x, y
    ct = t
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
x,y,t=0,0,0

for i in range(n):
  mt,mx,my= map(int,input().split())
  ft = mt - t
  fx = abs(x-mx)
  fy = abs(y-my)
  if fx + fy > ft:
    print("No")
    exit()
  elif (ft - (fx + fy)) % 2 == 0:
    pass
  else:
    print("No")
    exit()
  x,y,t=mx,my,mt
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
        
print('Yes' if all(travelable(p,q) for p,q in zip(P[:N],P[1:])) else 'No')

Submission status: Accepted

Solution code:
N = int(input())
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
from itertools import zip_longest
print('Yes' if all(travelable(p,q) for p,q in zip_longest(P[:N],P[1:])) else 'No')

Submission status: Accepted

Solution code:
N=int(input())
P=[(0,0,0)]
for i in range(N):
	t,x,y=map(int,input().split())
	P.append((t,x,y))

T=[0]*N
dist=[0]*N

for i in range(N):
	T[i]=P[i+1][0]-P[i][0]
	dist[i]=abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])

ans=1
for i in range(N):
	if dist[i]>T[i]:
		ans=0
	else:
		m=T[i]-dist[i]
		if m%2==0:
			pass
		else:
			ans=0
	if ans==0:
		break
print("Yes" if ans==1 else "No")

Submission status: Accepted

Solution code:
N = int(input())

T = 0
X = 0
Y = 0

for i in range(N):
    t, x, y = map(int, input().split())
    dt = t - T
    dx = abs(X - x)
    dy = abs(Y - y)
    dis = dx + dy
    if dt < dis:
        print("No")
        break
    if (dt - dis) % 2 == 1:
        print("No")
        break
    T = t
    X = x
    Y = y
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
bx=by=bt=0
ans='Yes'

for i in range(n):
    t,x,y=map(int, input().split())
    if t%2!=(x+y)%2:
        ans='No'
    if abs(bx-x)+abs(by-y)>abs(bt-t):
        ans='No'
    bx=x
    by=y
    bt=t

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

def func(start,goal,t):
    distance=abs(start[0]-goal[0])+abs(start[1]-goal[1])
    if distance<=t and (t-distance)%2==0:
        return True
    return False
now=0
can=1
start=[0,0]
for i in range(n):
    t,x,y=[int(i) for i in input().split()]
    goal=[x,y]
    if not func(start,goal,t-now):
        can=0
        break
    else:
        start=goal
        now=t

if can==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
a = [0]*(n+1)
a[0] = [0, 0, 0]
for i in range(n):
    a[i+1]=list(map(int,input().split()))

flag = True
for i in range(n):
    if abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2]) > (a[i+1][0]-a[i][0]):
        flag=False
    elif (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])-(a[i+1][0]-a[i][0]))%2==1:
        flag=False

if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 'Yes'
    n = int(input())
    now = [0,0]
    pt = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        d = abs((x - now[0]) + (y - now[1]))
        if d > abs(t - pt) or (t - pt)%2 != d%2:
            ans = "No"
            break
        now = [x, y]
        pt = t
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
T, X, Y = [], [], []
pos_x, pos_y, now_t = 0, 0, 0
for i in range(N):
    t, x, y = zz()
    T.append(t)
    X.append(x)
    Y.append(y)
ok = 1
for t, x, y in zip(T, X, Y):
    if (abs(x - pos_x) + abs(y - pos_y) > (t - now_t)):
        ok = 0
        break
    if (((abs(x - pos_x) + abs(y - pos_y)) % 2) != ((t - now_t) % 2)):
        ok = 0
        break
    pos_x, pos_y, now_t = x, y, t
if(ok == 1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t,x,y=t1-t0,x1-x0,y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t=t1-t0
    x=x1-x0
    y=y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

ans = 1
tt, xx, yy = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    keep = abs(xx - x) + abs(yy - y) - (t - tt)
    if (keep > 0) | (keep % 2 != 0):
        ans *= 0
    tt, xx, yy = t, x, y
print(['No', 'Yes'][ans])

Submission status: Accepted

Solution code:
n=int(input())
x=0
y=0
t=0
f=0
for i in range(n):
    T,a,b=map(int,input().split())
    if not(abs(a-x)+abs(b-y)<=T-t and (abs(a-x)+abs(b-y)-(T-t))%2==0):
        f=1
    x=a
    y=b
    t=T
print("Yes" if f==0 else "No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
infos = []
for i in range(N):
  infos.append([int(s) for s in input().split()])

def check():
    c_t = 0
    c_x = 0
    c_y = 0
    for info in infos:
      n_t = info[0]
      n_x = info[1]
      n_y = info[2]

      d_t = n_t - c_t
      d_x = abs(n_x - c_x)
      d_y = abs(n_y - c_y)
      if d_t < (d_x + d_y):
        return "No"

      if (d_t - (d_x+d_y)) % 2 != 0:
        return "No"
      c_t = n_t
      c_x = n_x
      c_y = n_y
    return "Yes"

print(check())

Submission status: Accepted

Solution code:
n = int(input())
s = [[0,0,0]]
flag = 0
for i in range(n):
    t, x, y = map(int, input().split())
    s.append([t,x,y])
# print(s)
for i in range(1,n+1):
    dt = s[i][0]-s[i-1][0]
    dx = abs(s[i][1]-s[i-1][1])
    dy = abs(s[i][2]-s[i-1][2])
#     print(dt,dx,dy)
    if dt - (dx+dy) >= 0 and dt % 2 == (dx+dy) % 2:
        continue
    else:
        flag = 1
        print('No')
        break
if flag == 0:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
ti_1, xi_1, yi_1 = [0,0,0]
for i in range(n):
  ti, xi, yi = map(int, input().split())
  tlim = ti- ti_1
  dist = abs(xi - xi_1) + abs(yi - yi_1)
  if tlim < dist or (tlim-dist) % 2 == 1:
    print('No')
    exit()
  else:
    ti_1, xi_1, yi_1 = ti, xi, yi
    continue
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
pnt = [[0]*3]
for i in range(N):
  pnt.append(list(map(int, input().split())))
cnt = 0
for i in range(1, N+1):
  t = pnt[i][0] - pnt[i-1][0]
  x = abs(pnt[i][1] - pnt[i-1][1])
  y = abs(pnt[i][2] - pnt[i-1][2])
  if t >= x+y and (t-(x+y)) % 2 == 0:
    cnt += 1
if cnt == N: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
#13 C - Traveling
N = int(input())

plan = []
for _ in range(N):
    ti,xi,yi = map(int,input().split())
    plan.append((ti,xi,yi))
    
#今いる場所の座標と時間
spot = (0,0,0)#始点
result = 'Yes'
for t,x,y in plan:
    tdiff = t-spot[0]
    xdiff = abs(x-spot[1])
    ydiff = abs(y-spot[2])
    #(x,y)の変化量の和の偶奇と時間の差の偶奇が一致している
    #時間の変化量より(x,y)の変化量の方が小さい
    if (tdiff%2 == (xdiff+ydiff)%2) and ((xdiff + ydiff)<=tdiff):
        '''
        xdiff<=tdiff and ydiff<=t だと(3,3,2)などの範囲外に対応できない
        if (tdiff%2 == (xdiff+ydiff)%2) and (xdiff<=tdiff) and (ydiff<=tdiff):
        '''
        spot = (t,x,y)
    else:
        result = 'No'
        break
print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# coding=utf-8

import sys

n = int(sys.stdin.readline().strip())

txy = [(0,0,0)]+[tuple(map(int, l.strip().split(" "))) for l in sys.stdin.readlines()]
check_txy = [abs(_x - _xp) + abs(_y - _yp) <= _t - _tp and (_t + _x + _y) % 2 == 0 for (_t, _x, _y), (_tp, _xp, _yp) in zip(txy[1:], txy)]
if all(check_txy):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
pos = [list(map(int, input().split())) for _ in range(n)]

def func(n, pos):
    c_t, c_x, c_y = 0, 0, 0

    for i in pos:
        d_t = i[0] - c_t
        z = abs(i[1] - c_x) + abs(i[2] - c_y)

        if z > d_t or (d_t - z) % 2 != 0:
            return "No"
        else:
            c_t, c_x, c_y = i[0], i[1], i[2]

    return "Yes"


print(func(n, pos))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    lst = [[0, 0, 0]]
    for _ in range(n):
        lst.append(list(map(int, input().split())))

    flag = True
    for i in range(n):
        left_time = lst[i + 1][0] - lst[i][0]
        distance = abs(lst[i + 1][1] - lst[i][1]) + abs(lst[i + 1][2] - lst[i][2])

        if left_time < distance:
            flag = False
            break
        else:
            if left_time % 2 == 0:
                if distance % 2 == 0:
                    continue
                else:
                    flag = False
                    break
            else:
                if distance % 2 == 1:
                    continue
                else:
                    flag = False
                    break

    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int,input().split())) for _ in range(n)]
t = txy[0][0]
go = txy[0][1] + txy[0][2]
if t < go or t%2 != go%2:
    print("No")
    exit()
for i in range(n-1):
    t = txy[i+1][0] - txy[i][0]
    go = abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2])
    if t < go or t%2 != go%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
tl = []
dl = []
flag = 0

for i in range(n):
    t, x, y = (int(x) for x in input().split())
    tl.append(t)
    dl.append((x, y))

for num in range(n):
    if num == 0:
        if tl[num] >= sum(dl[num]) and tl[num] % 2 == sum(dl[num]) % 2:
            pass
        else:
            flag = 1
    else:
        ntl = tl[num]-tl[num-1]
        ndl = sum((abs(dl[num][0] - dl[num - 1][0]), abs(dl[num][1] - dl[num - 1][1])))
        if ntl >= ndl and ntl%2 == ndl%2:
            pass
        else:
            flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
T = [];X = [];Y = []
for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
if N == 1:
    print('Yes' if T[0] == sum(X+Y) else 'No')
    exit()
for i in range(N):
    if i == 0: continue
    d = abs(X[i] + Y[i] - X[i-1] - Y[i-1])
    t = T[i] - T[i-1]
    if (t + d) % 2 or t < d:
        print('No')
        exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = [];X = [];Y = []
for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
if N == 1:
    print('Yes' if T[0] == sum(X+Y) else 'No')
    exit()
for i in range(N):
    if i == 0: continue
    d = abs(X[i] + Y[i] - X[i-1] - Y[i-1])
    t = T[i] - T[i-1]
    if t >= d:
        t = t % 2
        d = d % 2
        if (t != 0 and d == 0) or (t == 0 and d != 0):
            print('No')
            exit()
    else:
        print('No')
        exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = []
X = []
Y = []
for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

before_t = before_x = before_y = 0

for t,x,y in zip(T,X,Y):

    if before_t == 0:
        if t != x + y:
            print('No')
            exit()

    d = abs(x + y - before_x - before_y)

    if t - before_t >= d:
        if (t - before_t) % 2 == 0 and d % 2 == 0:
            pass
        elif (t - before_t) % 2 != 0 and d % 2 != 0:
            pass
        else:
            print('No')
            exit()
    else:
        print('No')
        exit()

    before_t = t
    before_x = x
    before_y = y

else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
n=int(input())
t=[]
for i in range(n):
    t.append(list(map(int,input().split())))
for i,d in enumerate(t):
    if i>0:
        b=d[0]-a
        c=abs(d[1]+d[2]-aa)
    a=d[0]
    aa=d[1]+d[2]
    if i==0:
        if not (a >= aa and a % 2 == aa % 2):
            print('No')
            sys.exit()
        else:
            continue
    if not (b>=c and b%2==c%2):
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
for i in range(N):
    dt = t[i + 1] - t[i]
    dst = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if (dt < dst) or (dt % 2 != dst % 2):
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
x=y=t=0
ans='Yes'
for i in range(n):
  c=a[i]
  xy=c[1]+c[2]-(x+y)
  if xy>c[0]-t:
    ans='No'
    break
  else:
    if xy%2!=(c[0]-t)%2:
      ans='No'
      break
    elif abs(c[1]-x)+abs(c[2]-y)>c[0]-t:
      ans='No'
      break
  x=c[1]
  y=c[2]
  t=c[0]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
x=y=t=0
ans='Yes'
for i in range(n):
  xy=a[i][1]+a[i][2]-(x+y)
  if xy>a[i][0]-t:
    ans='No'
    break
  else:
    if xy%2!=(a[i][0]-t)%2:
      ans='No'
      break
    elif abs(a[i][1]-x)+abs(a[i][2]-y)>a[i][0]-t:
      ans='No'
      break
  x=a[i][1]
  y=a[i][2]
  t=a[i][0]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t = [0] * (n + 1)
x = [0] * (n + 1)
y = [0] * (n + 1)
for i in range(n):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())

can = True
for i in range(n):
    dt = t[i+1] -t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dt < dist:
        can = False
    # ここはよくわかっていない
    if dist % 2 != dt % 2:
        can = False
if can:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

l = []
l.append([0, 0, 0])
for _ in range(n): l.append(list(map(int, input().split())))

for i in range(n):
  t = abs(l[i][1] - l[i+1][1]) + abs(l[i][2] - l[i+1][2])
  s = l[i+1][0] - l[i][0]
  if t > s or t%2 != s%2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
T = []
X = []
Y = []
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
flag = 0
if T[0]-abs(X[0])-abs(Y[0]) < 0 or (T[0]-abs(X[0])-abs(Y[0]))%2 != 0:
    flag = 1
for i in range(N-1):
    if T[i+1]-T[i]-abs(X[i+1]-X[i])-abs(Y[i+1]-Y[i]) < 0 or (T[i+1]-T[i]-abs(X[i+1]-X[i])-abs(Y[i+1]-Y[i]))%2 != 0:
        flag = 1
print("Yes" if flag == 0 else "No")

Submission status: Accepted

Solution code:
N = int(input())
t = 0
x = 0
y = 0
for i in range(N):
    t1,x1,y1 = map(int,input().split())
    if abs(x1-x) + abs(y1-y) > t1-t or (abs(x1-x) + abs(y1-y) - (t1-t)) % 2 != 0:
        print('No')
        exit(0)
    t,x,y = t1,x1,y1
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txy = [[0,0,0] for i in range(N+1)]
for i in range(1,N+1):
    txy[i] = list(map(int,input().split()))

ans = 'Yes'
for i in range(1,N+1):
    dist = abs(txy[i][1]-txy[i-1][1])+abs(txy[i][2]-txy[i-1][2])
    dt   = txy[i][0]-txy[i-1][0]
    
    if dist%2 != dt%2 or dist>dt:
        ans = 'No'
        
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ct,cx,cy=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    dt=t-ct
    dx=x-cx
    dy=y-cy
    if dt<abs(dx)+abs(dy):
        print('No')
        exit()
    elif (dt-(abs(dx)+abs(dy)))%2!=0:
        print('No')
        exit()
    ct=t
    cx=x
    cy=y


print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = [[0,0,0]]+[ [int(x) for x in input().split()] for _ in range(N)]

flag = 'Yes'
i = 0
while flag=='Yes' and i<len(T)-1:
    t1,x1,y1 = T[i] 
    t2,x2,y2 = T[i+1]
    dis = abs(x2-x1)+abs(y2-y1)
    _t = t2-t1
    if dis > _t or _t%2 != dis%2:
        flag = 'No'
    i += 1        
print(flag)

Submission status: Accepted

Solution code:
t,x,y = 0, 0, 0
for i in range(int(input())):
    next_t,next_x,next_y = map(int, input().split())
    dist = abs(next_x - x) + abs(next_y - y)
    time = next_t - t
    if dist > time or (dist - time) % 2 == 1:
        print("No")
        exit(0)
    t,x,y = next_t,next_x,next_y
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

t,x,y = 0,0,0
for _ in range(1, N+1):
    tn,xn,yn = map(int, input().split())
    step = tn-t
    step_needed = abs(x-xn) + abs(y-yn)
    
    if step < step_needed or step%2 != step_needed%2:
        print("No")
        break
    t,x,y = tn,xn,yn
    
else:  
    print("Yes")

Submission status: Accepted

Solution code:
T = [[0, 0]]
for i in range(int(input())):
    t, x, y = map(int, input().split())
    T.append((t, x + y))

    dt = T[i+1][0] - T[i][0]
    dxy = abs(T[i+1][1] - T[i][1])

    if dt < dxy or dt % 2 != dxy % 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
T = [[0, 0]]
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append((t, x + y))

for i in range(N):
    dt = T[i+1][0] - T[i][0]
    dxy = abs(T[i+1][1] - T[i][1])

    if dt < dxy or dt % 2 != dxy % 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
X=0
Y=0
T=0
for i in range(n):
    t,x,y=map(int,input().split())
    if t-T>=abs(X-x)+abs(Y-y) and (t-T)%2==(abs(X-x)+abs(Y-y))%2:
        T=t
        X=x
        Y=y
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t,x,y = 0,0,0
for n in range(N):
  T,X,Y = map(int,input().split())
  D = abs(X-x) + abs(Y - y) 
  if D <= T - t and (T - t - D) % 2 == 0:
    x = X
    y = Y
    t = T
  else:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txy = list(list(map(int, input().split())) for _ in range(N))
dt = 0
dx = 0
dy = 0
for i in range(N):
    if abs(txy[i][1]-dx)+abs(txy[i][2]-dy) > txy[i][0]-dt or (txy[i][1]+txy[i][2])%2 != txy[i][0]%2:
        print("No")
        break
    dt = txy[i][0]
    dx = txy[i][1]
    dy = txy[i][2]
else:
    print("Yes")

Submission status: Accepted

Solution code:
N=int(input())+1
t,x,y,r=[0]*N,[0]*N,[0]*N,1
N-=1
for i in range(N):
    i+=1
    t[i],x[i],y[i]=map(int,input().split())

def a(t,x,y):
    return (x+y<=t)*(1-(x+y-t)%2)

for i in range(N):
    r*=a(t[i+1]-t[i],abs(x[i+1]-x[i]),abs(y[i+1]-y[i]))
print(['No','Yes'][r])

Submission status: Accepted

Solution code:
N=int(input())
x,y=0,0
time=0
for i in range(N):
  t,a,b=map(int,input().split())
  if abs(x-a)+abs(y-b)>t-time or (abs(x-a)+abs(y-b)-t+time)%2==1:
    print("No")
    exit()
  time=t
  x=a
  y=b
print("Yes")