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
X = Y = 0
Flag = 'Even'

for n in range(N):
    Ti,Xi,Yi = [int(x) for x in input().split()]
    if abs(Xi-X) + abs(Yi-Y) > (Ti-T):
        print('No')
        break
    else:
        if Flag == 'Even':
            if (Ti-T) % 2 == 0:#Even and Even = Even
                if (Xi + Yi) % 2 == 0:
                    X = Xi
                    Y = Yi
                    T = Ti
                    continue
                else:
                    print('No')
                    break
            else:#Even and Odd = Odd
                if (Xi + Yi) % 2 == 0:
                    print('No')
                    break
                else:
                    X = Xi
                    Y = Yi
                    T = Ti
                    Flag = 'Odd'
                    continue
        else:#Odd
            if (Ti - T) % 2 == 0: #Odd and Even = Odd
                if(Xi + Yi)% 2 == 0:
                    print('No')
                    break
                else:
                    X = Xi
                    Y = Yi
                    T = Ti
                    continue
            else: #Odd and Odd = Even
                if(Xi + Yi) % 2 == 0:
                    X = Xi
                    Y = Yi
                    T = Ti
                    Flag = 'Even'
                    continue
                else:
                    print('No')
                    break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if (x+y)>t or (x+y+t)%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(n):
    t,x,y = map(int,input().split())
    if (x + y <= t and t % 2 == (x + y) % 2):
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()

pt = 0
px = 0
py = 0

for _ in range(N):
  t, x, y = mi()
  mnht = abs(x-px) + abs(y-py)
  if not (t-pt >= mnht and (t-pt)%2 == mnht % 2):
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
N = int(input())

for i in range(N):
	t, x, y = map(int, input().split(" "))
	t = t - x - y
	if t % 2 != 0 or t < 0:
		print("No")
		sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
n=int(input())
t_pre=0
x_pre=0
y_pre=0
for _ in range(n):
    t,x,y=map(int,input().split())
    if t-t_pre<abs(x-x_pre)+abs(y-y_pre):
        print("No")
        sys.exit(0)
    elif (t-t_pre)%2!=(abs(x-x_pre)+abs(y-y_pre))%2:
        print("No")
        sys.exit(0)
print("Yes")

Submission status: Accepted

Solution code:
import sys
ans = "Yes"; input()

for e in sys.stdin:
    t, x, y = map(int, e.split())
    t = t - x - y
    if t < 0 or t % 2 == 1:
        ans = "No"
        break
print(ans)

Submission status: Accepted

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

check = [False for i in range(N)]

for i in range(N):
        if i == 0:        
                t = TXY[0][0]
                x = TXY[0][1]
                y = TXY[0][2]
                if t >= (x+y) and t%2 ==(x+y)%2 :
                        check[0] = True
                else:
                        break
        else :
                t = TXY[i][0] - TXY[i-1][0]
                x = TXY[i][1] - TXY[i-1][1]
                y = TXY[i][2] - TXY[i-1][2]
                if t >= (x+y) and t%2 ==(x+y)%2 :
                        check[i] = True
                else:
                        break

ans = check.count(True)
if ans == N :
        print('Yes')
else:
        print('No')

Submission status: Accepted

Solution code:
N = int(input())
table = [[int(i) for i in input().split()] for n in range(N)]
can = True
for i in range(N):
    if(i != 0):
        dt = table[i][0] - table[i-1][0]
        dist = abs(table[i][1]-table[i-1][1]) +abs(table[i][2]-table[i-1][2])
    else:
        dt = table[i][0]
        dist = abs(table[0][1]) + abs(table[0][2])
    if(dist > dt):
        can = False
        break
    elif((dt-dist)%2 != 0):
        can = False
        break
if(can == True):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(1, N+1):
  can = False
  dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
  dt = abs(t[i] - t[i-1])
  if dist <= dt:
    if dist % 2 == dt % 2:
      can = True
  if can == False:
    break
if can == True:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())

t_prev = 0
x_prev = 0
y_prev = 0
possible = True
for i in range(n):
    t, x, y = map(int, input().split())

    z = (t - t_prev) - (abs(x - x_prev) + abs(y - y_prev))
    if z < 0 or z % 2 == 1:
        possible = False

    t_prev, x_prev, y_prev = t, x, y

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC86 C

n = int(input())

nt,nx,ny = 0,0,0
f = 1
for _ in range(n):
    t,x,y = map(int,input().split())
    if t - nt < abs(nx - x) + abs(ny - y):
        f = 0
    s = abs(nx - x) + abs(ny - y) - (t - nt)
    if s % 2 == 1:
        f = 0
    nt,nx,ny = t,x,y
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

memo = [[0, 0, 0]]
# diff_t = 0
# diff_x = 0
# diff_y = 0

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

# print(memo)

for i in range(1, N+1):
    diff_s = memo[i][0] - memo[i-1][0]
    # print(diff_s)
    diff_m = abs(memo[i][1]-memo[i-1][1])+abs(memo[i][2]-memo[i-1][2])
    if diff_m > diff_s:
        print('No')
        exit()
    if diff_m % 2 == 0 and diff_s % 2 == 0:
        pass
    elif diff_m % 2 == 1 and diff_s % 2 == 1:
        pass
    else:
        print('No')
        exit()



print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pret, prex, prey = 0, 0, 0

for i in range(N):
  t,x,y = map(int,input().split())
  if (t - pret >= abs(x-prex)+abs(y-prey)) and (t-pret)%2 == (abs(x-prex)+abs(y-prey))%2:
    pret,prex,prey = t,x,y    
    continue
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
pret = prex = prey = 0
res = True
for _ in range(N):
    t,x,y = map(int,input().split())
    dt,dx,dy = t-pret,x-prex,y-prey
    pret,prex,prey = t,x,y
    r = dt-abs(dx)-abs(dy)
    if r<0 or r%2!=0:res = False
print('Yes' if res else 'No')

Submission status: Accepted

Solution code:
def hantei(t,x,y):
  if t%2==(x+y)%2 and t>=(abs(x)+abs(y)):
    return True
  else:
    return False
N=int(input())
result=[]
t=0
x=0
y=0
T=0
Y=0
X=0
for i in range(N):
  t,x,y=map(int,input().split())
  result.append(hantei(t-T,x-X,y-Y))
  T=t
  X=x
  Y=y
if False in result:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
points = [list(map(int, input().split())) for i in range(n)]
points.insert(0, [0, 0, 0])

flg = True

for i in range(n):
    dt = points[i + 1][0] - points[i][0]
    dist = abs(points[i + 1][1] - points[i][1]) + abs(points[i + 1][2] - points[i][2])
    if dt < dist:
        flg = False
        break
    if dist % 2 != dt % 2:
        flg = False
        break

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
row = [input().split() for i in range(N)]
f = np.vectorize(int)
t = f(row)
Flag = 0

time = t[0][0]
x = t[0][1]
y = t[0][2]
dis = abs(x) + abs(y)
if dis % 2 == time % 2 and dis <= time:
    for i in range(1,N):
        time = t[i][0] - t[i-1][0]
        x = t[i][1] - t[i-1][1]
        y = t[i][2] - t[i-1][2]
        dis = abs(x) + abs(y)
        if dis % 2 == time % 2 and dis <= time:
            continue
        else:
            Flag = 1
            break
else:
    Flag = 1

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

Submission status: Accepted

Solution code:
N = int(input())
now = [0, 0, 0]
ans = 'Yes'
for i in range(0, N):
	T, X, Y = map(int, input().split())
	nexttime = T - now[0]
	nextX = abs(X - now[1])
	nextY = abs(Y - now[2])
	if nexttime < nextX + nextY:
		ans = 'No'
		break
	if (nexttime-(nextX+nextY)) % 2 == 1:
		ans = 'No'
		break
	now = [T, X, Y]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
now_x = 0
now_y = 0
now_t = 0
f = 0
for _ in range(N):
    t,x,y  = map(int,input().split())
    abs_xy = abs(x-now_x)+abs(y-now_y)
    abs_t = abs(t-now_t)
    if abs_xy == abs_t or (abs_t > abs_xy and (abs_t -abs_xy)%2 ==0):
        now_x = x
        now_y = y
        now_t = t
    else:
        f = 1
        break

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

Submission status: Accepted

Solution code:
N = int(input())

for n in range(N):
  t, x, y = map(int, input().split())
  if t-x-y < 0 or (t-x-y)%2 != 0:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
n = input()
n = int(n)

points = []
points.append(("0", "0", "0"))
for i in range(n):
  points.append(input().split())

for i in range(len(points)-1):
  dt = int(points[i+1][0]) - int(points[i][0])
  dx = int(points[i+1][1]) - int(points[i][1])
  dy = int(points[i+1][2]) - int(points[i][2])
  
  if dt < abs(dx)+abs(dy):
    print("No")
    exit()
  elif (dt - ( abs(dx)+abs(dy) ) ) % 2 == 1:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

tt = 0
xx = 0
yy = 0
f = 0
for i in range(N):
    t, x, y = map(int, input().split())

    dt = t - tt
    dx = x - xx
    dy = y - yy
    dxy = dx + dy

    if dt%2 == 0:
        if dxy <= dt and dxy%2 == 0:
            continue
        else:
            f = 1
            break
    else:
        if dxy <= dt and dxy%2 == 1:
            continue
        else:
            f = 1
            break

if f == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

def manhattan(x1,x2,y1,y2):
	return abs(x2-x1) + abs(y2-y1)
x,y = 0,0
can = True
dt = data[0][0]
for i in range(n):
	dist = manhattan(x,data[i][1],y,data[i][2])
	if dist > dt:
		can = False
		break
	elif (dt - dist) % 2 != 0:
		can = False
		break
	if i == n-1:
		break
	x = data[i][1]
	y = data[i][2]
	dt = data[i+1][0] - data[i][0]
if can:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
def traveling():
	N = int(input())
	t = [0] * (N + 1)
	x = [0] * (N + 1)
	y = [0] * (N + 1)
	for i in range(1, N + 1):
		t[i], x[i], y[i] = map(int, input().split())
	
	flag = True
	for i in range(1, N + 1):
		dt = t[i] - t[i - 1]
		dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
		if dist > dt:
			flag = False
		if dist % 2 != dt % 2:
			flag = False
		
	
	if flag:
		print('Yes')
	else:
		print('No')

traveling()

Submission status: Accepted

Solution code:
N=input()
a=[]
t=True
for _ in range(int(N)):
    a+=[list(map(int,input().split()))]
for i in range(int(N)):
    if a[i][0]%2==0:
        if abs(a[i][1]+a[i][2])<=a[i][0] and (a[i][1]+a[i][2])%2==0:
            continue
        else:
            print('No')
            t=False
            break
    else:
        if abs(a[i][1]+a[i][2]<=a[i][0]) and (a[i][1]+a[i][2])%2==1:
            continue
        else:
            print('No')
            t=False
            break
if t:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if x+y>t or t%2!=(x+y)%2 : 
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
# Nが偶数なら x + y = 偶数
# 移動距離 < tの変化
import sys

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

t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)

for j in range(1, len(t)):
    if t[j] % 2 == 0:
        if (x[j] + y[j]) % 2 != 0:
            print("No")
            sys.exit()
    else:
        if (x[j] + y[j]) % 2 == 0:
            print("No")
            sys.exit()
    if ((x[j] - x[j-1]) + (y[j] - y[j-1])) > t[j] - t[j-1]:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
cor_lis = [0] * N
diff_lis = [0] * N
for n in range(N):
    cor_lis[n] = tuple(map(int, input().split()))
cor_lis = [[0, 0, 0]] + cor_lis
for n in range(N):
    diff_lis[n] = [cor_lis[n + 1][0] - cor_lis[n][0], abs(cor_lis[n + 1][1] - cor_lis[n][1]), abs(cor_lis[n + 1][2] - cor_lis[n][2])]
    if diff_lis[n][0] % (diff_lis[n][1] + diff_lis[n][2]) != 0:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

t = [0]
x = [0]
y = [0]
for i in range(N):
    a = input().split(" ")
    t.append(int(a[0]))
    x.append(int(a[1]))
    y.append(int(a[2]))

flag = 0
for i in range(1,N+1):
    t[i] = t[i]-t[i-1]
    x[i] = x[i]-x[i-1]
    y[i] = y[i]-y[i-1]
    if (x[i]+y[i])%2 == t[i]%2:
        if x[i] >= 0:
            if y[i] <= -x[i] + t[i] and y[i] >= x[i] - t[i]:
                continue
            else:
                print("No")
                flag = 1
                break
        else:
            if y[i] <= x[i] + t[i] and y[i] >= -x[i] - t[i]:
                continue
            else:
                print("No")
                flag = 1
                break
    else:
        print("No")
        flag = 1
        break

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

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0
N = int(input())
r = "Yes"
for i in range(0, N):
  t2, x2, y2 = map(int, input().split())
  d = abs(x2-x)+abs(y2-y)
  if not(t2-t>=d and d%2==(t2-t)%2):
    r = "No"
    break
print(r)

Submission status: Accepted

Solution code:
N = int(input())
now_x = 0
now_y = 0
now_time = 0
ans = 1
for i in range(N):
    t, x, y = map(int, input().split())
    distance = abs(now_x - x) + abs(now_y - y)
    time = t - now_time
    sa = time-distance
    if sa >= 0 and sa % 2 == 0:
        now_x, now_y, now_time = x, y, t
        continue
    else:
        ans = 0
        continue

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

Submission status: Accepted

Solution code:
N = int(input())
C = []
for i in range(N):
    C.append(list(map(int, input().split())))
c_pre = [0, 0, 0]
for c_now in C:
    tr = abs(c_now[0]-c_pre[0])
    length = abs(c_now[1]-c_pre[1])+abs(c_now[2]-c_pre[2])
    if length<=tr and tr%2==length%2:
        c_pre = c_now
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
px,py,pt=0,0,0
import sys
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(x-px)+abs(y-py)<=t-pt and (t-pt-abs(x-px)-abs(y-py))%2==0:
        px,py,pt=x,y,t
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

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

now=[0,0,0]
for i in range(n):
    kyori=abs(now[1]-txy[i][1])+abs(now[2]-txy[i][2])
    tsa=txy[i][0]-now[0]

    if kyori>tsa:
        print("No")
        break
    if kyori%2!=tsa%2:
        print("No")
        break
    now=txy[i]
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t_0, x_0, y_0 = 0, 0, 0

for n in range(N):
  t_1, x_1, y_1 = [int(txyz) for txyz in input().split()]
  d_01 = abs(x_1 - x_0) + abs(y_1 - y_0)
  dt = t_1 - t_0
  if dt < d_01:
    print("No")
    break
  else:
    t_d = dt - d_01
    if t_d % 2 == 0:
      t_0, x_0, y_0 = t_1, x_1, y_1
    else:
      print("No")
      break
else:
  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()) 
flag=0
for i in range(n):
    l=abs(x[i]-x[i+1])+abs(y[i]-y[i+1])
    s=t[i+1]-t[i]
    if(l>s or (l-s)%2==1):
        flag=1
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
coords = []
status = "Yes"
for i in range(N):
    coords.append(list(map(int, input().split())))

x = 0
y = 0
for coord in coords:
  summy = abs(x-coord[1]) + abs(y - coord[2])
  parity = (coord[1] + coord[2]) % 2
  if summy > coord[0] or parity != coord[0] % 2:
    status = "No"
    break
  else:
    pass
  x = coord[1]
  y = coord[2]
print(status)

Submission status: Accepted

Solution code:
n=int(input())
c=0
for i in range(n):
    ti,xi,yi=map(int,input().split())
    if (xi+yi)%2==ti%2 and ti>=xi+yi:
        c+=1
if n<=c<=n:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]
txy.insert(0, [0, 0, 0])
time = 0
d = 0
for i in range(N):
    time = txy[i + 1][0] - txy[i][0]
    d = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    if time >= d and time % 2 == d % 2:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:

N = int(input())

txy = [[0,0,0]]

for i in range(N):

    new = list(map(int,input().split()))

    txy.append(new)

ans = "Yes"
for i in range(N):

    leng = abs(txy[i+1][1]-txy[i][1]) + abs(txy[i+1][2]-txy[i][2])
    time = txy[i+1][0]-txy[i][0]



    if leng > time or (leng-time)%2 != 0 :
        ans = "No"
        #print(leng,time)
        break

print (ans)

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = [0, 0, 0]
for _ in range(N):
  t, x, y = map(int, input().split())
  d = (t - t0) - (abs(x - x0) + abs(y - y0))
  if d < 0 or d % 2 == 1:
    print('No')
    exit()
  else:
    t0 = t
    x0 = x
    y0 = y
print('Yes')

Submission status: Accepted

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

for i in range(N):
    dxdy = coo[i+1][0] - coo[i][0] + coo[i+1][1] - coo[i][1]
    rt = (T[i+1] - T[i]) % 2
    rdxdy = dxdy % 2
    if dxdy <= T[i+1] - T[i] and rt == rdxdy:
        pass
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    n = int(input())
    for i in range(n):
        t, x, y = map(int, input().split())
        if t<x+y or (t-x-y)%2:
            print("No")
            break
    else: print("Yes")
if __name__=="__main__": main()

Submission status: Accepted

Solution code:
n = int(input())
x = [input().split() for i in range(n)]

mm = 0
flag = 1

if int(x[0][0]) < int(x[0][1]) + int(x[0][2]):
    flag = 0
else:
    if int(x[0][0])%2 != (int(x[0][1]) + int(x[0][2]))%2:
        flag = 0
    else:
        for i in range(n-1):
            if int(x[i+1][0])-int(x[i][0]) < int(x[i+1][1]) +int(x[i+1][2])-int(x[i][1])-int(x[i][2]):
                flag = 0
                break
            else:
                if (int(x[i+1][0])-int(x[i][0]))%2 != (int(x[i+1][1]) +int(x[i+1][2])-int(x[i][1])-int(x[i][2]))%2:
                    flag = 0
                    break            

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

Submission status: Accepted

Solution code:
n = int(input())
info = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    info.append(tmp)
diff = [[info[0][0], info[0][1]+info[0][2]]]
for i in range(n-1):
    time_diff = info[i+1][0] - info[i][0]
    dist_diff = abs(info[i+1][1]-info[i][1]) + abs(info[i+1][2]-info[i][2])
    diff.append([time_diff, dist_diff])
    
flg = 0
for i in range(len(diff)):
    if diff[i][0] < diff[i][1] or (diff[i][0]- diff[i][1]) % 2 !=0:
        flg=1
        break
if flg ==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
arr_old = [0,0,0]
for i in range(n):
    arr = list(map(int,input().split()))
    if arr[0] % 2 != (arr[1]+arr[2]) % 2:
        print("No")
        exit()
    if abs(arr[1]-arr_old[1])+abs(arr[2]-arr_old[2]) > arr[0]-arr_old[0]:
        print("No")
        exit()
    arr_old = arr
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
for __ in range(N):
    t, x, y = map(int, input().split())
    if (x + y) > t or (x + y + t) % 2 == 1:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
t[0],x[0],y[0]=0,0,0
for i in range(1,n+1):
  t[i],x[i],y[i]=map(int, input().split())
d='Yes'
for i in range(n):
  a=t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i])
  if a<0 or a%2==1:
    d='No'
    break
print(d)

Submission status: Accepted

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

x = 0 
y = 0
t = 0

for i in Input:
    dif_x = abs(x - i[1])
    dif_y = abs(y - i[2])
    dif_t = abs(t - i[0])

    if dif_x + dif_y <= dif_t and (dif_x + dif_y)%2 == dif_t%2:
        x = i[1]
        y = i[2]
        t = i[0]
    else:
        print("No")
        break

else:
    print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
for i in range(N):
    t,x,y=map(int, input().split())
    j=x+y
    if t<j or (t+j)%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
T=[list(map(int,input().split())) for i in range(N)]
for i in range(N):
    t=T[i][0]
    j=T[i][1]+T[i][2]
    if t<j or (t+j)%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())

ans='Yes'
dt=0
cur=0
cur_t=0
dist=0
for i in range(n):
	t,x,y=map(int,input().split())
	dist=abs(cur-(x+y))
	cur=x+y
	dt=t-cur_t
	cur_t=t
	
	if dist>dt or dt%2!=(dist)%2:
		ans='No'
		break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

ans='Yes'
dt=0
cur=0
cur_t=0
dist=0
for i in range(n):
	t,x,y=map(int,input().split())
	dist=abs(cur-(x+y))
	cur=x+y
	dt=t-cur_t
	cur_t=t
	
	if dist>dt:
		ans='No'
		break
	if dt%2==0 and (dist)%2==0 or dt%2==1 and (dist)%2==1:continue
	else:
		ans='No'
		break
print(ans)

Submission status: Accepted

Solution code:
import sys
n=int(input())
plan=[[0,0,0]]
for i in range(n):
    plan.append(list(map(int,input().split())))
for i in range(n):
    dt=abs(plan[i][0]-plan[i+1][0])
    dx=abs(plan[i][1]-plan[i+1][1])
    dy=abs(plan[i][2]-plan[i+1][2])
    if dt<dx+dy:
        print('No')
        sys.exit()
    if abs(dx+dy-dt)%2!=0:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
N,t0,x0,y0,ans=int(input()),0,0,0,0
for _ in range(N):
    t,x,y=map(int,input().split())
    timerest=(t-t0)-(x+y-x0-y0)
    if timerest<0 or timerest%2==1:ans=1
    t0,x0,y0=t,x,y
if ans==0:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
n = int(input())
t = 0
res = True
x, y = 0, 0
for i in range(n):
    t2, x2, y2 = map(int, input().split())
    dt = t2 - t
    #print("cur {0} {1} {2}".format(t, x, y))
    #print("d {0} {1} {2}".format(dt, x2, y2))
    #print("ju {0} {1} {2} {3}".format(abs(x-x2) + abs(y-y2), dt, (abs(x-x2) + abs(y-y2) - dt) % 2, 1))

    if abs(x-x2) + abs(y-y2) > dt or (abs(x-x2) + abs(y-y2) - dt) % 2 == 1:
        res = False
    t, x, y = t2, x2, y2
print("Yes" if res else "No")

Submission status: Accepted

Solution code:
n = int(input())
t_pre = 0
x_pre = 0
y_pre = 0
can = 0
for i in range(n) :
    s = input().split(" ")
    t = int(s[0])
    x = int(s[1])
    y = int(s[2])
    sa = t - t_pre - ((x - x_pre) + (y - y_pre))
    if sa >= 0 and sa % 2 == 0 :
        can = 1
    else :
        can = 0
        break
    t_pre = t
    x_pre = x
    y_pre = y
if bool(can) :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
t,x,y = [0]*(n+1),[0]*(n+1),[0]*(n+1)

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

for i in range(1,n+1):
    cnt = (t[i]-t[i-1])-abs(x[i]-x[i-1])-abs(y[i]-y[i-1])
    if cnt>=0 and cnt%2==0:
        pass
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
s = [[0,0,0]]*(N+1)
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
for i in range(1,N+1):
  s[i] = input().split()
  t[i] = int(s[i][0])
  x[i] = int(s[i][1])
  y[i] = int(s[i][2])
k = 0
for i in range(N):
  dt = t[i+1]-t[i]
  d = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1])
  if d <= dt and d%2 == dt%2:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
 
nopass = False
for i in range(n) :
    t, x, y = map(int, input().split())
    if (x+y > t) or ((x+y+t)%2 == 1) :
        nopass = True
        break

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

Submission status: Accepted

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

can = True

for n in range(len(input_lis)):
    dis = 0
    t = 0
    if n == 0:
        dis = abs(input_lis[n][1]) + abs(input_lis[n][2])
        t = abs(input_lis[n][0])
    else:
        dis = abs(input_lis[n][1] - input_lis[n-1][1]) + abs(input_lis[n][2] - input_lis[n-1][2])
        t = abs(input_lis[n][0]) - abs(input_lis[n-1][0])
    
    if dis == t:
        continue
    if dis < t and ((t - dis) % 2) == 0:
        continue
    can = False
    break

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

Submission status: Accepted

Solution code:
N=int(input())
t,x,y=0,0,0
s=0
for i in range(N):
  a,b,c=map(int,input().split())
  p,q=a-t,abs(b-x)+abs(c-y)
  if p<q or p%2!=q%2:
    s=1
    break
  t,x,y=a,b,c
print("No" if s else "Yes")

Submission status: Accepted

Solution code:
N=int(input())
I=[[0,0,0]]
for i in range(N):
    I.append(list(map(int,input().split())))
    
check=0
for i in range(N):
    time=I[i+1][0]-I[i][0]
    len=abs(I[i+1][1]-I[i][1])+abs(I[i+1][2]-I[i][2])
    if len>time:
        check=1
        break
    if (time-len)%2 != 0:
        check=1
        break

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

Submission status: Accepted

Solution code:
N=int(input())
t=x=y=0
for i in range(N):
    t_,x_,y_=map(int,input().split())
    k=t_-t-(x_-x+y_-y)
    if k<0 or k%2==1:
        print("No")
        quit()
    t=t_
    x=x_
    y=y_
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in range(n):
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def resolve():

    n = int(input())

    list_t = [0] * 100010
    list_x = [0] * 100010
    list_y = [0] * 100010

    for i in range(n):
        list_t[i], list_x[i], list_y[i] = map(int, input().split())

    for i in range(n):

        if i == 0:
            delta_t = list_t[i]
            delta_xy = list_x[i] + list_y[i]

        else:
            delta_t = list_t[i] - list_t[i-1]
            delta_xy = abs(list_x[i] + list_y[i] - list_x[i-1] - list_y[i-1])

        if delta_t < delta_xy:
            print('No')
            return

        if delta_t % 2 != delta_xy % 2:
            print('No')
            return

    print('Yes')
    
resolve()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y) > t or (x + y + t) % 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import time

def is_feasible_travel(N, t, x, y):
    t_old, x_old, y_old = t[0], x[0], y[0]
    if N == 1:
        if t_old < (x_old + y_old):
            return False
        if (t_old % 2) == ((x_old + y_old) % 2):
            return True
        else:
            return False

    for ti, xi, yi in zip(t[1:], x[1:], y[1:]):
        t_diff = ti - t_old
        x_diff = abs(xi - x_old)
        y_diff = abs(yi - y_old)

        dist = x_diff + y_diff
        if dist > t_diff:
            return False
        elif dist < t_diff:
            if (dist % 2) != (t_diff % 2):
                return False

        t_old, x_old, y_old = ti, xi, yi
    return True


def main():
    N = int(input())
    t = [0] * N
    x = [0] * N
    y = [0] * N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())

    # start = time.time()
    if is_feasible_travel(N, t, x, y):
        print("Yes")
    else:
        print("No")
    # print(time.time() - start)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
de=[[0,0,0]]
for i in range(n):
  de.append(list(map(int,input().split())))
flag=0
for i in range(n):
  interval=de[i+1][0]-de[i][0]
  distance=abs(de[i+1][1]-de[i][1])+abs(de[i+1][2]-de[i][2])
  if interval<distance:
    flag=1
    break
  elif (interval-distance)%2==0:
    continue
  else:
    flag=1
    break
if flag==1:
  print("No")
else:
  print("Yes")