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())
txy = [list(map(int, input().split())) for _ in range(n)]

for i in range(n):
    if i == 0:
        diff_t = txy[i][0]
        diff_ab = abs(txy[i][1]) + abs(txy[i][2])
    else:
        diff_t = txy[i][0] - txy[i-1][0]
        diff_ab = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2]-txy[i-1][2])
    # 距離判定
    if diff_ab > diff_t:
        print('No')
        exit()
    # 奇数偶数判定
    if diff_ab % 2 != diff_t % 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
t=0
x=0
y=0
hantei=True
for i in range(N):
  t_,x_,y_=map(int,input().split())
  if abs(x-x_)+abs(y-y_)>t_-t or abs(abs(x-x_)+abs(y-y_)-(t_-t))%2==1:
    hantei=False
    break
  else:
    t=t_
    x=x_
    y=y_
print('Yes' if hantei else 'No')

Submission status: Accepted

Solution code:
n = int(input())
 
travel = []
for i in range(n):
    t,x,y = map(int, input().split())
    tmp = [t,x,y]
    travel.append(tmp)
 
now = [0, 0]
pre_time = 0
for tra in travel:
    diff_time,x,y = tra[0]-pre_time,tra[1],tra[2]
    for _ in range(diff_time):
        if now[0] < x:
            now[0] += 1
        elif x < now[0]:
            now[0] -= 1
        elif now[1] < y:
            now[1] += 1
        elif y < now[1]:
            now[1] -= 1
        else:
            now[1] -= 1
    
    if now[0] == x and now[1] == y:
        pass
    else:
        print('No')
        exit()

    pre_time = tra[0]
 
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

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

x = 0
y = 0
t = 0
ans = 'Yes'

for i in lst:
  diff_t = i[0] - t
  dis = abs(i[1] - x) + abs(i[2] - y)
  if (diff_t < dis):
    ans = 'No'
    break
  if ((dis - diff_t) % 2 != 0):
    ans = 'No'
    break
  x = i[1]
  y = i[2]
  t = i[0]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
flg = True
t, x, y = 0, 0, 0
for i in range(n):
    nt, nx, ny = map(int, input().split()) 
    dist = abs(x - nx) + abs(y - ny)
    dt = nt - t
    if dist > dt or (dist - dt) % 2 == 1:
        print("No")
        flg = False
        break
    t, x, y = nt, nx, ny
if flg == True:
    print("Yes")

Submission status: Accepted

Solution code:
nums = int(input())
tmp = list()
for num in range(nums):
    tmp.append([int(_) for _ in str(input()).split(" ")])

for num, case in enumerate(tmp):
    t, x, y = case
    if t < abs(x) + abs(y):
        print("No")
        break
    else:
        if ((abs(x) + abs(y)) % 2) and (t % 2):
            if num +1 == len(tmp):
                print("Yes")
        elif ((abs(x) + abs(y)) % 2 == 0) and (t % 2 == 0):
            if num +1 == len(tmp):
                print("Yes")
        else:
            print("No")
            break

Submission status: Accepted

Solution code:
_,*l=map(int,open(0).read().split());print("YNeos"[any((t+x+y)%2+(t<x+y)for t,x,y in zip(*[iter(l)]*3))::2])

Submission status: Accepted

Solution code:
N = int(input())
T = []
Z = []
time = []
T.append([0,0,0])
for i in range(N):
    t = list(map(int, input().split()))
    T.append(t)
goal = True

for l in range(len(T)-1):
    Z.append(abs(T[l+1][1]-T[l][1]) + abs(T[l+1][2]-T[l][2]))
    time.append(T[l+1][0] - T[l][0])

for j in range(len(T)-1):
    if Z[j] > time[j] or Z[j]%2 != time[j]%2:
        goal = False
        break

if goal == False:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

txy = [[0, 0, 0]]
for i in range(N):
    tmp = list(map(int, input().split()))
    txy.append(tmp)
    
for i in range(len(txy)-1):
    start = txy[i]
    goal = txy[i+1]
    time = goal[0] - start[0]
    move_x = abs(goal[1] - start[1])
    move_y = abs(goal[2] - start[2])
    if move_x + move_y <= time:
        if (time - (move_x + move_y)) % 2 == 0:
            pass
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
prevt,prevx,prevy = 0,0,0
for i in range(N):
    t, x, y = map(int,input().split())
    dt,dx,dy = t-prevt,x-prevx,y-prevy
    if dt < dx+dy or (dt-dx-dy)%2 != 0:
        print('No')
        exit()
    prevt,prevx,prevy = t,x,y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

result = 1
bt=0
bx=0
by= 0

for i in range(N):
	t, x, y = map(int, input().split())
	distance = abs(x-bx) + abs(y-by)
	dur = t - bt
#	print(t,x,y,distance, dur)
	if dur - distance >= 0 and (dur - distance) %2 == 0:
		(bt,bx,by) = (t,x,y)
		continue
	else:
		result = 0
		break

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

Submission status: Accepted

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

import numpy
import scipy
#import sys


N = int(input())
P = []
for n in range(N):
    P.append(list(map(int, input().split())))

for i, p in enumerate(P):
    if i == 0:
        t_p, x_p, y_p = 0, 0, 0
    else:
        t_p, x_p, y_p = P[i-1][0], P[i-1][1], P[i-1][2]
    t, x, y = p
    dt = t - t_p
    dx = x - x_p
    dy = y - y_p
    dist = abs(dx) + abs(dy)

    if dist > dt:
        print("No")
        exit()

    if dist%2 != dt%2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = []
S.append([0,0,0])
for _ in range(N):
    S.append(list(map(int, input().split())))
#print(S)
cnt = 0
for i in range(len(S)-1):
  time = S[i+1][0]-S[i][0]
  distance = abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2])
  if distance>time or distance%2 != time%2:
    print('No')
    break
  else:
    cnt+=1
if cnt == len(S)-1:
  print('Yes')

Submission status: Accepted

Solution code:
N=int(input())

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

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

can=True

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

suc = True

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
t0,x0,y0=0,0,0
for i in range(n):
    t,x,y=map(int,input().split())
    d=abs(x0-x)+abs(y0-y)
    if d%2!=(t-t0)%2 or (t-t0)<d:
        print("No")
        exit()
    t0,x0,y0=t,x,y
print("Yes")

Submission status: Accepted

Solution code:
now = {"t":0,"x":0,"y":0}
can = True
for i in range(int(input())):
    t,x,y = map(int,input().split())
    dx = abs(x - now["x"]) #x距離
    dy = abs(y - now["y"]) #y距離
    d = dx + dy #距離合計
    if d > t-now["t"] or d%2 != (t-now["t"])%2:
        print("No")
        can = False
        break
    now = {"t":t,"x":x,"y":y}
if can:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n):
    period = li[i+1][0] - li[i][0]
    dist = abs(li[i+1][1] - li[i][1]) + abs(li[i+1][2] - li[i][2])
    if period % 2 == 0 and dist % 2 == 0 and period >= dist:
        continue
    elif period % 2 != 0 and dist % 2 != 0 and period >= dist:
        continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
Plan = []
for i in range(n):
  Plan.append(list(map(int, input().split())))
Plan.sort(lambda x: x[0])
x = 0
y = 0
t = 0
for txy in Plan:
  t_new, x_new, y_new = txy
  dx = abs(x_new - x)
  dy = abs(y_new - y)
  dt = abs(t_new - t)
  if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
    continue
  else:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
points = [[0, 0, 0]]
for i in range(n):
    points.append(list(map(int, input().split())))

def can_exist(before_point, after_point):
    def_t = after_point[0] - before_point[0]
    def_x = after_point[1] - before_point[1]
    def_y = after_point[2] - before_point[2]
    def_total = abs(def_x) + abs(def_y)
    if def_total <= def_t and def_total % 2 == def_t % 2:
        return True
    else:
        return False

out = 'Yes'
for i in range(n):
    if can_exist(points[i], points[i+1]):
        continue
    else:
        out = 'No'
        break

print(out)

Submission status: Accepted

Solution code:
n = int(input())

x1,y1 = 0,0
t1 = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    if abs(x1-x) + abs(y1-y) <= t - t1 and (abs(x1-x) + abs(y1-y) - (t - t1)) % 2 == 0:
        x1 = x
        y1 = y
        t1 = t
        continue
    else:
        print("No")
        import sys
        sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
travel_list = [np.array([0, 0, 0])]
add_list = [np.array([int(i) for i in input().split()]) for i in range(N)] 
travel_list.extend(add_list)

def is_travel(arr1, arr2):
    dt, dx, dy = abs(arr2 - arr1)
    if dt < dx + dy:
        return False
    elif dt % 2 != (dx + dy) % 2:
        return False
    else:
        return True
        
travel = 'Yes'
for i in range(N):
    if is_travel(travel_list[i], travel_list[i+1]):
        continue
    else:
        travel = 'No'
        break
print(travel)

Submission status: Accepted

Solution code:
N=int(input())
T,X,Y=[0], [0], [0]
flag=0
for i in range(N):
    t,x,y = list(map(int,input().split()))
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    if X[i+1]-X[i]+Y[i+1]-Y[i]<=(T[i+1]-T[i]) and (X[i+1]-X[i]+Y[i+1]-Y[i]-(T[i+1]-T[i]))%2==0:
        continue
    else:
        flag+=1
        break
if flag==1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
N = int(input())
TXY = [[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]

ans = "Yes"
for i in range(N):
    t0,x0,y0 = TXY[i]
    t1,x1,y1 = TXY[i+1]
    t = t1-t0
    d = abs(x1-x0)+abs(y1-y0)
    if t<d or d%2!=t%2:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
row_length = int(input())
point = {}
for i in range(row_length):
    point[i] = list(map(int, input().split()))
from math import ceil
def feasible_point(t, x, y):
    if t % 2 == 0:  # tが偶数の時
        k = t / 2
        # (x,y)がk * kの間にある偶数点ならばokを返す・・・これが間違っていた
        # x + y <= 6の点なら何でもよかった
        if ((x+y)%2 == 0)&(x+y <= t):
            return True
        else:
            return False
    else:
        k = ceil(t / 2)
        # (x,y)がk * kの間にある奇数点ならばokを返す
        if ((x+y)%2 == 1)&(x+y<= t):
            return True
        else:
            return False

check_list = []
for j in range(len(point)):
    check_list.append(feasible_point(point[j][0], point[j][1], point[j][2]))

if all(check_list):
    # 各点同士の両立可能性を調べる
    check_list_2 = []
    for l in range(len(point)-1):
        t_gap = point[l+1][0] - point[l][0]
        xy_gap = point[l+1][1] + point[l+1][2] - point[l][1] - point[l][2]
        if abs(xy_gap) <= abs(t_gap):
            check_list_2.append(True)
        else:
            check_list_2.append(False)
    if all(check_list_2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
plan = [[int(i) for i in input().split()] for j in range(N)]
x = 0
y = 0
t = 0
 
for i in range(N):
    newT = plan[i][0]
    x_t = plan[i][1]
    y_t = plan[i][2]
    distance = abs((x_t+y_t) - (x+y))
    time_lag = newT - t
 
    if distance % 2 == time_lag % 2:
        if distance <= time_lag:
            t = newT
            x = x_t
            y = y_t
            continue
    
    print("No")
    exit()
 
print("Yes")

Submission status: Accepted

Solution code:
#86c
N = int(input())

now_x = 0
now_y = 0
now_t = 0

for i in range(N):
    t,x,y = map(int, input().split())
    margin = (t- now_t) - abs(x - now_x) - abs(y - now_y)
    
    if margin < 0 or margin%2!=0:
        print("No")
        break
    else:
        now_x = x
        now_y = y
        now_t = t
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t_x_y = [0]*N
for n in range(N):
    t_x_y[n] = [int(x) for x in input().split()]
    
can_flag = 1
for t, x, y in t_x_y: 
    if (t%2 == (x+y)%2) & ((x+y)<=t):
        continue
    else:
        can_flag=0
        break

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

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0
for i in range(int(input())):
    t_next, x_next, y_next = map(int, input().split())
    dif = abs(x - x_next) + abs(y - y_next)
    if dif > abs(t - t_next) or (dif - (t- t_next))%2 == 1:
        print('No')
        exit(0)
    t, x, y = t_next, x_next, y_next
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
TXY = []
for n in range(N):
    TXY.append([int(i) for i in input().split()])
temp = [0,0,0]
ans = True
for txy in TXY:
    dist = (txy[1]-temp[1]) + (txy[2]-temp[2])
    if (txy[0]-temp[0]) % 2 == dist % 2 and (txy[0]-temp[0]) >= dist:
        temp = txy
    else:
        ans = False
print("Yes") if ans else print("No")

Submission status: Accepted

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


for i in range(N):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    if N == 1:
        root = txy[1][1] + txy[1][2]
        time = txy[1][0]
        if time < root:
            print("No")
        else:
            if (time - root) % 2 == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
info=[[0,0,0]]
for i in range(n):
    t,x,y=map(int,input().split())
    info.append([t,x,y])
ans="Yes"
for i in range(1,n+1):
    t=info[i][0]-info[i-1][0]
    kyori=abs(info[i][1]-info[i-1][1])+abs(info[i][2]-info[i-1][2])
    zan=t-kyori
    if zan<0:
        ans="No"
        break
    if zan%2!=0:
        ans="No"
        break
print(ans)

Submission status: Accepted

Solution code:
num = int(input())
a, b, c = 0, 0, 0
for i in range(num):
  d, e, f = map(int, input().split())
  times = d - a
  distance = (e-b) + (f-c)
  if times>=distance and times%2 == distance%2:
    continue
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input()) 
pre_t = 0
pre_x = 0
pre_y = 0

for i in range(N):
    now_t,now_x,now_y = list(map(int,input().split()))
    d = abs(now_x - pre_x) + abs(now_y - pre_y)
    t = now_t - pre_t
    if d <= t and t % 2 == d % 2:
        flg = 1
    else:
        flg = 0
        break

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

Submission status: Accepted

Solution code:
def examC():
    N = I()
    ans = "Yes"
    now = [0,0,0]
    for _ in range(N):
        t, x, y = LI()
        T = t - now[0]
        X = x - now[1]
        Y = y - now[2]
        if abs(X)+abs(Y)>T or (abs(X)+abs(Y)-T)%2==1:
            ans = "No"
            break
        else:
            now = [t,x,y]
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
import math

n = int(stdin.readline().rstrip())

t = [0]*n
x = [0]*n
y = [0]*n
for i in range(n):
    t[i],x[i],y[i] = [int(x) for x in stdin.readline().rstrip().split()]

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

if n == 1:
    if x[1]+y[1] > t[1]:
        print("No")
        exit()
    elif t[1]%2 != (x[1]+y[1])%2:
        print("No")
        exit()
    else:
        print("Yes")
        exit()

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

print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
t,x,y = 0,0,0
for i in range(N):
    T,X,Y = map(int,input().split())
    d = abs(x-X)+abs(y-Y)
    if (T-t)-d >= 0 and ((T-t)-d)%2 == 0:
        t,x,y = T,X,Y
        continue
    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):
    T,X,Y = map(int,input().split())
    d = abs(x-X)+abs(y-Y)
    if (T-t)-d >= 0 and ((T-t)-d)%2 == 0:
        t,x,y = T,X,Y
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[[int(i) for i in input().split()] for i in range(n)]
for i in a:
    if i[0]%2!=(i[1]+i[2])%2 or i[0]<i[1]+i[2]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def is_reachable(dept, dest):
    distance = abs(dest[1] - dept[1]) + abs(dest[2] - dept[2])
    time = dest[0] - dept[0]
    if (time - distance >= 0) and ((time - distance) % 2 == 0):
        return True
    else:
        return False


N = int(input())
itin = [(0, 0, 0)]
itin_append = itin.append
for n in range(N):
    itin_append(tuple(map(int, input().split())))

for n in range(N):
    if is_reachable(itin[n], itin[n + 1]):
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
t=[0]*n
x=[0]*n
y=[0]*n
c=0
a=0
b=0
ans='Yes'
for i in range(n):
    t[i],x[i],y[i]=map(int,input().split())
for j in range(n):
    if t[j]-c>=x[j]+y[j]-a-b:
        if (t[j]-c-(x[j]+y[j]-a-b))%2==0:
            a=x[j]
            b=y[j]
            c=t[j]
        else:
            ans='No'
            break
    else:
        ans='No'
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
nowT = 0
nowX = 0
nowY  = 0
for _ in range(N):
  nextT, nextX, nextY = map(int, input().split())
  d = abs(nowX - nextX) + abs(nowY - nextY)
  if d > (nextT - nowT) or (nextT - nowT) % 2 != d % 2:
    print('No')
    exit()
  nowT = nextT
  nowX = nextX
  nowY = nextY
print('Yes')

Submission status: Accepted

Solution code:
# Me
class Check():
    def __init__(self):
        self.now_t, self.now_x, self.now_y = 0, 0, 0

    def do(self, t, x, y):
        distance = ((x - self.now_x) + (y - self.now_y))
        duration = t - self.now_t
        if duration < distance:
            return False

        if (distance - duration) % 2 != 0:
            return False

        self.now_t, self.now_x, self.now_y = t, x, y
        return True


N = int(input())
c = Check()
for i in range(N):
    a = [int(x) for x in input().split()]
    if not c.do(a[0], a[1], a[2]):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
# Me
class Check():
    def __init__(self):
        self.now_t, self.now_x, self.now_y = 0, 0, 0

    def do(self, t, x, y):
        distance = ((x - self.now_x) + (y - self.now_y))
        duration = t - self.now_t
        if duration < distance:
            return False

        if distance % 2 != duration % 2:
            return False

        self.now_t, self.now_x, self.now_y = t, x, y
        return True


N = int(input())
c = Check()
for i in range(N):
    a = [int(x) for x in input().split()]
    if not c.do(a[0], a[1], a[2]):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

s_x = 0
s_y = 0
s_t = 0

for i in range(n):
    t = t_li[i][0]
    x = t_li[i][1]
    y = t_li[i][2]
    
    s = abs(x-s_x)+abs(y-s_y)
    
    if s > t or (t-s_t-s)%2 == 1:
        print("No")
        exit()
        
    s_x = x
    s_y = y
    s_t = t
        
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

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

    # violation case1: distance is more than time
    if x + y > t:
        flag = 0

    # validation case2: t has to be odd if x + y is odd, and vice versa for even number
    if (t + x + y) % 2 != 0:
        flag = 0

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

Submission status: Accepted

Solution code:
import sys
l = sys.stdin.readlines()
for i in l[1:]:
    t, x, y = map(int, i.split())
    if (x + y > t) or ((x + y) % 2 != t % 2):
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
cx, cy, ct = 0, 0, 0
for _ in range(N):
  t, x, y = map(int, input().split())
  if abs(x - cx) + abs(y - cy) <= t - ct and ((t - ct - (abs(x - cx) + abs(y - cy))) % 2 == 0):
    continue
  print("No")
  exit(0)
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
txy = []
for i in range(N):
    txy.append(list(map(int,input().split())))
ans = "Yes"
t = 0
x = 0
y = 0
for i in range(N):
    deft = txy[i][0] - t
    defx = abs(txy[i][1] - x)
    defy = abs(txy[i][2] - y)
    t = txy[i][0]
    x = txy[i][1]
    y = txy[i][2]
    if (defx + defy) > deft:
        ans = "No"
        break
    elif (deft - defx - defy)%2 != 0:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t,x,y = [],[],[]

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)

ct,cx,cy = 0,0,0
cond = True
for i in range(N):
	dt = t[i] - ct
	dx = abs(cx - x[i])
	dy = abs(cy - y[i])

	if dt < dx + dy:
		cond = False
		break

	buff = dx+dy-dt

	if buff % 2 == 1:
		cond = False
		break

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

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

List = []
point = [0,(0,0)]
Answer = 'Yes'
for _ in range(N):
  t,x,y = map(int,input().split())
  List.append([t,(x,y)])

for item in List:
  ability = item[0] -point[0]
  length = item[1][0]+item[1][1]-point[1][0]-point[1][1]
  if length > ability:
    Answer = 'No'
    break
  elif (ability - length) % 2 == 1:
    Answer = 'No'
    break
  else:
    point = item

print(Answer)

Submission status: Accepted

Solution code:
import numpy as np


def main():
    N = int(input())
    TXY = [[int(x) for x in input().split()] for _ in range(N)]
    TXY.insert(0, [0, 0, 0])
    d = np.diff(TXY, 1, 0)
    dd = d[:, 0] - np.abs(d[:, 1]) - np.abs(d[:, 2])
    b1 = np.any(dd < 0)
    b2 = np.any(dd % 2 != 0)
    if b1 or b2:
        print('No')
    else:
        print('Yes')


main()

Submission status: Accepted

Solution code:
import numpy as np


def main():
    N = int(input())
    TXY = [[int(x) for x in input().split()] for _ in range(N)]
    TXY.insert(0, [0, 0, 0])
    d = np.diff(TXY, 1, 0)
    dd = d[:, 0] - np.abs(d[:, 1]) - np.abs(d[:, 2])
    b1 = np.all(dd >= 0)
    b2 = np.all(dd % 2 == 0)
    if b1 and b2:
        print('Yes')
    else:
        print('No')


main()

Submission status: Accepted

Solution code:
import sys


def main():
    N = int(input())
    TXY = [[int(x) for x in input().split()] for _ in range(N)]
    TXY.insert(0, [0, 0, 0])

    for i in range(N):
        dt = TXY[i+1][0] - TXY[i][0]
        dl = abs(TXY[i+1][1] - TXY[i][1])
        dl += (TXY[i+1][2] - TXY[i][2])

        if dt < dl or (dt-dl) % 2 == 1:
            print('No')
            sys.exit()

    print('Yes')


main()

Submission status: Accepted

Solution code:
import sys
n=int(input())
lst=[]
for i in range(n):
  T,X,Y=map(int,input().split())
  lst.append([T,X,Y])
if (abs(lst[0][1])+abs(lst[0][2]))%2==lst[0][0]%2:
  if abs(lst[0][1])+abs(lst[0][2])<=lst[0][0]:
    pass
  else:
    print('No')
    sys.exit()
else:
  print('No')
  sys.exit()

for j in range(n-1):
  if (abs(lst[j][1]-lst[j+1][1])+abs(lst[j][2]-lst[j+1][2]))%2==(lst[j+1][0]-lst[j][0])%2:
    if abs(lst[j][1]-lst[j+1][1])+abs(lst[j][2]-lst[j+1][2])<=(lst[j+1][0]-lst[j][0]):
      pass
    else:
      print('No')
      sys.exit()
  else:
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

Solution code:
import sys

def main():
    N = int(input())
    t = []
    x = []
    y = []
    for i in range(N):
        ti, xi, yi = map(lambda i: int(i), input().split(' '))
        t.append(ti)
        x.append(xi)
        y.append(yi)
    current_t = 0
    current_point = [0, 0]
    for i in range(N):
        next_t = t[i]
        next_point = [x[i], y[i]]
        distance = abs(next_point[0] - current_point[0]) + abs(next_point[1] - current_point[1])
        time_diff = next_t - current_t
        if distance > time_diff:
            print('No')
            sys.exit()
        elif distance < time_diff:
            diff = time_diff - distance
            if diff % 2 == 1:
                print('No')
                sys.exit()
        current_t = t[i]
        current_point = [x[i], y[i]]
    print('Yes')

main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input().strip())
x_ = 0
y_ = 0
t_ = 0

def f(t, x, y):
    t -= (abs(x) + abs(y))
    if t < 0 or t % 2 == 1:
        return False
    else:
        return True

ans = 'No'
for n in range(N):
    t, x, y = [int(x) for x in input().strip().split()]
    t, t_, x, x_, y, y_ = t - t_, t, x - x_, x, y - y_, y
    if not f(t, x, y):
        break

else:
    ans = 'Yes'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def z(a):
  return max(a,-a)
N=int(input())
l=[list(map(int,input().split())) for _ in range(N)]
l=[[0,0,0]]+l
n=True
for i in range(N):
  a=z(l[i][1]-l[i+1][1])+z(l[i][2]-l[i+1][2])
  if not(l[i+1][0]-l[i][0]-a>=0 and (l[i+1][0]-l[i][0]-a)%2==0):
    n=False
if n:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from itertools import chain
# 入力
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
ls.insert(0,[0,0,0])
ls = list(chain.from_iterable(ls))

# 階差数列
time = [(ls[i+3]-ls[i]) for i in range(0,len(ls)-3,3)]
cost = [abs(ls[i+1]-ls[i+4])+abs(ls[i+2]-ls[i+5]) for i in range(0,len(ls)-4,3)]

# 要素ごとに比較して条件式がすべてTrueならYESを出力
result = 'Yes' if all(time[i]%2==cost[i]%2 and time[i] >= cost[i] for i in range(len(time))) else 'No'
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
list_place = []
max_t = 0
for _ in range(n):
  t, x, y = map(int, input().split())
  if t > max_t:
    max_t = t
  list_place.append([t, x, y])

t = 0
place = [0, 0]
for tgt_t, tgt_x, tgt_y in list_place:
  while t < tgt_t:
    dif_x = tgt_x - place[0]
    dif_y = tgt_y - place[1]
    if dif_x > 0:
      place[0] += 1
    elif dif_x < 0:
      place[0] -= 1
    else:
      if dif_y > 0:
        place[1] += 1
      else:
        place[1] -= 1
    t += 1
  if place[0] != tgt_x or place[1] != tgt_y:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-06 12:47:30(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, *txy = (int(x) for x in sys.stdin.read().split())
    t, x, y = [0], [0], [0]
    for i in range(0, n * 3, 3):
        t.append(txy[i])
        x.append(txy[i+1])
        y.append(txy[i+2])
    for i in range(n):
        dt = t[i+1] - t[i]
        distx = abs(x[i+1] - x[i])
        disty = abs(y[i+1] - y[i])
        if dt - (distx + disty) >= 0 and (dt - (distx + disty)) % 2 == 0:
            continue
        else:
            ans = 'No'        
            break
    else:
        ans = 'Yes'
    
    print(ans)

if __name__ == "__main__":
    # execute only if run as a script
    main()