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:
def solve():
    N = int(input())
    t_p = 0
    x_p = 0
    y_p = 0
    for i in range(1, N+1):
        t, x, y = map(int, input().split())
        #　時間的に可能かどうか。
        if (t - t_p) < abs(x - x_p) + abs(y - y_p):
            print('No')
            exit()
        # 空間的に可能かどうか。奇数秒後はx+yが奇数に、偶数秒後はx+yが偶数にならないといけない。
        if (t%2==0 and (x+y)%2==1) or (t%2==1 and (x+y)%2==0):
            print('No')
            exit()
        t_p, x_p, y_p = t, x, y
    print('Yes')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    t_p = 0
    x_p = 0
    y_p = 0
    for i in range(1, N+1):
        t, x, y = map(int, input().split())
        # 空間的に可能かどうか。奇数秒後はx+yが奇数に、偶数秒後はx+yが偶数にならないといけない。
        if (t%2==0 and (x+y)%2==1) or (t%2==1 and (x+y)%2==0):
            print('No')
            exit()
        #　時間的に可能かどうか。
        if (t - t_p) < abs(x - x_p) + abs(y - y_p):
            print('No')
            exit()
        t_p, x_p, y_p = t, x, y
    print('Yes')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    t = [0] * (N+1)
    x = [0] * (N+1)
    y = [0] * (N+1)
    t[0] = 0
    x[0] = 0
    y[0] = 0
    for i in range(1, N+1):
        t[i], x[i], y[i] = map(int, input().split())
        # 空間的に可能かどうか。奇数秒後はx+yが奇数に、偶数秒後はx+yが偶数にならないといけない。
        if (t[i]%2==0 and (x[i]+y[i])%2==1) or (t[i]%2==1 and (x[i]+y[i])%2==0):
            print('No')
            exit()
        #　時間的に可能かどうか。
        if (t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

    for i in range(1,N+1):
        # 空間的に可能かどうか。奇数秒後はx+yが奇数に、偶数秒後はx+yが偶数にならないといけない。
        if (t[i]%2==0 and (x[i]+y[i])%2==1) or (t[i]%2==1 and (x[i]+y[i])%2==0):
            print('No')
            exit()
        #　時間的に可能かどうか。
        if (t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())
flag = True
dx, dy, dt = 0, 0, 0

for _ in range(n):
    t, x, y = map(int, input().split())
    dist = abs(dx - x) + abs(dy - y)
    if t - dt < dist or (t - dt - dist) % 2:
        flag = False
    dt, dx, dy = t, x, y

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

Submission status: Accepted

Solution code:
N = int(input())

p = [[ 0 for i in range(3)] for j in range(N+1)]

for i in range(1,N+1):
    p[i][0], p[i][1], p[i][2] = map(int,input().split())

cant = True

if p[1][0] % 2 == (p[1][1] + p[1][2]) % 2 and p[1][0] >= p[1][1] + p[1][2]:
    cant = False

if cant:
    print('No')
    exit()

if N > 1:
    for i in range(1, N+1):
        ts = p[i][0] - p[i-1][0]
        ps = p[i][1] - p[i-1][1] + p[i][2] - p[i-1][2]
        if ts%2 == ps%2 and ts*ts >= ps*ps:
            cant = False
        else:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
answer = ""
for i in range(N):
    t, x, y = map(int,input().split())
    if i == 0:
        if t == (abs(x) + abs(y)):
            answer = "Yes"
            pre_x = x
            pre_y = y
            pre_t = t
        else:
            answer = "No"
            break
    
    else:
        if (t - pre_t) >= (abs(x - pre_x) + abs(y - pre_y)) and (t - pre_t) % 2 == (abs(x - pre_x) + abs(y - pre_y)) % 2:
            answer = "Yes"
            pre_x = x
            pre_y = y
            pre_t = t
        else:
            answer = "No"
            break

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

for num in range(n):
    dif_t = t[num+1] - t[num]
    dif_x = abs(x[num+1] - x[num])
    dif_y = abs(y[num+1] - y[num])
    i = dif_t - (dif_x + dif_y)
    if i%2 == 1 or i <= -1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

t = 0
x = 0
y = 0

for i in range(0,N):
    mt = abs(list[i][0] - t)
    mx = abs(list[i][1] - x)
    my = abs(list[i][2] - y)
    if (mx + my == mt) or ( (mx+my<mt) & ((mt - mx - my)%2 == 0)):
        t = list[i][0]
        x = list[i][1]
        y = list[i][2]
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
cs = []
t1, x1, y1 = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  d = abs(x1-x2) + abs(y1-y2)
  if d == 0 or d > (t2 - t1) or d % 2 != (t2 - t1) % 2:
    ans = 'No'
    break
  t1, x1, y1 = t2, x2, y2
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
t1 = 0
x1 = 0
y1 = 0
for i in range(N):
  t2,x2,y2=map(int,input().split())
  d = abs(x1 - x2) + abs(y1 - y2)
  dt = t2 - t1
  if d > dt:
    print('No')
    exit()
  if dt%2!=0 and d%2==0:
    print('No')
    exit()
  if dt%2==0 and d%2!=0:
    print('No')
    exit()
  t1,x1,y1=t2,x2,y2
print('Yes')

Submission status: Accepted

Solution code:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = [0]
x = [0]
y = [0]
for _ in range(n):
    tmp = LI()
    t.append(tmp.pop(0))
    x.append(tmp.pop(0))
    y.append(tmp.pop(0))

for i in range(1,n+1):
    dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    dt = abs(t[i]-t[i-1])
    if dt<dist:
        print('No')
        exit()
    else:
        if (dt-dist)%2:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = [0]
x = [0]
y = [0]
for _ in range(n):
    tmp = LI()
    t.append(tmp.pop(0))
    x.append(tmp.pop(0))
    y.append(tmp.pop(0))

for i in range(1,n+1):
    dx = abs(x[i]-x[i-1])
    dy = abs(y[i]-y[i-1])
    dt = abs(t[i]-t[i-1])
    if dt<dx+dy:
        print('No')
        exit()
    else:
        tmp = dt-dx-dy
        if tmp%2:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__  == "__main__":
    n = int(input())
    nowX = 0
    nowY = 0
    nowT = 0
    for i in range(n):
        t,x,y = map(int,input().split())
        dt = t - nowT
        dx = abs(x - nowX)
        dy = abs(y - nowY)
        if dt%2 == 1:
            if (dx + dy)%2 == 1 and (dx + dy)<=dt:
                flag = 1
            else:
                print("No")
                sys.exit()
        else:
            if (dx + dy)%2 == 0 and (dx + dy)<=dt:
                flag = 1
            else:
                print("No")
                sys.exit()
        nowT = t
        nowX = x
        nowY = y
    print("Yes")

Submission status: Accepted

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

tmp = [0, 0, 0]
for t, x, y in txy:
    tmp1 = t - tmp[0]
    tmp2 = abs(x - tmp[1]) + abs(y - tmp[2])
    if tmp1 >= tmp2 and (tmp1 + tmp2) % 2 == 0:
        tmp = [t, x, y]
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

t = []
cordinate = []

#　リストtに時間の情報、二次元配列のcordinateにx,y座標を入れる
for i in range(N):
    time,x,y = map(int, input().split())
    t.append(time)
    cordinate.append([x,y])

# 初期の時間と初期座標
time = 0
x,y = 0,0


for i in range(len(t)):
    
    # 移動先への移動にかけて良い時間
    time = abs(time - t[i])
    
    #移動先のx,y座標
    objx = cordinate[i][0]
    objy = cordinate[i][1]
    

    
    #移動できる時間より距離が長い場合はアウト
    if time < abs((objx - x) + (objy - y)):
        print("No")
        sys.exit()
    
    #偶奇の判定
    if (abs((objx - x) + (objy - y)))%2 != time % 2:
        print("No")
        sys.exit()

    x,y = objx,objy
    time = t[i]

print("Yes")

Submission status: Accepted

Solution code:
import sys 
N = int(input())
 
t = []
cordinate = []
 
#　リストtに時間の情報、二次元配列のcordinateにx,y座標を入れる
for i in range(N):
    time,x,y = map(int, input().split())
    t.append(time)
    cordinate.append([x,y])
 
# 初期の時間と初期座標
time = 0
x,y = 0,0
 
 
for i in range(len(t)):
    
    # 移動先への移動にかけて良い時間
    time = abs(time - t[i])
    
    #移動先のx,y座標
    objx = cordinate[i][0]
    objy = cordinate[i][1]
    
 
    
    #移動できる時間より距離が長い場合はアウト
    if time < abs((objx - x) + (objy - y)):
        print("No")
        sys.exit()
    
    #偶奇の判定
    if (abs((objx - x) + (objy - y)))%2 != time % 2:
        print("No")
        sys.exit()
 
    x,y = objx,objy
    time = t[i]
 
print("Yes")

Submission status: Accepted

Solution code:
N, *T = map(int, open(0).read().split())
d_t, d_x, d_y = 0, 0, 0
for t, x, y in zip(T[::3], T[1::3], T[2::3]):
    dist = abs(d_x - x) + abs(d_y - y)
    if t - d_t - dist < 0 or (t - d_t - dist) % 2:
        print("No")
        break
    d_t, d_x, d_y = t, x, y
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    lis = []
    lis.append((0, 0, 0))
    for _ in range(N):
        t, x, y = map(int, input().split())
        lis.append((t, x, y))
    ans = "Yes"
    for i in range(1, N+1):
        t_diff = lis[i][0] - lis[i-1][0]
        d_diff = abs(lis[i][1] - lis[i-1][1]) + abs(lis[i][2] - lis[i-1][2])
        if t_diff % 2 != d_diff % 2 or t_diff < d_diff:
            ans = "No"
            break
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans="Yes"
for i in range(N):
  t_now=tra[i][0]
  x_now=tra[i][1]
  y_now=tra[i][2]
  
  t_next=tra[i+1][0]
  x_next=tra[i+1][1]
  y_next=tra[i+1][2]
  
  mind=abs(x_now-x_next)+abs(y_now-y_next)
  tdis=t_next-t_now
  
  # 遠すぎて移動できないときと、時間差と距離の偶奇が不一致の時アウト
  if mind>tdis or (mind+tdis)%2==1:
    ans="No"
    break

print(ans)

Submission status: Accepted

Solution code:
N = int(input().strip())
route = [tuple(map(int, input().strip().split(" "))) for i in range(N)]

start = (0, 0, 0)
goal = True

for r in route:
    t = r[0] - start[0]
    d = abs(r[1]-start[1]) + abs(r[2]-start[2])
    if d % 2 == t % 2 and t >= d: # match even/odd and can reach dest in time
        pass
    else:
        goal = False
        break
    start = r

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

Submission status: Accepted

Solution code:
N=int(input())
listA=[[0,0,0]] #最初の位置を置く
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;        
        
def main():
  for i in range(N): #i番目の場所とi+1番目の場所を順次比較していく
    # マンハッタン距離　別名:City block distance  
    # 京都のような碁盤目状の地域の移動にかかる距離
    Manhattan_distance=abs(listA[i+1][1]-listA[i][1])+abs(listA[i+1][2]-listA[i][2])
    
    # 偶奇での不可と可能
    if listA[i+1][0]%2!=(listA[i+1][1]+listA[i+1][2])%2:
      return "No"
    
    #時間差%2 != マンハッタン距離　
    #奇数時間と偶数時間で到達可能区域が異なる
    if (listA[i+1][0]-listA[i][0])%2!=Manhattan_distance%2: 
      return "No"
    
    # 距離的制約
    if (listA[i+1][0]-listA[i][0])<Manhattan_distance:
      return "No"
  
  return "Yes"


print(main())

Submission status: Accepted

Solution code:
N=int(input())
listA=[[0,0,0]] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;        
        
def main():
  for i in range(N):
    Manhattan_distance=abs(listA[i+1][1]-listA[i][1])+abs(listA[i+1][2]-listA[i][2])
    #print("Manhattan_distance",Manhattan_distance)
    #print("")
    
    # 偶奇での不可と可能
    if listA[i+1][0]%2!=(listA[i+1][1]+listA[i+1][2])%2:
      #print("listA[i+1][0]%2",listA[i+1][0]%2)
      #print("(listA[i+1][1]+listA[i+1][2])%2",(listA[i+1][1]+listA[i+1][2])%2)
      return "No"
    
    if (listA[i+1][0]-listA[i][0])%2!=Manhattan_distance%2: #時間差%2 != マンハッタン距離
      #print("(listA[i+1][0]-listA[i][0])%2",(listA[i+1][0]-listA[i][0])%2)
      
      return "No"
    
    # 距離的制約
    if (listA[i+1][0]-listA[i][0])<Manhattan_distance:
      return "No"
  
  return "Yes"



print(main())

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())

    pt, px, py = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        dt = t - pt
        dx = abs(x - px)
        dy = abs(y - py)
        dl = dx + dy

        if dt < dl or dl % 2 != dt % 2:
            print('No')
            return

        pt, px, py = t, x, y

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
TXY = [(0, 0, 0)]
for i in range(n):
	TXY.append(tuple(map(int, input().split())))
for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]):
	dist = abs(x2 - x1) + abs(y2 - y1)
	d = t2 - t1
	if dist > d or dist % 2 != d % 2:
		print("No")
		exit()
else:
	print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
TXY = [(0, 0, 0)]
for i in range(n):
	TXY.append(tuple(map(int, input().split())))
for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]):
	dist = abs(x2 - x1) + abs(y2 - y1)
	d = t2 - t1
	flag = False
	for t in range(d, -1, -2):
		if t == dist:
			flag = True
			break
	if flag == False:
		print("No")
		exit()
else:
	print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
ans = "Yes"
now_x = 0
now_y = 0
now_t = 0

for i in range(n):
  t,x,y = map(int,input().split())
  
  if abs(now_x-x)+abs(now_y-y) > (t-now_t):
    ans = "No"
    break
    
  if (abs(now_x-x)+abs(now_y-y)-(t-now_t))%2 == 1:
    ans = "No"
    break
    
  now_x = x
  now_y = y
  now_t = t
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
data = [[int(__) for __ in input().split()] for _ in range(N)]


data.insert(0, [0, 0, 0])
canTravel = True

for i in range(1, N+1):
    absT = abs(data[i][0] - data[i-1][0])
    absX = abs(data[i][1] - data[i-1][1])
    absY = abs(data[i][2] - data[i-1][2])

    distance = absX + absY
    if absT < distance or absT % 2 != distance % 2:
        canTravel = False
        break

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

Submission status: Accepted

Solution code:
N = int(input())
data = [[int(__) for __ in input().split()] for _ in range(N)]


data.insert(0, [0, 0, 0])
canTravel = True


def diff(nowData, oldData):
    absT = abs(nowData[0] - oldData[0])
    absX = abs(nowData[1] - oldData[1])
    absY = abs(nowData[2] - oldData[2])
    return [absT, absX, absY]


for index, d in enumerate(data):
    if index == 0:
        continue
    else:
        absT, absX, absY = diff(d, data[index - 1])
        distance = absX + absY
        if absT < distance or absT % 2 != distance % 2:
            canTravel = False
            break

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

Submission status: Accepted

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

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

ans = "Yes"
t0, sx, sy = 0, 0, 0
for i in range(N):
    dis = manhat_dis(sx, sy, x[i], y[i])
    dt = t[i] - t0
    if dt < dis or (dis - dt) % 2:
        ans = "No"
        break
    t0, sx, sy = t[i], x[i], y[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t=[0]
x=[0]
y=[0]
for i in range(n):
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

flag = 0
for i in range(1,n+1):
    dt = t[i] - t[i-1]
    dx = x[i] - x[i-1]
    dy = y[i] - y[i-1]
    dist = abs(dx) + abs(dy)
    if dist > dt:
        flag = flag +1
    elif dist % 2 != dt % 2:
        flag = flag +1
else:
    print("Yes" if flag ==0 else "No")

Submission status: Accepted

Solution code:
n = int(input())
t=[0]
x=[0]
y=[0]
for i in range(n):
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

for i in range(1,n+1):
    dt = t[i] - t[i-1]
    dx = x[i] - x[i-1]
    dy = y[i] - y[i-1]
    if abs(dx) + abs(dy) > dt or (dx+dy) % 2 != 0 and dt % 2 == 0 or (dx+dy) % 2 == 0 and dt % 2 != 0:
        break

else:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = [input().split() for _ in range(N)]

if N ==1:
  n = int(A[0][0])
  move = int(A[0][1]) + int(A[0][2]) 
  if move > n or move%2 != n%2:
    print("No")
  else:
    print("Yes")
  
for i in range(1,N):
  H = abs(int(A[i][1]) - int(A[i -1][1]))
  V = abs(int(A[i][2]) - int(A[i -1][2]))
  move = H + V
  n = int(A[i][0]) - int(A[i -1][0])
  if move > n or move%2 != n%2:
    print("No")
    break
  elif i == N -1:
    print("Yes")

Submission status: Accepted

Solution code:
before = 0, 0, 0
for _ in range(int(input())):
    tt, tx, ty = map(int, input().split())
    bt, bx, by = before
    distance = abs(tx - bx) + abs(ty - by)
    t = tt - bt
    if t < distance or t % 2 != distance % 2:
        break
    before = tt, tx, ty
else:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
N = int(input())

bt, bx, by = 0, 0, 0

for _ in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-bx)+abs(y-by)
    time = t-bt
    if time<dist or time%2!=dist%2:
        print('No')
        break
    bt, bx, by = t, x, y
else:
    print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
x=y=t=0
flag=True
for i in range(N):
  ti, xi, yi = map(int, input().split())
  dist = abs(xi-x)+abs(yi-y)
  dt = ti-t
  x, y, t = xi, yi, ti
  if dist<=dt and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")

Submission status: Accepted

Solution code:
N=int(input())
x=y=t=0
flag=True
for i in range(N):
  ti, xi, yi = map(int, input().split())
  dist = abs(xi-x)+abs(yi-y)
  dt = ti-t
  x, y, t = xi, yi, ti
  if dist<=dt and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[lmp() for i in range(n)]
if l[0][0]<l[0][1]+l[0][2] or l[0][0]%2!=(l[0][1]+l[0][2])%2:
    print("No")
    exit()
for i in range(n-1):
    t,x,y=l[i+1][0]-l[i][0],abs(l[i+1][1]-l[i][1]),abs(l[i+1][2]-l[i][2])
    if t<x+y or t%2!=(x+y)%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def resolve():
  n = int(input())
  plan = []
  for i in range(n):
    t, x, y = map(int, input().split())
    plan.append((t, x, y))

  t = 0
  x = 0
  y = 0

  for p in plan:
    time = p[0] - t
    l = abs(x - p[1]) + abs(y - p[2])
    if l > time or l % 2 != time % 2:
      print('No')
      return
    t, x, y = p

  print('Yes')

  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
n = int(input())

time = 0
now = [0, 0]
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - now[0]) + abs(y - now[1])
    if d <= t - time and d % 2 == (t - time) % 2:
        time = t
        now = x, y
        continue
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Accepted

Solution code:
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
X.insert(0,[0,0,0])
flag = 0
for i in range(1,N+1):
    dx = dist(X[i][1:],X[i-1][1:])
    dt = X[i][0]-X[i-1][0]
    if dt>=dx and (dt-dx)%2==0:
        continue
    else:
        flag = 1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = "Yes"
X = 0
Y = 0
T = 0
for _ in range(N):
    t,x,y = map(int, input().split())
    dt = t-T
    d = abs(X-x)+abs(Y-y)-dt
    if d > 0 or d%2 == 1:
        ans = "No"
    T = t
    X = x
    Y = y

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    l.insert(0,[0,0,0])
    ans='Yes'
    for i in range(n):
        t=l[i+1][0]-l[i][0]
        x=abs(l[i+1][1]-l[i][1])
        y=abs(l[i+1][2]-l[i][2])
        if t<x+y or t%2!=(x+y)%2:
            ans='No'
            break
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    px, py, pt = 0, 0, 0
    for i in range(n):
        t, x, y = XY[i]
        if abs(x - px) + abs(y - py) > abs(t - pt):
            print("No")
            break
        else:
            if (abs(x - px) + abs(y - py) - abs(t - pt)) % 2 != 0:
                print("No")
                break
            px, py, pt = x, y, t
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    t=[0]*n
    x=[0]*n
    y=[0]*n
    for i in range(n):
        t[i],x[i],y[i]=map(int,readline().split())

    flag=True
    for i in range(n):
        if i==0:
            if t[i]==x[i]+y[i]:
                pass
            else:
                flag=False
                break
        else:
            a=t[i]-t[i-1]
            b=abs(x[i]-x[i-1])
            c=abs(y[i]-y[i-1])
            if a>=b+c and a%2==(b+c)%2:
                pass
            else:
                flag=False
                break

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

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
T=X=Y=0
ans = "Yes"

for t,x,y in txy:
  a = (t-T) - (abs(X-x) + abs(Y-y))
  if a % 2 == 0 and abs(X-x) + abs(Y-y) <= t - T:
    T,X,Y = t,x,y
  else:
    ans = "No"
    break
print(ans)

Submission status: Accepted

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

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

t = 0
x = 0
y = 0
for i in range(N):
  dt = L[i][0]-t
  nx = L[i][1]
  ny = L[i][2]
  dif = abs(x-nx)+abs(ny-y)
  #print(dif,dt)
  if dif > dt or (dif-dt)%2 == 1:
    print("No")
    sys.exit()
  t += dt
  x = nx
  y = ny
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())

bt=0
bx=0
by=0
ans='Yes'
for i in range(n):
  t,x,y=map(int,input().split())
  dt=t-bt
  dx=abs(x-bx)
  dy=abs(y-by)

  if (dx+dy)>dt:
    ans='No'
  elif (dt-(dx+dy))%2==1:
    ans='No'

  bt=t
  bx=x
  by=y

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
txy = []
for _ in range(n):
    t, x, y = map(int, input().split())
    txy.append((t, x, y))
px = py = pt = 0
for t, x, y in txy:
    m = abs(x-px)+abs(y-py)
    dt = t-pt
    if m>dt or (dt-m)%2==1:
        print('No')
        break
    px, py, pt = x, y, t
else:
    print('Yes')

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = [list(map(int, input().split())) for i in range(n)]
    t, x, y = [0], [0], [0]
    t.extend([row[0] for row in a])
    x.extend([row[1] for row in a])
    y.extend([row[2] for row in a])
    flag = 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:
            print('No')
            flag = False
            break
        elif dt % 2 != dist % 2:
            print('No')
            flag = False
            break
    if flag == True:
        print('Yes')
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

t_list = [0]
x_list = [0]
y_list = [0]

for a in range(n):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

for a in range(1, n+1):
    dt = t_list[a] - t_list[a-1]
    dx = x_list[a] - x_list[a-1]
    dy = y_list[a] - y_list[a-1]

    if abs(dx) + abs(dy) <= dt:
        if (dx + dy) % 2 == dt % 2:
            ans = True
        else:
            ans = False
            break
    else:
        ans = False
        break

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

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    def check_possible_plan(query):
        prev_t, prev_x, prev_y = 0, 0, 0
        for t, x, y in query:
            diff_t = t - prev_t
            manhattan = abs(x - prev_x) + abs(y - prev_y)
            if diff_t < manhattan or (diff_t - manhattan) % 2 == 1:
                return False
            prev_t, prev_x, prev_y = t, x, y
        return True


    n = ii()
    query = [lmi() for _ in range(n)]
    print('Yes') if check_possible_plan(query) else print('No')



if __name__ == "__main__":
    main()