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, x, y = 0, 0, 0
for _ in range(N):
	_t, _x, _y = map(int, input().split())
	d_xy = abs(x - _x) + abs(y - _y)
	d_t = _t - t
	if d_xy <= d_t and d_xy%2 == d_t%2:
		pass
	else:
		print("No")
		exit()
	t, x, y = _t, _x, _y
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.insert(0,[0,0,0])
a,x,y = zip(*l)

for i in range(n):
  count=a[i+1]-a[i]
  x_len=abs(x[i+1]-x[i])
  y_len=abs(y[i+1]-y[i])
  
  if (x_len+y_len)>count:
    print('No')
    exit()
  elif (count-(x_len+y_len))%2!=0:
    print('No')
    exit()
  else:
    continue
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
now_t,now_x,now_y = 0,0,0
for i in range(n):
  t,x,y = map(int,input().split())
  time = t-now_t
  distance = abs(x-now_x)+abs(y-now_y)
  if distance <= time and (time-distance)%2 == 0:
    now_t,now_x,now_y = t,x,y
  else:
    print('No')
    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(1, N + 1):
    t[i], x[i], y[i] = map(int, input().split())

"""
t = [0, 3, 6]
x = [0, 1, 1]
y = [0, 2, 1]
"""

for i in range(N):
    dt = t[i + 1] - t[i]
    dx = abs(x[i + 1] - x[i])
    dy = abs(y[i + 1] - y[i])

    # 移動距離が実現可能か
    if (dx + dy) > dt:
        print("No")
        exit()

    # 目的地に到達した後、残り時間が偶数か
    if (dt - (dx + dy)) % 2 != 0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys


class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y


def can_move(start, end, time):

    d_x = end.x - start.x
    d_y = end.y - start.y
    if abs(d_x) + abs(d_y) > time:
        return False
    elif abs(d_x) + abs(d_y) == time:
        return True
    else:
        if (abs(d_x) + abs(d_y) - time) % 2 == 0:
            return True
        else:
            return False


if __name__ == "__main__":
    N = int(input())
    prev_point = Point(0, 0)
    prev_time = 0
    for _ in range(N):
        t, x, y = [int(x) for x in input().split(" ")]
        if not can_move(prev_point, Point(x, y), t - prev_time):
            print("No")
            sys.exit(0)
        else:
            prev_time = t
            prev_point = Point(x, y)
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

nx = 0
ny = 0
nt = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    k = abs(nx-x)+abs(ny-y)
    if k > t-nt:
        print("No")
        break
    if (k-(t-nt))%2 != 0:
        print("No")
        break
    nx = x
    ny = y
    nt = t
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    nowt, nowx, nowy = (0, 0, 0)
    is_ok = True
    for _ in range(n):
        t,x,y = map(int,input().split())
        if is_ok:
            dt = t - nowt
            d = abs(x-nowx) + abs(y-nowy)
            nowx, nowy, nowt = x, y, t
            if dt < d:
                is_ok = False
            elif (dt - d) % 2 != 0:
                is_ok = False
    if is_ok:
        print("Yes")
    else:
        print("No")
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

Z = [list(map(int,input().split())) for a in range(N)]


def solve():
    former = [0,0,0]
    for a in Z:
        distance = abs(a[1]-former[1])+abs(a[2]-former[2])
        if distance > a[0] - former[0]:
            print("No")
            return
        if (a[0]-former[0]) % 2 != distance % 2:
            print("No")
            return
        former = a
    print("Yes")

solve()

Submission status: Accepted

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

x,y=0,0
t=0
flag=True

for i in range(n):
    if abs(l[i][1]-x)+abs(l[i][2]-y)<=(l[i][0]-t) and ((l[i][0]-t)-abs(l[i][1]-x)+abs(l[i][2]-y))%2==0:
        x=l[i][1]
        y=l[i][2]
        t=l[i][0]
    else:
        flag=False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

tx = 0
ty = 0
tt = 0

for i in range(n):
    dx = abs(ab[i][1] - tx)
    dy = abs(ab[i][2] - ty)
    dt = ab[i][0] -tt
    dd = dt- (dx+dy)
    if dd % 2 ==0 and dd>=0:
        tx = ab[i][1]
        ty = ab[i][2]
        tt = ab[i][0]

    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t,x,y = 0,0,0
for i in range(n):
  nt, nx, ny  = map(int, input().split())
  if not(abs(nx-x)+abs(ny-y) <= nt-t and t%2 == (x+y)%2):
    print("No")
    exit()
  t,x,y = nt,nx,ny
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
t,x,y = 0,0,0
for i in range(n):
  nt, nx, ny  = map(int, input().split())
  if abs(nx-x)+abs(ny-y) <= nt-t and t%2 == (x+y)%2:
    cnt += 1
  t,x,y = nt,nx,ny
print("Yes" if cnt == n else "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])

flag = 0

for n in range(1,N+1):
  if txy[n][0] % 2 != (txy[n][1] + txy[n][2])%2 or \
  abs(txy[n][0] - txy[n-1][0]) < abs(txy[n][1] - txy[n-1][1]) + abs(txy[n][2] - txy[n-1][2]):
    flag = 1
    break

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

Submission status: Accepted

Solution code:
N = int(input())
ans = True
t1,x1,y1 = 0,0,0
for i in range(N):
    t2,x2,y2 = map(int, input().split())
    if t2-t1 >= abs(x2-x1)+abs(y2-y1) and ((t2-t1)-(abs(x2-x1)+abs(y2-y1)))%2 == 0:
        None
    else:
        ans = False
        break
    t1,x1,y1 = t2,x2,y2
    #print(i)
print("Yes" if ans==True else "No")

Submission status: Accepted

Solution code:
N = int(input())
x = [list(map(int,input().split())) for i in range(N)]
x[0:0] =[[0,0,0]]
can = True
for i in range(N):
    max_dis = x[i+1][0]-x[i][0]
    dis = abs(x[i+1][1]-x[i][1])+abs(x[i+1][2]-x[i][2])
    if(dis>max_dis or dis%2 != max_dis%2):
        can = False
        break
print("Yes" if can == True else "No")

Submission status: Accepted

Solution code:
n=int(input())
sx,sy=0,0
f=True
t1=0
for i in range(n):
    t2,gx,gy=map(int,input().split())
    a=abs(sx-gx)+abs(sy-gy)
    t=t2-t1
    if a>t:
        f=False
    elif (a-t)%2==1:
        f=False
    sx,sy=gx,gy
    t1=t2
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
# 初期位置
x_old, y_old, t_old = 0, 0, 0

for _ in range(n):
    # 都度読み込み
    t, x, y = map(int, input().split())
    d = (t - t_old) - abs(x - x_old) - abs(y - y_old)
    if d >= 0 and d % 2 == 0:
        x_old, y_old, t_old = x, y, t
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t_pre = 0
x_pre = 0
y_pre = 0
ans = "Yes"

for _ in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - x_pre) + abs(y - y_pre)
    t_interval = t - t_pre
    if d <= t_interval and (t_interval - d) % 2 == 0:
        t_pre = t
        x_pre = x
        y_pre = y
    else:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
import copy
n = int(input())
X = 0
Y = 0
T = 0
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())

    res = t - (T + abs(x -X) + abs(y - Y))
    if res >= 0 and res % 2 == 0:
        ans = 'Yes'
    else:
        ans = 'No'
        break
    X = copy.copy(x)
    Y = copy.copy(y)
    T = copy.copy(t)
print(ans)

Submission status: Accepted

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

now_t=0
now_x=0
now_y=0

for nt,nx,ny in l:
  d_dist=abs(nx-now_x)+abs(ny-now_y)
  d_t=nt-now_t
  if d_dist>d_t or (d_t-d_dist)%2==1:
    print('No')
    exit()
  now_t=nt
  now_x=nx
  now_y=ny

print('Yes')

Submission status: Accepted

Solution code:
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# ac_py.main.py
# Date: 2020/06/08
# Filename: main.py 

__author__ = 'acto_mini'
__date__ = "2020/06/08"


def main():
    n = int(input())
    t_prev = 0
    x_prev = 0
    y_prev = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        dt = t - t_prev
        dist = abs(x - x_prev) + abs(y - y_prev)
        if dt < dist or ((dt % 2) != (dist % 2)):
            print("No")
            exit()
        t_prev, x_prev, y_prev = t, x, y

    print("Yes")
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

x_now, y_now, t_now = 0, 0, 0

for i in range(n):
    t, x, y = map(int, input().split())
    distance = (t -t_now) - abs(x-x_now) - abs(y-y_now)
    if distance >= 0 and distance % 2 == 0:
        x_now,y_now,t_now = x,y,t
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

def enable_move(old_pos, new_pos):
    old_t, old_x, old_y = old_pos
    new_t, new_x, new_y = new_pos
    t = new_t - old_t
    d = abs(new_x - old_x) + abs(new_y - old_y)
    if t < d:
        return False
    return ((t - d) % 2 == 0)

ans = "Yes"
old_pos = [0, 0, 0]
for _ in range(n):
    new_pos = [int(s) for s in input().split()]
    if not enable_move(old_pos, new_pos):
        ans = "No"
        break
    old_pos = new_pos
print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


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


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
prev_t = 0
prev_x = 0
prev_y = 0
for i in range(N):
    t, x, y = LI()
    if abs(prev_x-x) + abs(prev_y-y) > (t - prev_t) or (abs(prev_x-x) + abs(prev_y-y) + (t - prev_t)) % 2:
        print('No')
        exit()
    prev_t = t
    prev_x = x
    prev_y = y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

ts,xs,ys = 0,0,0

for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x-xs) + abs(y-ys) > t-ts:
        print("No")
        break
    else:
        if (x-xs + y-ys - t-ts) % 2 != 0:
            print("No")
            break
        else:
            ts,xs,ys = t,x,y
    
if ts == t:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

hoge = int(input())
cite = [list(map(int, input().split())) for i in range(hoge)]
cite.insert(0, [0, 0, 0])

for j in range(1, hoge+1):
    x_dif = abs(cite[j][1]-cite[j-1][1])
    y_dif = abs(cite[j][2]-cite[j-1][2])
    t_dif = cite[j][0] - cite[j-1][0]
    
    if x_dif + y_dif > t_dif or (x_dif + y_dif) % 2 != t_dif % 2:
        print("No")
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    t = [[0,0,0]]
    for _ in range(n):
        t.append(list(map(int,input().split())))
    for i in range(n):
        time = t[i+1][0] - t[i][0]
        distance = abs(t[i+1][1] - t[i][1]) + abs(t[i+1][2] - t[i][2])
        if time < distance or (time-distance) % 2 == 1:
            print('No')
            return
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
 
x0, y0, t0 = 0, 0, 0
 
for _ in range(n):
  t, x, y = map(int, input().split())
  if abs(x-x0) + abs(y-y0) > t-t0 or (x+y)%2 != t%2:
    status = "No"
    break
  else:
    status = "Yes"
    t0, x0, y0 = t, x, y
    
print(status)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
currentTime = 0
current = [0, 0]
for i in range(N):
    timeStamp = list(map(int, input().split()))
    reqLen = abs(timeStamp[1] - current[0]) + abs(timeStamp[2] - current[1])
    timeLen = timeStamp[0] - currentTime
    if reqLen > timeLen:
        print("No")
        exit()
    if reqLen % 2 != timeLen % 2:
        print("No")
        exit()
    currentTime = timeStamp[0]
    current = timeStamp[1:]
print("Yes")

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

ct, cx, cy = (0, 0, 0)

ok = True
for i in range(N):
    t, x, y = map(int, input().split())

    d = abs(cx - x) + abs(cy - y)
    dt = t - ct

    if d > dt or (d - dt) % 2 == 1:
        ok = False
    ct, cx, cy = t, x, y

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

Submission status: Accepted

Solution code:
N=int(input())
pre_t,pre_x,pre_y=0,0,0
reachable=True
for _ in range(N):
  t,x,y=map(int,input().split())
  dist=abs(x-pre_x)+abs(y-pre_y)
  time=t-pre_t
  if dist<=time:
    if dist%2==time%2:
      pre_t,pre_x,pre_y=t,x,y
    else:
      reachable=False
      break
  else:
    reachable=False
    break
  pass
if reachable:print('Yes')
else: print('No')

Submission status: Accepted

Solution code:
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
can = True

for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - prev_t
    dist = abs(x - prev_x) + abs(y - prev_y)
    if dt < dist or dist % 2 != dt % 2:
        can = False
    prev_t = t
    prev_x = x
    prev_y = y

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

Submission status: Accepted

Solution code:
N = int(input())
plan = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]
f = True
for i in range(N):
    time = plan[i+1][0]-plan[i][0]
    dist = abs(plan[i+1][1]-plan[i][1])+abs(plan[i+1][2]-plan[i][2])
    if dist>time or dist%2 != time%2:
        f = False    
print('Yes' if f else 'No')

Submission status: Accepted

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

s = 0
t = 0
d = 0
p = [0, 0]
ans = ''
for e in l:
  if ans == '':
    s = e[0] - t
    t = e[0]
    d = abs(p[0] - e[1]) + abs(p[1] - e[2])
    p = [e[1], e[2]]
    if s < d:
      ans = 'No'
    else:
      if (s - d) % 2 == 1:
        ans = 'No'
      else:
        next
if ans == '':
  ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
txy = [list(map(int, readline().split())) for _ in range(n)]

t = txy[0][0]
d = abs(txy[0][1]) + abs(txy[0][2])

if t < d:
    print('No')
    exit()
for i in range(n-1):
    t = 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 t < d:
        print('No')
        exit()
    if t % 2 == 0 and d % 2 != 0:
        print('No')
        exit()
    if t % 2 != 0 and d % 2 == 0:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
st = 0
sx = 0
sy = 0
flg = False
for _ in range(N):
    t,x,y = map(int,input().split())

    if abs((x+y)-(sx+sy)) > (t-st) or (t-st) % 2 != abs((x+y)-(sx+sy)) % 2:
        flg = True
        break
    else:
        st = t
        sx = x
        sy = y
print('No' if flg else 'Yes')

Submission status: Accepted

Solution code:
n = int(input())
st = 0
sx, sy = 0, 0
ng = False
for _ in range(n):
    t, x, y = map(int, input().split())
    dt = (t - st)
    dx = abs(sx - x)
    dy = abs(sy - y)

    if dt%2 == (dx+dy)%2 and dx+dy <= dt:
        st = t
        sx = x
        sy = y
    else:
        ng = True
        break
print('No' if ng else 'Yes')

Submission status: Accepted

Solution code:
n = int(input())
t0 = 0
x0 = 0
y0 = 0
flag = True

for _ in range(n):
    t, x, y = map(int, input().split())
    t -= t0
    x -= x0
    y -= y0
    diff = abs(x) + abs(y)
    t0 = t
    x0 = x
    y0 = y
    if diff > t:
        flag = False
        break
    if t % 2:
        if diff % 2:
            pass
        else:
            flag = False
            break
    else:
        if diff % 2:
            flag = False
            break
        else:
            pass
print('Yes') if flag else print('No')

Submission status: Accepted

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

ans='Yes'
now=[0,0,0]
for t,x,y in txy:
    distance=abs(x-now[1])+abs(y-now[2])
    if distance>t-now[0] or (distance+(t-now[0]))%2>0:
        ans='No'
        break
    else:
        now=[t,x,y]

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=[[0,0,0]]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
for i in range(1,n+1):
    b=abs(A[i-1][1]+A[i-1][2]-A[i][1]-A[i][2])
    if b>A[i][0]-A[i-1][0] or (b+A[i][0]-A[i-1][0])%2==1:
        print("No")
        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())
x = [list(map(int, input().split())) for i in range(N)]
cnt = 0
sum = 0
flag = 0
for i in range(N):
    if i == 0:
        cnt = x[i][0]
        sum = x[i][1] + x[i][2]
    else:
        cnt = x[i][0] - x[i-1][0]
        sum = abs(x[i][1]-x[i-1][1]) + abs(x[i][2]-x[i-1][2])
    if cnt < sum or cnt % 2 != sum % 2:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
lt = 0
lx = 0
ly = 0
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    dt = abs(lt-t)
    dx = abs(lx-x)
    dy = abs(ly-y)
    if not(dt >= dx + dy and dt % 2 == (dx + dy) % 2):
        print("No")
        exit()
    lt = t
    lx = x
    ly = y
print("Yes")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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())


for i in range(1, N+1):
    if abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) > (t[i] - t[i-1]) or (((t[i] -x[i] -y[i]) % 2) != 0):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
a = [[0, 0, 0]] + [[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    d = a[i + 1][0] - a[i][0]
    x = abs(a[i + 1][1] - a[i][1])
    y = abs(a[i + 1][2] - a[i][2])
    if x + y > d:
        print("No")
        break
    elif (d - (x + y)) % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
l = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    t1, x1, y1 = l[i]
    t2, x2, y2 = l[i + 1]
    if (abs(x1 - x2) + abs(y1 - y2)) % 2 != (t2 - t1) % 2 or t2 - t1 < abs(x1 - x2) + abs(y1 - y2):
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
__DEUBG__ = 0

import math

N = int(input())
t_prev = x_prev = y_prev = 0

def get_dist(x_old, y_old, x_new, y_new):
    return abs(x_old - x_new) + abs(y_old - y_new)

for _ in range(N):
    t, x, y = map(int, input().split())
    dist = get_dist(x_prev, y_prev, x, y)
    delta_t = t - t_prev
    if __DEUBG__:
        print()
        print(dist, delta_t)
    if dist > delta_t:
        print('No')
        exit(0)
    elif delta_t %2 != dist % 2:
        print('No')
        exit(0)
    t_prev, x_prev, y_prev = t, x, y
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
start = [0, 0]
curtime = 0
flag = True
for i in range(n):
    t, x, y = map(int, input().split())
    dist = abs(x-start[0]) + abs(y-start[1])
    time = t-curtime
    if dist <= time and dist % 2 == time % 2:
        start = [x, y]
        curtime = t
        continue
    print('No')
    flag = False
    break
if flag:
    print('Yes')

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline().rstrip())
pos = (0, 0)
used_time = 0
for _ in range(N):
    t, x, y = map(int, readline().split())
    cost = abs(pos[0] - x) + abs(pos[1] - y)
    available = t - used_time
    # print("cost: {}".format(cost))
    # print("available: {}".format(available))
    if cost > available or ((cost - available) % 2 != 0):
        print('No')
        quit()
    used_time = t
    pos = (x, y)
print('Yes')

Submission status: Accepted

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

# 初期値
t = x = y = 0
# 判定フラグ
flag = 0
for l in coord:
    dt, dx, dy = abs(l[0] - t), abs(l[1] - x), abs(l[2] - y)
    # dtが以前のdx, dyの合計値よりも小さいならば不可
    if dt < dx + dy:
        flag = 1
        break
    else:
        # dtの偶奇とdx, dyの和の偶奇は等しくなるはず
        # 等しくない場合
        if dt % 2 != (dx + dy) % 2:
            flag = 1
            break
        else:
            t, x, y = l[0], l[1], l[2]
            continue

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

Submission status: Accepted

Solution code:
import sys
import math


def main():
    t = 0
    pos = 0, 0

    N = int(input())
    for i in range(N):
        ti, xi, yi = [int(v) for v in input().split()]

        dx = xi - pos[0]
        dy = yi - pos[1]

        td = ti - t
        dd = abs(dx + dy)

        if dd > td:
            print("No")
            sys.exit()

        if td % 2 != dd % 2:
            print("No")
            sys.exit()

        t = ti
        pos = xi, yi

    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

# 時間、位置をt(i-1)に対する相対的な値に変換する
for i in range(1, N):
    L[i] = [L[i][0]-L[i-1][0], L[i][1]-L[i-1][1], L[i][2]-L[i-1][2]]


def judge(t, x, y):
    distance = abs(x) + abs(y)
    global answer
    if distance > t:
        answer = 'No'
        return
    else:
        if t % 2 == distance % 2:
            return
        else:
            answer = 'No'
            return


for l in L:
    judge(l[0], l[1], l[2])
    if answer == 'No':
        break

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
nowt = 0
nowx = 0
nowy = 0
for i in range(N):
  t, x, y = map(int, input().split())
  ti = t - nowt
  xi = x - nowx
  yi = y - nowy
  if ti < abs(xi) + abs(yi):
    print('No')
    exit()
  if ti%2 != (xi+yi)%2:
    print('No')
    exit()
  nowt = t
  nowx = x
  nowy = y
    
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
t0=0
x0=0
y0=0
def num_abs(num):
    return abs(num)
ans=0
for i in range(n):
    t,x,y=map(int,input().split())
    numx=num_abs(x-x0)
    numy=num_abs(y-y0)
    numt=t-t0
    if numx+numy>numt or (numt-(numx+numy))%2==1:
        ans=1
        break
    t0=t
    x0=x
    y0=y
if ans==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    txy = [list(map(int, input().split())) for _ in range(n)]
    
    pre_x, pre_y, pre_t = 0, 0, 0
    for t, x, y in txy:
        d = abs(pre_x - x) + abs(pre_y - y)
        if not(t - pre_t >= d and (t - pre_t) % 2 == d % 2):
            print('No')
            break
        pre_x,  pre_y, pre_t = x, y, t
    else:
        print('Yes')
        
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    txy = [list(map(int, input().split())) for _ in range(n)]
    
    pre_x, pre_y, pre_t = 0, 0, 0
    for t, x, y in txy:
        d = abs(pre_x - x) + abs(pre_y - y)
        if t - pre_t >= d and (t - pre_t) % 2 == d % 2:
            pre_x,  pre_y, pre_t = x, y, t
        else:
            print('No')
            break
        pre_x,  pre_y, pre_t = x, y, t
    else:
        print('Yes')
        
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
now = 0
nowx = 0
nowy = 0
for i in range(N):
    t,x,y = map(int,input().split())
    d = (abs(x-nowx)+abs(y-nowy))
    if d > t-now:
        print('No')
        exit()
    if (t-now)%2 == 0:
        if d%2 == 0:
            now = t
            nowx = x
            nowy = y
        else:
            print('No')
            exit()
    else:
        if d%2 == 1:
            now = t
            nowx = x
            nowy = y
        else:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
x=0
y=0
t=0
for i in range(N):
    tt,xx,yy=map(int,input().split())
    if abs(xx-x)+abs(yy-y)<=tt-t:
        if (abs(xx-x)+abs(yy-y))%2!=(tt-t)%2:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t,x,y=tt,xx,yy
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
timeNum = int(input())

placeSequence = list()
for pivot in range(timeNum):
  placeSequence.append(list(map(int, input().split(' '))))

def compatibleCoordinate(time, x, y):
  if time % 2 == (abs(x) +  abs(y)) % 2 and time >= abs(x) + abs(y):
    return True
  else:
    return False

time = x = y = 0

for place in placeSequence:
  objectTime, objectX, objectY = place
  flag = compatibleCoordinate(objectTime-time, objectX-x, objectY-y)
  if flag:
    time = objectTime
    x = objectX
    y = objectY
    continue
  else:
    print('No')
    break

else:
  print('Yes')

Submission status: Accepted

Solution code:

n = int(input())
travel = [[0, 0, 0]]

for i in range(n):
    array = list(map(int, input().strip().split()))
    travel.append(array)


def func(num, query):
    for j in range(num):
        time_temp = query[j+1][0] - query[j][0]
        x_temp = abs(query[j+1][1] - query[j][1])
        y_temp = abs(query[j+1][2] - query[j][2])

        if not (x_temp + y_temp) % 2 == time_temp % 2:
            print('No')
            return
        if x_temp + y_temp > time_temp:
            print('No')
            return

    print('Yes')


func(num=n, query=travel)

Submission status: Accepted

Solution code:
n = int(input())
s = [0, 0, 0]
ans = 'Yes'
for i in range(n):
  l = list(map(int, input().split()))
  diff_t = l[0] - s[0]
  diff_x = abs(s[1] - l[1])
  diff_y = abs(s[2] - l[2])
  s = [l[0], l[1], l[2]]
  if diff_x + diff_y > diff_t or (diff_t - diff_x - diff_y) % 2 != 0:
    ans = 'No'
print(ans)

Submission status: Accepted

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

tp = xp = yp = 0
for t, x, y in txy:
  ti = t - tp
  d = abs(x - xp) + abs(y - yp)
  tp = t
  xp = x
  yp = y
  if ti < d:
    print('No')
    exit()
  else:
    if ti % 2 != d % 2:
      print('No')
      exit()
    else:
      continue
    
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

# タプル(時刻, x, y)のリストを生成する
data_list = [(0, 0, 0)]
for _ in range(n):
  temp = list(map(int, input().strip().split()))
  data_list.append((temp[0], temp[1], temp[2]))

# リストの行間において、移動が可能かを判定し、できなければそこで終了する
for i in range(n):
  time_diff = data_list[i + 1][0] - data_list[i][0]
  x_diff = abs(data_list[i + 1][1] - data_list[i][1])
  y_diff = abs(data_list[i + 1][2] - data_list[i][2])
  
  if ((x_diff + y_diff) % 2) != (time_diff % 2):
    print('No')
    exit()
  if x_diff + y_diff > time_diff:
    print('No')
    exit()

print('Yes')