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 = [],[],[]
for i in range(N):
  t,x,y = map(int,input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
if N == 1:
  trans_count = X[0] + Y[0]
  time = T[0]
  if (time - trans_count) % 2 == 0 and time - trans_count >= 0:
    print("Yes")
  else:
    print("No")
  exit()
for i in range(N-1):
  trans_count = abs(X[i+1] - X[i]) + abs(Y[i+1] - Y[i])
  time = T[i+1] - T[i]
  if (time - trans_count) % 2 != 0 or time - trans_count < 0:
    print("No")
    break
  elif i == N-2:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
I = [[int(i) for i in input().split()] for j in range(N)]

current, time = (0, 0), 0
for i in range(N):
    dist = abs(current[0] - I[i][1]) + abs(current[1] - I[i][2])
    if dist > I[i][0] - time or (I[i][0]- time - dist) % 2 == 1:
        print("No")
        break
    current, time = (I[i][1], I[i][2]), I[i][0]
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t=[0]
x=[0]
y=[0]
z = 1
for j in range(n):
    [a,b,c] = [int(i) for i in input().split()]
    t.append(a)
    x.append(b)
    y.append(c)

for i in range(1,len(t)):
    tmp = abs(x[i] - x[i - 1])+abs(y[i] - y[i - 1])
    if (tmp <= (t[i] - t[i - 1])) and ((t[i] - t[i - 1] + tmp) % 2 == 0):
        z = z
    else:
        z = 0

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

Submission status: Accepted

Solution code:


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


def check(a1,a2):
    l = abs(a1[1]-a2[1])+abs(a1[2]-a2[2])
    t = abs(a1[0]-a2[0])
    if l <= t and l%2 == t%2:
        return True
    return False

flag = True
for i in range(N):
    r = check(a[i],a[i+1])
    if r==False:
        flag = False
        break

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

Submission status: Accepted

Solution code:
import collections


def solve(N, ts, ps):
    for i in range(N):
        dt = ts[i+1] - ts[i]
        d = abs(ps[i+1].x - ps[i].x) + abs(ps[i+1].y - ps[i].y)

        if d > dt or dt % 2 != d % 2:
            return "No"
    return "Yes"


N = int(input())
point = collections.namedtuple('point', ['x', 'y'])
ts = [0]
ps = [point(0, 0)]
for i in range(N):
    t, x, y = list(map(int, input().split()))
    ts.append(t)
    ps.append(point(x, y))

print(solve(N, ts, ps))

Submission status: Accepted

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

for i in range(N):

    if i == len(point):
        break

    Np = point[i][0]
    xp = point[i][1]
    yp = point[i][2]

    Nn = point[i+1][0]
    xn = point[i+1][1]
    yn = point[i+1][2]

    dist = abs(xn-xp) + abs(yn-yp)

    if dist != Nn - Np:
        if dist > Nn - Np:
            print('No')
            exit()
        else:
            if dist % 2 != (Nn - Np) % 2:
                print('No')
                exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
t = []
x = []
y =[]
for i in range(N):
    data = input().split()
    data = [int(n) for n in data]
    t.append(data[0])
    x.append(data[1])
    y.append(data[2])

t_now = 0
x_now = 0
y_now = 0

flag_able = True
for i in range(N):
    t_sub = t[i] - t_now
    x_sub = abs(x[i] - x_now)
    y_sub = abs(y[i] - y_now)
    step_needed = x_sub + y_sub
    if(step_needed > t_sub):
        flag_able = False
    else:
        if((t_sub - step_needed)%2 == 1):
            flag_able = False
        else:
            flag_able = True
    if(flag_able == False):
        break

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

Submission status: Accepted

Solution code:
N = int(input().rstrip())
t = [0 for _ in range(N+1)]
x = [0 for _ in range(N+1)]
y = [0 for _ in range(N+1)]

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

judge = []
for i in range(N):
    diff_t = t[i+1] - t[i]
    diff_x = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if diff_t >= diff_x and (diff_t - diff_x ) % 2 == 0:
        judge.append(True)
    else:
        judge.append(False)

if all(judge):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

    f = True
    for a in ary:
        time = a[0]
        distance = a[1] + a[2]
        max_distance = time
        if ( (time % 2) != (distance % 2) or distance > max_distance):
            print("No")
            f = False
            break
    if (f):
        print("Yes")
solve()

Submission status: Accepted

Solution code:
## ABC086C
## C - Traveling
import sys

n = int(input())
pos = [[int(_) for _ in input().split()] for _ in range(n)]

x = 0
y = 0
t = 0

for i in pos:
    ti, xi, yi = map(int,i)
    # print(t,x,y)
    dl = abs(xi-x)+abs(yi-y)
    dt = ti-t
    if (dl > dt or (dl-dt)%2 == 1):
        print('No')
        sys.exit()
    else:
        x = xi
        y = yi
        t = ti

print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

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

tb,xb,yb = 0,0,0

for t,x,y in txy:
    ts = t - tb
    xs = abs(x - xb)
    ys = abs(y - yb)
    tb = t
    xb = x
    yb = y

    if ts < xs + ys:
        print('No')
        exit()

    if (ts - (xs + ys)) % 2 == 1:
        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:
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    ts, xs, ys = [0], [0], [0]

    for i in range(n):
        ti, xi, yi = map(int, input().split())
        ts.append(ti)
        xs.append(xi)
        ys.append(yi)

    for j in range(n):
        dt = ts[j + 1] - ts[j]
        dxy = (xs[j + 1] - xs[j]) + (ys[j + 1] - ys[j])

        if (-dt <= dxy <= dt) and (dt % 2 == dxy % 2):
            pass
        else:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import math

n = int(input())
a = [input().split() for i in range(n)]

# n時間での座標(x_n,y_n)と、(n+t)時間の座標(x_(n+t), y_(n+t))との、x座標同士、y座標同士の差の絶対値の合計 S = (|x_(n+t) - x_n| + |y_(n+t) - y_n|)が、
# (1) Sがt以下
# (2) tが奇数の時Sも奇数、tが偶数の時tも偶数
# の条件を満たして入れば、可能。

def travelCheck(alpha, beta):
    timeDiff = int(beta[0]) - int(alpha[0])
    positionDiff = abs(int(beta[1]) - int(alpha[1])) + abs(int(beta[2]) - int(alpha[2]))
    flag = False
    if timeDiff >= positionDiff and (timeDiff%2 == positionDiff%2):
        flag = True
    return flag

start = ['0', '0', '0']

# positionList = []
# positionList.append(start)
# positionList.append(a)

for i in a:
    flag = travelCheck(start, i)
    start = i

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

Submission status: Accepted

Solution code:
import sys

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

TXY=[[0,0,0]]+TXY

n=0
nx=0
ny=0

for t,x,y in TXY:
    #print(n,nx,ny,t,x,y)
    if abs(x-nx)+abs(y-ny)<=t-n and (abs(x-nx)+abs(y-ny))%2==(t-n)%2:
        n,nx,ny=t,x,y
    else:
        print("No")
        sys.exit()


print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t0 = 0
x0 = 0
y0 = 0
flag = 0
for i in range(N) :
    t1,x1,y1 = map(int,input().split())
    t = t1-t0
    x = abs(x1-x0)
    y = abs(y1-y0)
    if x+y <= t and (t-(x+y))%2 == 0 :
        t0 = t1
        x0 = x1
        y0 = y1
    else :
        flag = 1
if flag == 0 :
    print("Yes")
else :
    print("No")

Submission status: Accepted

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

t0 = 0
x0 = 0
y0 = 0

for t, x, y in plan:
    if not (abs(x-x0) + abs(y-y0) <= (t-t0) and (t-t0)%2 == (abs(x-x0) + abs(y-y0))%2):
        print("No")
        exit()
    t0 = t
    x0 = x
    y0 = y

print("Yes")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

txy = [(0,0,0)]
for _ in range(n):
    txy.append(tuple(li()))
 
exist = True

for i in range(n):
    tp,xp,yp = txy[i]
    tn,xn,yn = txy[i+1]
    
    dt = tn-tp
    dx = xn-xp
    dy = yn-yp
    
    if abs(dx) + abs(dy) > dt:
        exist = False
        break
    
    if (dx+dy)%2 != dt%2:
        exist = False
        break
    
if exist:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
c = [0,0,0]
for i in range(n):
    t,x,y = map(int,input().split())
    time = t-c[0]
    coor = abs(c[1]-x)+abs(c[2]-y)
    if not (time>=coor and coor%2==time%2):
        print('No')
        exit()
    c = [t,x,y]
print('Yes')

Submission status: Accepted

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

nt = nx = ny = 0
for t,x,y in src:
    dist = abs(x-nx) + abs(y-ny)
    if t - nt < dist or (t-nt)%2 != dist%2:
        print('No')
        exit()
    nt,nx,ny = t,x,y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
x_list = [0]
y_list = [0]
t_list = [0]

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

ans = 'Yes'

for i in range(N):
	t_d = t_list[i+1] - t_list[i]
	x_d = abs(x_list[i+1] - x_list[i])
	y_d = abs(y_list[i+1] - y_list[i])
	xy_d = x_d + y_d
	if xy_d > t_d:
		ans = 'No'
		break
	else:
		if xy_d % 2 != t_d % 2:
			ans = 'No'
			break
print(ans)

Submission status: Accepted

Solution code:
def mdist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

n = int(input())
data = [[0, 0, 0]] + [[int(d) for d in input().split(' ')] for _ in range(n)]

for d1, d2 in zip(data[:-1], data[1:]):
    dt = d2[0] - d1[0]
    dist = mdist(d1[1:], d2[1:])
    if not ((dt >= dist) and ((dt%2)==(dist%2))):
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
fr=[0]*3
ans="Yes"
for i in range(int(input())):
 dest=list(map(int,input().split()))
 if (dest[0]-fr[0])<(dest[1]+dest[2]-fr[1]-fr[2])or(dest[0]-fr[0]+dest[1]+dest[2]-fr[1]-fr[2])%2!=0:
  ans="No"
  break
 fr[0],fr[1],fr[2]=dest[0],dest[1],dest[2]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
txy = [[int(i) for i in input().split()] for i in range(n)] 
txy.append([0,0,0])
txy.sort(key=lambda x:x[0])
ispossible="Yes"
for i in range(0,n):
    k = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if (k-txy[i+1][0]+txy[i][0])%2 or k>txy[i+1][0]-txy[i][0]:
        ispossible="No"
print(ispossible)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n = int(input())

now = [0,0]
time = 0

flag = True

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

Submission status: Accepted

Solution code:

N = int(input())
t = [0]
x = [0]
y = [0]

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

flag = True
for j in range(1,N+1):
    c = abs(x[j]-x[j-1])+abs(y[j]-y[j-1])
    tm = t[j]-t[j-1]
    if tm-c < 0 or (tm-c) % 2 != 0:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
t = []
x = []
y = []
t.append(0)
x.append(0)
y.append(0)

for i in range(0,N):
	I = list(map(int,input().split()))
	t.append(I[0])
	x.append(I[1])
	y.append(I[2])

frag = 1
for i in range(0,N):
	if ((t[i + 1] - t[i]) % 2) != (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) % 2:
		frag = 0
	if abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > t[i + 1] - t[i]:
		frag = 0

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

Submission status: Accepted

Solution code:
def delta_t(t):
    return abs(t[1] - t[0])

def mh_distance(x, y):
    return abs(x[1] - x[0]) + abs(y[1] - y[0])

def yes_no():
    for i in range(N):
        d_t = delta_t(t[i:i+2])
        mh_d = mh_distance(x[i:i+2], y[i:i+2])
        if (d_t < mh_d or d_t % 2 != mh_d % 2):
            return "No"
    return "Yes"

N, = map(int, input().split())
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())
print(yes_no())

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
flag = True
for nt, nx, ny in txy:
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if (dt < dx + dy) or ((dx + dy) % 2 != dt % 2):
        flag = False
        break
    t = nt
    x = nx
    y = ny
if flag:
    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 x+y > t or (x+y+t) % 2!=0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

for i in range(n):
    if i == 0:
        ti, xi, yi = 0, 0, 0
    else:
        ti, xi, yi = txy[i-1]
    tf,xf,yf = txy[i]
    dt = tf - ti
    dx = abs(xi-xf)
    dy = abs(yi-yf)

    if dt < dx + dy or (dt-(dx+dy))%2 != 0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t1, x1, y1 = 0, 0, 0

for i in range(n):
    t2, x2, y2 = [int(j) for j in input().split()]
    if not ((t2 - t1) % 2 == (abs(x2 - x1) + abs(y2 - y1)) % 2
            and (t2 - t1) >= abs(x2 - x1) + abs(y2 - y1)):
        print('No')
        break
    else:
        t1, x1, y1 = t2, x2, y2
else:
    print('Yes')

Submission status: Accepted

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

can = True

for i in range(0, 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
    elif dt % 2 != dist % 2:
        can = False

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

Submission status: Accepted

Solution code:
import sys

n=int(input())

a=0
b=0

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

Submission status: Accepted

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

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

	for i in range(len(plan)-1):
		delta_t = plan[i+1][0] - plan[i][0]
		delta_x = plan[i+1][1] - plan[i][1]
		delta_y = plan[i+1][2] - plan[i][2]

		if (delta_t < (delta_x + delta_y)) or ((delta_t - (delta_x + delta_y)) % 2 != 0):
			print("No")
			return

	print("Yes")
	return

if __name__ == '__main__':
	main()

Submission status: Accepted

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

list_tr = []
list_tr.append([list_txy[0][0],abs(list_txy[0][1]) + abs(list_txy[0][2])])

for i in range(1, n):
    list_tr.append([list_txy[i][0] - list_txy[i-1][0], \
    abs(list_txy[i][1] - list_txy[i-1][1]) + abs(list_txy[i][2] - list_txy[i-1][2])])

for i in range(0,n):
    if list_tr[i][0] < list_tr[i][1]:
        ans = "No"
    else:
        if (list_tr[i][0] - list_tr[i][1]) % 2 != 0:
            ans = "No"
        else:
            ans ="Yes"
print(ans)

Submission status: Accepted

Solution code:
n= int(input())
 
index=0
flag=0
list2=[0,0,0]
while index<n:
    list =input().split()
    t = abs(int(list[0])-list2[0])
    x = abs(int(list[1])-list2[1])
    y = abs(int(list[2])-list2[2])
    if x+y == t and flag ==0:
        answer="Yes"
        list2=[t,x,y]
    elif x+y<t and (x+y)%2==t%2 and flag ==0:
        answer="Yes"
        list2=[t,x,y]
    else:
        answer="No"
        list2 =[t,x,y]
        flag=1
    index+=1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#AtCorder Beginner Context 086 C Traveling
import sys

n = int(input())
t = []
x = []
y = []

t.append(0)
x.append(0)
y.append(0)

for i in range(n):
    a, b, c = map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)
    
for i in range(n):
    if t[i+1]-t[i] < (x[i+1] + y[i+1]) -(x[i] + y[i]) or (t[i+1]-t[i]-((x[i+1] + y[i+1]) -(x[i] + y[i])))%2 == 1:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String

N = int(input())
T = []
X = []
Y = []

for n in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

curT = 0
curX = 0
curY = 0
for n in range(N):
    nextT = T[n]
    nextX = X[n]
    nextY = Y[n]

    minD = abs(curX - nextX) + abs(curY - nextY)
    deltaT = nextT - curT

    # print('curT=', curT)
    # print('minD=', minD)
    if deltaT >= minD and ((deltaT - minD) % 2 == 0):
        curT = nextT
        curX = nextX
        curY = nextY
    else:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

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

ans = 'Yes'
t_cur, x_cur, y_cur = 0, 0, 0
for t, x, y in txy:
    d = abs(x-x_cur) + abs(y-y_cur)
    if t-t_cur >= d and ((t-t_cur)-d)%2 == 0:
        t_cur = t
        x_cur = x
        y_cur = y
    else:
        ans = 'No'
        break
    
print(ans)

Submission status: Accepted

Solution code:
N = int(raw_input())
data = []
for i in range(N):
    data.append(map(int, raw_input().split()))

for d in data:
    if d[0] < d[1] + d[2]:
        print("No")
        exit(0)
    elif d[0] > d[1] + d[2]:
        even0 = d[0] % 2 == 0
        even12 = (d[1] + d[2]) % 2 == 0
        if even0 ^ even12:
            print("No")
            exit(0)
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 and t%2==(x+y)%2:
    pass
  else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
T=X=Y=f=0
for i in[0]*input():t,x,y=map(int,raw_input().split());f+=t-T<abs(x-X)+abs(y-Y)or(x+y+t+X+Y+T)%2;T,X,Y=t,x,y
print["Yes","No"][f>0]

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

t_ = x_ = y_ = flag = 0
for i in range(input()):
    t, x, y = map(int, raw_input().split())
    if t - t_ < abs(x - x_) + abs(y - y_) or (x + y + t + x_ + y_ + t_) % 2:
        print "No"
        exit()
    t_, x_, y_ = t, x, y

print "Yes"

Submission status: Accepted

Solution code:
t_ = x_ = y_ = flag = 0
for i in range(input()):
    t, x, y = map(int, raw_input().split())
    flag += t - t_ < abs(x - x_) + abs(y - y_) or (x + y + t + x_ + y_ + t_) % 2
    t_, x_, y_ = t, x, y

print ["Yes", "No"][flag > 0]

Submission status: Accepted

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N = input()
t_, x_, y_ = 0, 0, 0
flag = True
for i in range(N):
    t, x, y = map(int, raw_input().split())
    if t - t_ < abs(x - x_) + abs(y - y_) or (x + y + t + x_ + y_ + t_) % 2:
        flag = False
    t_, x_, y_ = t, x, y

print "Yes" if flag else "No"

Submission status: Accepted

Solution code:
N = int(input())

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

    if distance > t or t % 2 != distance % 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

for i in range(n):
    t = txy[i][0]
    t -= txy[i][1]
    t -= txy[i][2]
    if t < 0:
        print("No")
        break
    if t % 2 != 0:
        print("No")
        break
    if i == n-1:
        print("Yes")
        break
    else:
        txy[i+1][0] -= txy[i][0]
        txy[i+1][1] = abs(txy[i+1][1] - txy[i][1])
        txy[i+1][2] = abs(txy[i+1][2] - txy[i][2])

Submission status: Accepted

Solution code:
n = int(input())
pt = 0
px = 0
py = 0
l = []
for i in range(n):
    t,x,y = map(int,input().split())
    l.append((t,x,y))

for i in range(n):
    t,x,y = l[i]
    d = abs(x - px) + abs(y - py)
    dt = t - pt
    if d % 2 != dt % 2 or dt < d:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

N = int(input())

now_txy = [0, 0, 0]

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

for i in range(N):
    next_txy = plan[i]
    diff = abs(next_txy[1] - now_txy[1]) + abs(next_txy[2] - now_txy[2]) - (next_txy[0] - now_txy[0])
    if (diff <= 0) & (diff % 2 == 0):
        now_txy = next_txy.copy()
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

diffs = []  
for i in range(1,n+1,1):
  diff = [ x - y for (x,y) in zip(lists[i], lists[i-1])]
  diffs.append(diff) 
  
for diff in diffs:
  if diff[0] < abs(diff[1]) + abs(diff[2]):
    print('No')
    exit()
  elif diff[0] % 2 != (abs(diff[1]) + abs(diff[2])) % 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 (t+x+y)%2 != 0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
lst = [[0, 0, 0]]
for _ in range(N):
    t, x, y = [int(a) for a in stdin.readline().strip().split()]
    lst.append([t, x, y])

ans = True
for i in range(len(lst) - 1):
    dt = abs(lst[i + 1][0] - lst[i][0])
    dx = abs(lst[i + 1][1] - lst[i][1])
    dy = abs(lst[i + 1][2] - lst[i][2])

    if dx + dy > dt or dt % 2 != (dx + dy) % 2:
        ans = False
        break

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

Submission status: Accepted

Solution code:
N = int(input())
t = [0];x = [0]
for _ in range(N):
    a,b,c = map(int,input().split())
    t.append(a)
    x.append(b+c)
flg = 1
for i in range(N):
    if ((x[i+1]-x[i])-(t[i+1]-t[i]))%2==1 or x[i+1]>t[i+1]:
        print("No")
        flg = 0
        break
if flg: print("Yes")

Submission status: Accepted

Solution code:

N = int(input())
Z=[]
for i in range(N):
	t, x, y = map(int, input().split())
	if t % 2 == 0:
		if x + y <= t and (x + y) % 2 == 0:
			Z.append(1)
		else:
			Z.append(0)
	else:
		if x + y <= t and (x + y) % 2 == 1:
			Z.append(1)
		else:
			Z.append(0)
	i += 1
if Z.count(0) >=1:
	print('No')
else:
	print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = (0, 0, 0)

for _ in range(N):
	t1, x1, y1 = map(int, input().split())
	if abs(x1-x0)+abs(y1-y0) > t1-t0 or (abs(x1-x0)+abs(y1-y0))%2 != (t1-t0)%2:
		print('No')
		break
	t0, x0, y0 = t1, x1, y1
else:
	print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t1 = 0
x1 = 0
y1 = 0
boolean = True

for __ in range(n):
    t, x, y = [int(_) for _ in input().split()]
    if boolean:
        temp1 = x
        temp2 = t
        x = abs(x - x1) + abs(y - y1)
        t -= t1
        x1 = temp1
        y1 = y
        t1 = temp2
        if x > t or (x + t) % 2 == 1:
            boolean = False
if boolean:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
T = []
X = []
Y = []
t1 = 0
x1 = 0
y1 = 0
for i in range(n):
    m = input().split()
    T.append(int(m[0]) - t1)
    t1 = int(m[0])
    X.append(abs(int(m[1]) - x1))
    x1 = int(m[1])
    Y.append(abs(int(m[2]) - y1))
    y1 = int(m[2])
T = np.array(T)
X = np.array(X)
Y = np.array(Y)
for i in range(n):
    if X[i] + Y[i] > T[i] or (X[i] + Y[i] + T[i]) % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

for i in range(0,N-1):
  T = L[i+1][0]-L[i][0]
  X = L[i+1][1]-L[i][1]
  Y = L[i+1][2]-L[i][2]
  if (T % 2 != (X+Y) % 2):
    flag = False
    break
  else:
    if (T < X+Y):
      flag = False
      break
if flag:
  if(L[0][0] % 2 != (L[0][1]+L[0][2]) % 2):
    flag = False
  else:
    if (L[0][0] < L[0][1]+L[0][2]):
      flag = False

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

Submission status: Accepted

Solution code:
(lambda ft: print(ft.reduce(lambda p, c: (p[0] < 0 or (lambda t, d: (d > t or d % 2 != t % 2))(c[0] - p[0], abs(c[1] - p[1]) + abs(c[2] - p[2]))) and [-1, -1, -1] or c, [list(map(int, input().split())) for _ in range(int(input()))], [0, 0, 0])[0] < 0 and "No" or "Yes"))(__import__("functools"))

Submission status: Accepted

Solution code:
t0 = 0
x0=0
y0=0
N = int(input())

ans='Yes'

for _ in range(N):
    t, x, y = [int(x) for x in input().split()]
    dist = abs(x-x0)+abs(y-y0)
    tt = t-t0
    if dist <= tt and (tt - dist)%2==0:
        pass
    else:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

Solution code:
'''input
2
3 1 2
6 1 1
'''
n = input()
arr = []
for i in range(n):
	t,x,y = map(int,raw_input().split())
	arr.append((t,x,y))
arr.sort()
cx,cy = 0,0
ct = 0
flag = False
for i in range(n):
	td = arr[i][0]-ct
	if abs(cx-arr[i][1])+abs(cy-arr[i][2]) > td or (td%2 != (abs(cx-arr[i][1])+abs(cy-arr[i][2]))%2):
		flag = True
		break
	else:
		cx,cy = arr[i][1],arr[i][2]
		ct = arr[i][0]
print "No" if flag else "Yes"

Submission status: Accepted

Solution code:
n=int(input())
a=[[0]*3 for i in range(n+1)]
for i in range(1,n+1):
    t,x,y=map(int,input().split())
    a[i][0]=t
    a[i][1]=x
    a[i][2]=y

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

Submission status: Accepted

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

def main():
    N = int(input())

    pre_t, pre_x, pre_y = 0, 0, 0
    for i in range(N):
        t, x, y = list(map(int, input().split()))
        diff = abs(x-pre_x) + abs(y-pre_y)
        amari = (t-pre_t) - diff
        if amari < 0:
            # 遠すぎて到達不可能
            print("No")
            exit()
        elif amari == 0:
            continue
        elif amari%2 == 0:
            # 余りが偶数なら目的地に戻れる
            continue
        else:
            print("No")
            exit()
    print("Yes")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
P = [[int(c) for c in input().split()] for _ in range(N)]
current = [0, 0, 0]
accept = True

for t, x, y in P:
    dt = t - current[0]
    d = abs(current[1] - x) + abs(current[2] - y)
    if d > dt:
        accept = False
        break
    elif d % 2 != dt % 2:
        accept = False
        break
    else:
        current = [t, x, y]

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
t = [0 for i in range(N+1)]
x = [0 for i in range(N+1)]
y = [0 for i in range(N+1)]

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

for i in range(N):
    time = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if (time - dist) >= 0 and (time - dist) % 2 == 0:
        pass
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

feasible = True
x = 0
y = 0
t = 0

for i in range(n):
    cp_t, cp_x, cp_y = map(int, input().split())
    if not feasible:
        continue

    step = abs(x - cp_x) + abs(y - cp_y)
    dt = cp_t - t
    if dt < step:
        feasible = False
    if (dt - step) % 2 != 0:
        feasible = False
    x = cp_x
    y = cp_y
    t = cp_t

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

Submission status: Accepted

Solution code:
N = int(input())
T = [0] * (N+1)
X = [0] * (N+1)
Y = [0] * (N+1)
flag = True
for i in range(1, N+1):
    T[i], X[i], Y[i] = list(map(int, input().split()))
for i in range(N):
    DIST = abs(X[i+1] - X[i]) + abs(Y[i+1]- Y[i])
    DIFF = T[i+1] - T[i]
    if (DIFF - DIST) % 2 == 1 or DIFF < DIST:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
plan = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
diff = [[plan[i + 1][j] - plan[i][j] for j in range(3)] for i in range(N)]

def is_possible(t, x, y):
    if (t + x + y) % 2 == 0 and abs(x) + abs(y) <= t:
        return True
    else:
        return False

for i in range(N):
    ti, xi, yi = diff[i]
    if not is_possible(ti, xi, yi):
        print('No')
        exit()
print('Yes')