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:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
prev_x = prev_y = prev_t = 0

for _ in range(N):
    t, x, y = map(int, readline().split())

    time = t - prev_t
    dist = abs(x - prev_x) + abs(y - prev_y)

    if dist > time or dist % 2 != time % 2:
        print("No")
        break

    prev_x, prev_y, prev_t = x, y, t

else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
nowx = 0
nowy = 0
nowt = 0

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

for i in range(n):
    nextt, nextx, nexty = map(int,input().split())
    if (nextt - nowt) >= manhattan(nowx,nowy,nextx,nexty) and (nextt - nowt)%2 == manhattan(nowx,nowy,nextx,nexty)%2:
        nowx, nowy, nowt = nextx, nexty, nextt
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    A = [list(map(int, input().split())) for i in range(n)]

    t = 0
    x = 0
    y = 0
    flag = True
    for i in range(n):
        if (A[i][0] % 2 == 0 and (A[i][1] + A[i][2]) % 2 != 0) or (A[i][0] % 2 == 1 and (A[i][1] + A[i][2]) % 2 != 1):
            flag = False
            break
        elif abs(A[i][1] - x) + abs(A[i][2] - y) > (A[i][0] - t):
            flag = False
            break
        else:
            t = A[i][0]
            x = A[i][1]
            y = A[i][2]

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


resolve()

Submission status: Accepted

Solution code:
N=int(input())
tn,xn,yn=0,0,0
judge=[]
for i in range(N):
    t1,x1,y1=map(int,input().split())
    td=abs(t1-tn)
    xd=abs(x1-xn)
    yd=abs(y1-yn)
    if t1%2==(x1+y1)%2 and td>=xd+yd:
        judge.append(True)
    else:
        judge.append(False)

    tn,xn,yn=t1,x1,y1
print('Yes' if all(judge) else 'No')

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().rstrip("\n"))
x,y = 0,0
t = 0
i = 0
while i < n:
    t_,x_,y_ = map(int, sys.stdin.readline().rstrip("\n").split())
    d = abs((x_+y_)-(x+y))
    t_d = t_-t
    if t_d >= d:
        if (t_d-d) % 2 == 0:
            x,y = x_,y_
            t = t_
            i += 1
        else:
            print('No')
            break
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

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

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

print("Yes")

Submission status: Accepted

Solution code:
import sys

def main():
  N = int(input())
  t, x, y = 0, 0, 0
  for i in range(N):
    next_t, next_x, next_y = [int(i) for i in input().split()]
    distance = abs(next_x-x)+abs(next_y-y)
    delta_t = next_t - t
    if distance > delta_t:
      print('No')
      sys.exit()
    elif (distance -delta_t)%2 != 0:
      print('No')
      sys.exit()   
    t, x, y = next_t, next_x, next_y
  print('Yes')
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
txy = [LIST() for _ in range(N)]
txy.insert(0, [0, 0, 0])

for i in range(1, N+1):
	dt = txy[i][0] - txy[i-1][0]
	dx = abs(txy[i][1] - txy[i-1][1])
	dy = abs(txy[i][2] - txy[i-1][2])
	if dt%2 == (dx+dy)%2 and dt >= dx+dy:
		continue
	else:
		print("No")
		break
else:
	print("Yes")

Submission status: Accepted

Solution code:
t = []
 
N = input()
 
for i in range(int(N)):
    t.append(list(map(int, input().split())))
    
t.sort()
 
co, co_ = [0, 0, 0], [0, 0, 0]
flag = 1
 
for i in range(len(t)):
    co_[0] = t[i][0] - co[0]
    co_[1] = t[i][1] - co[1]
    co_[2] = t[i][2] - co[2]
    dis = abs(co_[1]) + abs(co_[2])
    if dis % 2 != (t[i][0]-co[0]) % 2:
        flag = 0
        break
    elif dis > co_[0]:
        flag = 0
        break
        
    co = t[i]
    
if flag == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
t,x,y = 0,0,0
f = True
for i in range(N):
    ti,xi,yi = map(int, input().split())
    p=ti-t
    d=abs(xi-x)+abs(yi-y)
    if p<d or p%2 != d%2:
        f = False
        break 
    t,x,y = ti,xi,yi
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
N = int(input())
time_coor = []
for n in range(N+1):
    if n==0:
        time_coor.append([0, 0, 0])
    else:
        time_coor.append(list(map(int, input().split())))

can = True
for n in range(N):
    dist = abs(time_coor[n+1][1]-time_coor[n][1]) + \
           abs(time_coor[n+1][2]-time_coor[n][2])
    time = time_coor[n+1][0]-time_coor[n][0]
    if dist>time:
        can = False
        break
    elif dist%2==time%2:
        continue
    else:
        can = False
        break
    

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

Submission status: Accepted

Solution code:
time = int(input())
jorney = [list(map(int,input().split())) for i in range(time)]
flg = True
x_before = 0
y_bfefore =0
t_before = 0

for point in jorney:
    t = point[0]
    x = point[1]
    y = point[2]
    distance = abs(x- x_before) + abs(y - y_bfefore)
    interval = t - t_before
    
    
    if t %2 == (x+y)%2 and interval >= distance:
        t_before=t
        x_before=x
        y_bfefore=y

        continue
    else:
        flg=False
        break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

time = 0
visited = [0, 0]
result = []

for i in range(N):
    t, *xy = map(int, input().split())
    diff_time = t - time
    diff_dist = sum([abs(xy[i] - visited[i]) for i in range(2)])
    if (diff_dist <= diff_time) & (((diff_time - diff_dist) % 2)==0):
        result.append(True)
    else:
        result.append(False)
    time = t
    visited = xy

print("Yes") if all(result) else print("No")

Submission status: Accepted

Solution code:
num = int(input())


beforTime = 0
beforX = 0
beforY = 0
resultFrag = True
for travel in range(num):
    time, x, y = map(int, input().split())
    move = abs(beforX - x) + abs(beforY - y)
    canMoveTime = time - beforTime
    if move <= canMoveTime and (move + canMoveTime) % 2 == 0:
        beforTime = time
        beforX = x
        beforY =  y
        continue
    resultFrag = False
    break

print("Yes" if resultFrag else "No")

Submission status: Accepted

Solution code:

num = int(input())
travels = []
for _ in range(num):
    travels.append(list(map(int, input().split())))


beforTime = 0
beforX = 0
beforY = 0
resultFrag = True
for travel in travels:
    move = abs(beforX - travel[1]) + abs(beforY - travel[2])
    canMoveTime = travel[0] - beforTime
    if move <= canMoveTime and (move + canMoveTime) % 2 == 0:
        beforTime = travel[0]
        beforX = travel[1]
        beforY =  travel[2]
        continue
    resultFrag = False
    break

print("Yes" if resultFrag else "No")

Submission status: Accepted

Solution code:
# ABC086 C Traveling

n = int(input())
t, x, y = 0, 0, 0
flag = True

for i in range(n):
    _t,_x,_y = map(int, input().split())
    _d = abs(x - _x) + abs(y - _y)
    _dt = abs(t - _t)
    if _d > _dt or ((_d - _dt)%2) == 1:
        flag = False
    t,x,y = _t,_x,_y

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

Submission status: Accepted

Solution code:
n = int(input())
count=0
temp=0
xtemp=0
ytemp=0
for i in range(0,n):
    t,x,y = map(int, input().split())
    if abs(t-temp)>=abs(x-xtemp)+abs(y-ytemp) and (x-xtemp+y-ytemp-(t-temp))%2==0:
        count=count+1
    temp=t
    xtemp=x
    ytemp=y
if count==n:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
t,x,y = 0,0,0
cou = 0
t1,t2,x1,x2,y1,y2= 0,0,0,0,0,0

for i in range(N):
    t,x,y = map (int,input().split())
    if t>=(x+y) and (t+x+y)%2 == 0:
        t1,x1,y1 = t,x,y
        if abs(t1-t2) >= abs((x1-x2)+(y1-y2)):
            cou += 1
        else:
            print("No")
            break
        t2,x2,y2 = t1,x1,y1
    else:
        print("No")
        break

if cou == N:
    print("Yes")

Submission status: Accepted

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

x, y = 0, 0
t = 0
for i in range(N):
    t1 = T[i][0] - t
    x1 = T[i][1]
    y1 = T[i][2]
    if t1 < abs(x1 - x) + abs(y1 - y):
        print('No')
        sys.exit()
    t1 -= abs(x1 - x) + abs(y1 - y)
    if t1 % 2 != 0:
        print('No')
        sys.exit()
    t = T[i][0]
    x = x1
    y = y1
print('Yes')

Submission status: Accepted

Solution code:
import sys

N = int(input())

t = [0]
x = [0]
y = [0]

for i in range(N) : 
    a, b, c = map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)

for i in range(N) : 
    T = t[i+1] - t[i]
    R = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]) 
    if T < R or (T + R) % 2 == 1 :
        print('No')
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:

n = int(input())
prev_t = 0
prev_x = 0
prev_y = 0
ans = True
for i in range(n):
    t,x,y = map(int,input().split())
    d_t = t - prev_t
    d_x = abs(x - prev_x)
    d_y = abs(y - prev_y)
    distance = d_x + d_y
    if d_t < distance or (d_t % 2) != (distance % 2):
        ans = False
    prev_t = t
    prev_x = x
    prev_y = y

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

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    t2, x2, y2 = map(int, input().split())
    T = t2 - t
    d = abs(x2 - x) + abs(y2 - y)
    if T < d or (T % 2 != d % 2):
        print('No')
        break
    t, x, y = t2, x2, y2
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
l = []
t = x = y = 0
for _ in range(n):
    a,b,c = map(int,input().split())
    t_delta = a - t
    x_delta = abs(b - x)
    y_delta = abs(c - y)

    if (x_delta+y_delta <= t_delta) and (t_delta%2 == (x_delta+y_delta)%2):
            pass
    else:
        print ("No")
        exit ()

    t = a
    x = b
    y = c

print ("Yes")

Submission status: Accepted

Solution code:
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.insert(0,[0,0,0])#初期値がないと判定ができない。
def check(time,data):#time と　time+1←　添え字 が条件を満たしているかを調べる
    x0=data[time][1]
    y0=data[time][2]
    x1=data[time+1][1]
    y1=data[time+1][2]#たとえ近傍でも偶数、奇数によっては移動不可能な点も存在する。
    if abs(x0-x1)+abs(y0-y1)<=abs(data[time][0]-data[time+1][0]) and (abs(x0-x1)+abs(y0-y1))%2==abs(data[time][0]-data[time+1][0])%2:
        return(1)
    else:
        return(0)
ans=0    
for i in range(0,n):
    ans=ans+check(i,data)
if ans==n:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[[0,0,0] for i in range(n+1)]
for i in range(n):
    lis[i+1]=LI()
for i in range(n):
    dt=lis[i+1][0]-lis[i][0]
    dx=abs(lis[i+1][1]-lis[i][1])
    dy=abs(lis[i+1][2]-lis[i][2])
    if dx+dy<=dt and (dx+dy-dt)%2==0:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

t.sort()
now = 0
ans = "Yes"
past = 0

for i in range(N):
  if t[i][0] - past >= abs(t[i][1] + t[i][2] - now) and abs(t[i][0] - past - abs(t[i][1] + t[i][2] - now))%2 == 0:
    now = t[i][1] + t[i][2]
    past = t[i][0]
  else:
    ans = "No"

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(n):
    t_tmp, x_tmp, y_tmp = map(int, input().split(" "))
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

reachable = True
for j in range(1, n + 1):
    dt = t[j] - t[j - 1]
    dist = abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1])
    if dt < dist or dist % 2 != dt % 2:
        reachable = False

print("Yes" if reachable == True else "No")

Submission status: Accepted

Solution code:
n=int(input())
li=[input() for i in range(n)]
li2 = []
li2.append([0,0,0])
for i in range(n):
    li2.append( [int(x.strip()) for x in li[i].split()])
    
c=0


for i in range(n):
    t = li2[i+1][0] - li2[i][0]
    x = abs(li2[i+1][1] - li2[i][1])
    y = abs(li2[i+1][2] - li2[i][2])
    z = x+y
    if t < z:
        c=1
        break
    if (z - t)%2 == 1:
        c=1
        break
        
        

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

Submission status: Accepted

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

for i in range(n):
    txy.append(list(map(int, input().split())))

for j in range(1,n+1):
    t_diff = txy[j][0] - txy[j-1][0]
    x_diff = txy[j][1] - txy[j-1][1]
    y_diff = txy[j][2] - txy[j-1][2]
    if abs(x_diff) + abs(y_diff) <= t_diff and \
        (t_diff - abs(x_diff) - abs(y_diff))%2 == 0:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

t_pre, x_pre, y_pre = 0, 0, 0
reachable = True
for point in points:
    t, x, y = map(int, point)
    diff_t = t - t_pre
    p = x + y
    p_pre = x_pre + y_pre
    move = 0
    for _ in range(diff_t):
        move += 1 if p > (p_pre + move) else -1

    if p - p_pre != move:
        reachable = False
        break

    t_pre, x_pre, y_pre = t, x, y

print("Yes" if reachable == True else "No")

Submission status: Accepted

Solution code:
N = int(input())
start = [0, 0]
start_t = 0
for i in range(N):
    t, x, y = map(int, input().split())
    now = [x, y]
    dt = t - start_t
    dist = abs(now[0]-start[0]) + abs(now[1]-start[1])
    if dist > dt or dt % 2 != dist % 2:
        print('No')
        break
    else:
        start = now
        start_t = t
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
x = 0
y = 0
t = 0
ans = 0
for i in range(N):
    tt,xx,yy = map(int,input().split())
    t1 = tt -t 
    x1 = abs(xx-x)
    y1 = abs(yy-y)
    if x1 + y1 > t1:
        ans = 1
        #break
    elif (t1 - (x1 + y1) ) % 2 == 1:
        ans = 1
        #break
    t = tt
    x = xx
    y = yy
if ans == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
t = [0]
x = []
y = []
for _ in [0]*n:
    _t, _x, _y = map(int, input().split())
    t += [_t]
    x += [_x]
    y += [_y]
nx = ny = 0
for i in range(n):
    nt = t[i+1] - t[i]
    d = abs(x[i]-nx) + abs(y[i]-ny)
    if not (nt%2 == d%2 and nt>=d):
        print('No')
        break
    nx = x[i]
    ny = y[i]
else:
    print('Yes')

Submission status: Accepted

Solution code:
N  = int(input())
t = [0]*110000
x= [0]*110000
y= [0]*110000

for n in range(N):
        t[n+1],x[n+1],y[n+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: #dt が大きければたどり着ける
        can = False
    if (dist % 2 != dt % 2):#動いていなければ偶数奇数がずれる
        can = False

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

Submission status: Accepted

Solution code:
N = int(input())
li = []
pre_t = 0
pre_x = 0
pre_y = 0
ans = "Yes"
for _ in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x - pre_x) + abs(y - pre_y)
    d_t = abs(t - pre_t)
    if dist > d_t or (dist - d_t) % 2 == 1:
        ans = "No"

    pre_t, pre_x, pre_y = t, x, y

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t_list = [list(map(int,input().split())) 
          for nesya in range(n)]
dame = 0
ti = 0
tx = 0
ty = 0
for t in t_list:
  time = t[0]
  x_t = t[1]
  y_t = t[2]
  d = abs(y_t-ty)+abs(x_t-tx)
  h = time - ti
  if d > h or (h-d)%2 == 1:
    dame += 1
    print('No')
    break
  ti = time
  tx = x_t
  ty = y_t
if dame == 0:
  print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)
######################################################################################################
def main():
    N=int(input())
    f=True
    p=0
    px=0
    py=0
    A=[[] for a in range(N)]
    for a in range(N):
        A[a]=list(map(int,input().split()))
    A.sort()
    for a in range(N):
        t,x,y=A[a][0],A[a][1],A[a][2]
        d=abs(x-px)+abs(y-py)
        if d>t-p:
            f=False
        elif ((t-p)-d)%2==1:
            f=False
        p=t
        px=x
        py=y
    Yn(f)
main()

Submission status: Accepted

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

n = readInt()
be = [0,0]
b_time = 0
for i in range(n):
	data = readInts()
	delta = abs(be[0]-data[1])+abs(be[1]-data[2])
	time = data[0]-b_time
	if delta<=time and delta%2==time%2:
		be = data[1:]
		b_time = data[0]
	else:
		print("No")
		exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

def check(t, x, y):
    return (t - (abs(x) + abs(y))) >= 0 and (t - (abs(x) + abs(y))) % 2 == 0
t0, x0, y0 = 0, 0, 0
for l in [list(map(int, input().split())) for i in range(n)]:
    if not check(l[0] - t0, l[1] - x0, l[2] - y0):
        print('No')
        exit()
    t0, x0, y0 = l[0], l[1], l[2]
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
t0=0
x0=0
y0=0
for i in range(N):
  t,x,y = map(int, input().split())
  l = abs(x-x0) + abs(y-y0)
  if (l > (t-t0)) or (l%2 != (t-t0)%2):
    print("No")
    break
  else:
    x0 = x
    y0 = y
    t0 = t
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=True
for i in range(n):
    time=t[i+1]-t[i]
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dist>time:
        flag=False
    if dist%2 != time%2:
        flag=False
if flag == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

t0, x0, y0 = map(int, input().split())
if t0 < x0 + y0 or t0 % 2 != (x0 + y0) % 2:
    print("No")
    exit()

for i in range(1, N):
    t1, x1, y1 = map(int, input().split())
    dist_t, dist_x, dist_y = abs(t1-t0), abs(x1-x0), abs(y1-y0)
    # print("dist_t: {}, dist_x: {}, dist_y: {}".format(dist_t, dist_x, dist_y))
    if dist_t < dist_x + dist_y or dist_t % 2 != (dist_x + dist_y) % 2:
        print("No")
        exit()
    t0, x0, y0 = t1, x1, y1
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
ans = "Yes"
t_before = 0
x_before, y_before = 0, 0

for _ in range(N):
    ti, xi, yi = map(int, input().split())
    t_dist = abs(ti - t_before)
    x_dist = abs(xi - x_before)
    y_dist = abs(yi - y_before)
    xy_dist = x_dist + y_dist
    if xy_dist <= t_dist:
        if (t_dist % 2 == 0 and xy_dist % 2 == 0) or (t_dist % 2 == 1 and xy_dist % 2 == 1):
            t_before = ti
            x_before = xi
            y_before = yi
            continue
        else:
            ans = "No"
            break
    else:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
records = [tuple(map(int, input().split(' '))) for _ in range(N)]

pre_t = 0
pre_x = 0
pre_y = 0

for t, x, y in records:
    turn = t - pre_t
    dx = abs(x - pre_x)
    dy = abs(y - pre_y)

    if turn < (dx + dy):
        print('No')
        break

    if turn % 2 != (dx + dy) % 2:
        print('No')
        break

    pre_t = t
    pre_x = x
    pre_y = y
else:
    print('Yes')

Submission status: Accepted

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

if n==1:
    dt=m[0][0]
    dx=m[0][1]
    dy=m[0][2]
    if dt<dx+dy:
        print("No")
    else:
        if dt%2!=(dx+dy)%2:
            print("No")
        print("Yes")

else:
    for i in range(n-1):
        dt=m[i+1][0]-m[i][0]
        dx=abs(m[i+1][1]-m[i][1])
        dy=abs(m[i+1][2]-m[i][2])

        if dt<dx+dy:
            print("No")
            exit()
        else:
            if dt%2!=(dx+dy)%2:
                print("No")
                exit()

    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
T = [0]*110000
X = [0]*110000
Y = [0]*110000
for n in range(N):
    T[n+1], X[n+1], Y[n+1] = map(int, input().split())
res = True
for n in range(N):
    dt = T[n+1] - T[n]
    dist = abs(X[n+1] - X[n]) + abs(Y[n+1] - Y[n])
    if dt < dist:
        res = False
    if dt % 2 != dist % 2:
        res = False
if res:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

c_x = 0
c_y = 0
c_t = 0
for i in range(n):
  t, x, y = map(int, input().split())
  d_x = abs(c_x - x)
  d_y = abs(c_y - y)
  d = d_x + d_y
  d_t = t - c_t
  if d_t < d or (d_t - d) % 2 != 0:
    print('No')
    sys.exit(0)
  c_x = x
  c_y = y
  c_t = t
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T, X, Y = 0, 0, 0

can_reach = True
for i in range(N):
  next_T, next_X, next_Y = map(int, input().split())
  
  z = next_T - T - abs(X - next_X) - abs(Y - next_Y)
  if z >= 0 and z % 2 == 0:
    T, X, Y = next_T, next_X, next_Y
  else:
    can_reach = False
    break
    
if can_reach:
  print('Yes')
else:
  print('No')