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())
status = [list(map(int, input().split())) for i in range(N)]
dt = []
dist = []
flag = []
status.insert(0, [0, 0, 0])
for i in range(N):
    dt.append(status[i + 1][0] - status[i][0])
    dist.append(abs(status[i + 1][1] - status[i][1]) + abs(status[i + 1][2] - status[i][2]))
    if ((dt[i] % 2 == 0 and dist[i] % 2 == 0) \
        or (dt[i] % 2 == 1 and dist[i] % 2 == 1)) \
        and (dist[i] <= dt[i]):
        flag.append(True)
    else:
        flag.append(False)

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

Submission status: Accepted

Solution code:
def traveling(N: int, plan: list)->bool:
    ct, cx, cy = 0, 0, 0
    for nt, nx, ny in plan:
        if nt-ct < abs(nx-cx) + abs(ny-cy):
            return False
        if (nt-ct) % 2 != (abs(nx-cx) + abs(ny-cy)) % 2:
            return False
    return True


if __name__ == "__main__":
    N = int(input())
    plan = [tuple(int(s) for s in input().split()) for _ in range(N)]
    yes = traveling(N, plan)
    print('Yes' if yes else 'No')

Submission status: Accepted

Solution code:
N = int(input())
l = [[int(x) for x in input().split()] for _ in range(N)]
l.insert(0, [0, 0, 0])
judge = True
 
for i in range(N):
    if (l[i+1][0]-l[i][0]) < ((l[i+1][1]-l[i][1])+(l[i+1][2]-l[i][2])):
        judge = False
        break
    
    if (l[i+1][0]-l[i][0]) % 2 != ((l[i+1][1]-l[i][1])+(l[i+1][2]-l[i][2])) % 2:
        judge = False
        break
    
if judge == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
answer = "Yes"
N = int(input())
points = [[int(i) for i in input().split()] for i in range(N)]

for t, x, y in points:
    mdist = abs(x) + abs(y)
    if (mdist - t)%2 != 0 or t < mdist:
        answer = "No"
        break

print(answer)

Submission status: Accepted

Solution code:
last = [0,0,0]
N = int(input())
flag = True
for i in range(N):
    now = list(map(int, input().split()))
    judge = (now[0]-last[0]) - (abs(now[1]-last[1])+abs(now[2]-last[2]))
    if not (judge >= 0 and judge % 2 == 0):
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

ct = 0
cx = 0
cy = 0

result = "Yes"
for e_ in e:
    t = e_[0]
    x = e_[1]
    y = e_[2]

    dt = t - ct
    dxy = abs(cx - x) + abs(cy - y)
    if dxy > dt or (dt - dxy)%2 == 1:
        result = "No"
        break

    ct = t
    cx = x
    cy = y

print(result)

Submission status: Accepted

Solution code:
n=int(input())
now=(0,0,0)
result=True
for i in range(n):
    t,a,b=[int(i) for i in input().split()]
    time=t-now[0]
    x=abs(a-now[1])
    y=abs(b-now[2])
    if (x+y-time)%2!=0 or (x+y)>time:
        result=False
    else:
        now=(t,a,b)
if result:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()
def read(): return int(input())
def reads(): return [int(i) for i in input().split()]

def f(dt, dx, dy):
	if dt == dx + dy:
		return True
	elif dt < dx + dy:
		return False
	else:
		return f(dt-2, dx, dy)

N = read()
t, x, y = [0]*(N+1), [0]*(N+1), [0]*(N+1)
for i in range(1, N+1):
	t[i], x[i], y[i] = reads()

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

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

Submission status: Accepted

Solution code:
N = int(input())
flag = -1
t,x,y=0,0,0

for i in range(N):
    t2,x2,y2 = map(int,input().split())
    if abs(x+y-x2-y2) > t2-t:
        break
    elif abs(x+y-x2-y2) == t2-t:
        t,x,y=t2,x2,y2
    elif abs(x+y-x2-y2) < t2-t:
        if abs(x+y-x2-y2)%2 != (t2-t)%2:
            break
        else:
            t,x,y=t2,x2,y2
    if i+1 == N:
        flag = 1
        break
            
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

t, x, y = 0, 0, 0
flg = True
for _ in range(n):
    tn, xn, yn = map(int, input().split())
    dt, dx, dy = abs(tn-t), abs(xn-x), abs(yn-y)

    if not (dx + dy <= dt and (dx + dy) % 2 == dt % 2):
        flg = False

    t, x, y = tn, xn, yn

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

Submission status: Accepted

Solution code:
n = int(input())
txy = [[0,0,0]]
for i in range(n):
    txy.append([int(j) for j in input().split()])
for i in range(1,n+1):
    t = txy[i][0]-txy[i-1][0]
    x = abs(txy[i][1]-txy[i-1][1])
    y = abs(txy[i][2]-txy[i-1][2])
    if t%2 == (x+y)%2 and t >= x+y:
        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):
    t, x, y=map(int, input().split())
    delta_t=t-pre_t
    delta_x=abs(x-pre_x)
    delta_y=abs(y-pre_y)
    if delta_t<delta_x+delta_y:
        print("No")
        exit()
    elif (delta_x+delta_y+delta_t)%2==1:
        print("No")
        exit()
    pre_t=t
    pre_x=x
    pre_y=y
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
for i in range(N):
    a,b,c = map(int,input().split())
    if abs(b)+abs(c)>a or (a+b+c)%2==1:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

ans = True

for i in range(len(l)):
    time = l[i][0]
    x = l[i][1]
    y = l[i][2]
    dist = x + y
    if not ((dist <= time) & ((time - dist) % 2 == 0)):
        ans = False
print("Yes") if ans else print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C
import copy
n = int(input())
preX = [0,0,0]
ans = True
for i in range(n):
    curX = list(map(int, input().split()))
    dt = curX[0] - preX[0]
    dx = abs(curX[1] - preX[1])
    dy = abs(curX[2] - preX[2])
    if dt < dx + dy  or (dt % 2) != ((dx + dy) % 2):
        ans = False
    preX = copy.copy(curX)
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

ans = "Yes"
for _ in range(N):
  t, x, y = map(int,input().split())
  if((t+x+y)%2 == 1 or t < x+y):
    ans = "No"
    break
print(ans)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    ans = 'Yes'
    t0, x0, y0 = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        move = abs(x - x0) + abs(y - y0)
        time = t - t0
        if time >= move and (time - move) % 2 == 0:
            t0, x0, y0 = t, x, y
        else:
            ans = 'No'
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
t = [0 for i in range(N)]
x = [0 for i in range(N)]
y = [0 for i in range(N)]
for i in range(N):
    t[i], x[i], y[i] = map(int, input().split())
t.insert(0,0)
x.insert(0,0)
y.insert(0,0)
flag = True
for i in range(1, N + 1):
    dist = abs(t[i] - t[i-1]) - abs(x[i] - x[i-1]) - abs(y[i] - y[i-1])
    if dist < 0 or dist % 2 != 0:
        flag = False
        break
print("Yes") if flag else print("No")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    pt, px, py = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        tmp = t - pt - (abs(x-px) + abs(y-py))
        if tmp < 0 or tmp % 2 == 1:
            print("No")
            return
        pt, px, py = t, x, y
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(1,len(t)):
    dt = abs(t[i][0]-t[i-1][0])
    dx = abs(t[i][1]-t[i-1][1])
    dy = abs(t[i][2]-t[i-1][2])
    if not dx+dy<=dt or not (dx+dy)%2==dt%2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
t1 = x1 = y1 = 0
for t2, x2, y2 in L:
    t = t2 - t1
    x = abs(x2 - x1)
    y = abs(y2 - y1)
    if x + y > t:
        print("No")
        break
    if (t - (x + y)) % 2 != 0:
        print("No")
        break
    t1 = t2
    x1 = x2
    y1 = y2
else:
    print("Yes")

Submission status: Accepted

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

h,j,k = 0,0,0

for i in range(n):
    t = abs(h - a[i][0])
    dx = abs(j - a[i][1])
    dy = abs(k - a[i][2])
    if t >= dx + dy:
        if t % 2 != (dx + dy) % 2:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
    h = a[i][0]
    j = a[i][1]
    k = a[i][2]
print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin

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

for i in range(n):
    if (d[i][1] + d[i][2]) > d[i][0] or (d[i][1] + d[i][2] + d[i][0]) % 2 == 1:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
t=[0 for i in range(n)]
x=[0 for i in range(n)]
y=[0 for i in range(n)]
for i in range(n):
    t[i],x[i],y[i]=list(map(int,input().split(" ")))
t.insert(0,0)
x.insert(0,0)
y.insert(0,0)
for i in range(n):
    abx=abs(x[i]-x[i+1])
    aby=abs(y[i]-y[i+1])
    if abx+aby>t[i+1]-t[i] or (abs(x[i+1])+abs(y[i+1]))%2!=t[i+1]%2:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
bt, bx, by = 0, 0, 0
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())
    if ((t % 2 == 0 and (x + y) % 2 == 0) or (t % 2 == 1 and (x + y) % 2 == 1)) and (abs(x - bx) + abs(y - by) <= t - bt):
        bt, bx, by = t, x, y
        continue
    else:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

Solution code:
def traveling(n, m):
    t = range(1, n+1)
    for i in t:
        tdif = m[i][0] - m[i-1][0]
        xydif = abs(m[i][1] - m[i-1][1]) + abs(m[i][2] - m[i-1][2])
        if tdif < xydif:
            return 'No'
        else:
            if tdif%2 != xydif%2:
                return 'No'
    return 'Yes'
N = int(input())
deer = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]
print(traveling(N, deer))

Submission status: Accepted

Solution code:
import sys
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
data = [[int(i) for i in l] for l in data]
data.insert(0, [0, 0, 0])
for i, l in enumerate(data):
    if i == 0:
        continue
    distance = abs(l[1]-data[i-1][1])+abs(l[2]-data[i-1][2])
    step_diff = l[0]-data[i-1][0]
    if step_diff%2 == distance%2 and distance <= step_diff:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
plan = [tuple(map(int, input().split())) for _ in range(n)]
plan = [(0, 0, 0)] + plan
for i in range(n):
    ct, cx, cy = plan[i]
    nt, nx, ny = plan[i+1]
    t = nt - ct
    x = nx - cx
    y = ny - cy
    if abs(x) + abs(y) > t or (abs(x) + abs(y) - t) % 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N = ri()
ans = 1
t,x,y=0,0,0
for i in range(N):
    t_,x_,y_=rl()
    if t_%2 != (x_+y_)%2:
        ans = 0
    if (t_ - t) < abs(x_-x)+abs(y_-y):
        ans = 0
    t,x,y=t_,x_,y_

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)

def dist(start,goal):
    return abs(start[0]-goal[0])+abs(start[1]-goal[1])

n=int(input())
T=[0]
XY=[[0,0]]
for _ in range(n):
    t,x,y=map(int,input().split())
    T.append(t)
    XY.append([x,y])
for i in range(n):
    dxy=dist(XY[i],XY[i+1])
    dt=T[i+1]-T[i]
    if dxy>dt or dxy%2!=dt%2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
def traveling(n, m):
    t = range(1, len(m))
    for i in t:
        xdif = abs(m[i][1]-m[i-1][1])
        ydif = abs(m[i][2]-m[i-1][2])
        tdif = m[i][0]-m[i-1][0]
        dif = xdif+ydif
        if tdif < dif:
            return 'No'
        elif (tdif > dif) and (((tdif - dif) % 2) != 0):
            return 'No'
    return 'Yes'
N = int(input())
deer = [list(map(int, input().split())) for i in range(N)]
deer.insert(0, [0,0,0])
print(traveling(N, deer))

Submission status: Accepted

Solution code:
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
 
now_x = 0
now_y = 0
now_time = 0
for x in L:
    if x[0] % 2 != (x[1] + x[2]) % 2:
        print("No")
        quit()
    if abs(now_x-x[1]) + abs(now_y-x[2]) > x[0] - now_time:
        print("No")
        quit()
    now_time = x[0]
    now_x = x[1]
    now_y = x[2]
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t = []
x = []
y = []
t_b = 0
x_b = 0
y_b = 0
flag = 0
for i in range(n):
    t_a,x_a,y_a = map(int,input().split())
    t_d = t_a - t_b
    if x_a - x_b + y_a - y_b == t_a - t_b:
        t_b = t_a
        x_b = x_a
        y_b = y_a
    elif (t_a - t_b) - (x_a - x_b + y_a - y_b) > 0 and ((t_a - t_b) - (x_a - x_b + y_a - y_b))%2 == 0:
        t_b = t_a
        x_b = x_a
        y_b = y_a
    else:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
array_t = []
array_x = []
array_y = []
for i in range(N):
    t,x,y = map(int, input().split(" "))
    array_t.append(t)
    array_x.append(x)
    array_y.append(y)
flag = True
for i in range(N):
    if i ==0:
        added = abs(array_x[0])+abs(array_y[0])
        gap = array_t[0] - added
    else:
        added = abs(array_x[i]-array_x[i-1])+abs(array_y[i]-array_y[i-1])
        gap = array_t[i]-array_t[i-1] - added
    if gap>=0 and gap%2 == 0:
        continue
    else:
        print('No')
        flag = False
        break
if flag:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
routes = [(0,0,0)]
append = routes.append
for _ in range(0, N):
    t, x, y = map(int, input().split())
    append((t, x, y))
for i in range(1, N+1):
    bt, bx, by = routes[i-1]
    t, x, y = routes[i]
    ct = t - bt
    # xだけで考える。yとxは独立させて考えて問題ない。両方が成立しなければ成立しないため。
    cx = abs(x - bx)
    cy = abs(y - by)
    if cx > ct or cy > ct:
        print ("No")
        exit()
    if (cx+cy) % 2 != ct % 2:
        print ("No")
        exit()
print ("Yes")

Submission status: Accepted

Solution code:
n = int(input())
flag = True
for _ in range(n):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2==1:
        flag = False


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

Submission status: Accepted

Solution code:
N = int( input() )

isTravel = True
t, x, y = 0, 0, 0
for i in range( N ):
    ti, xi, yi = map( int, input().split() )
    if abs(xi-x)+abs(yi-y) > ti-t or (abs(xi-x)+abs(yi-y)) % 2 != (ti-t) % 2:
        isTravel = False
    t, x, y = ti, xi, yi

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

Submission status: Accepted

Solution code:
n=int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l.insert(0,[0,0,0])
can = True
for i in range(len(l)-1):
    dt = l[i+1][0] - l[i][0]
    dist = abs(l[i+1][1] - l[i][1]) + abs(l[i+1][2]-l[i][2])
    if dt < dist:
        can = False
        break
    if dist % 2 != dt % 2:
        can = False
        break
print('Yes') if can else print('No')

Submission status: Accepted

Solution code:
n=int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l.insert(0,[0,0,0])
can = True
for i in range(len(l)-1):
    dt = l[i+1][0] - l[i][0]
    dist = abs(l[i+1][1] - l[i][1]) + abs(l[i+1][2]-l[i][2])
    if dt < dist:
        can = False
        break
    if dist % 2 != dt % 2:
        can = False
print('Yes') if can else print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 28 18:15:06 2019

@author: yuta
"""

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

def main(p):
    count = 0
    for i in range(len(p)):
        t = p[i][0]
        sum_xy = p[i][1] + p[i][2]
        if t % 2 == 0:
            if sum_xy <= t and sum_xy % 2 == 0:
                count += 1
        else:
            if sum_xy <= t and sum_xy % 2 != 0:
                count += 1
    if count == len(p):
        print("Yes")
    else:
        print("No")

main(place)

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())
    X = abs(x_ - x)
    Y = abs(y_ - y)
    T = t_ - t
    if ( X + Y > T ) or (T % 2 != ( X + Y ) % 2):
        print("No")
        exit()
    t = t_
    x = x_
    y = y_
print("Yes")

Submission status: Accepted

Solution code:
import sys
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
    ti, xi, yi = map(int, input().split())
    if ti - t < abs(xi - x) + abs(yi - y) or not (abs(xi - x) + abs(yi - y) + ti - t )% 2 ==0:
        print("No")
        exit()
    else:
        t, x, y = ti, xi, yi
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())

t,x,y=0,0,0
s=0

for i in range(N):
    tn,xn,yn=map(int,input().split())
    
    if ((tn-t)-(xn-x+yn-y))%2==1 or ((tn-t)-(xn-x+yn-y))<0:
        s=1

if s==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

no = 0
for i in range(1,n+1):
    if (A[i][0]-A[i-1][0])%2 != (abs(A[i][1]-A[i-1][1]) + abs(A[i][2]-A[i-1][2]))%2 :
        no = 1
    elif A[i][0]-A[i-1][0] < abs(A[i][1]-A[i-1][1]) + abs(A[i][2]-A[i-1][2]) :
        no = 1
if no == 1 :
    print("No")
else :
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

now = 0
x, y = 0, 0
flag = True

for _ in range(n):
    t, x_target, y_target = map(int, input().split())

    distance = abs(x_target - x) + abs(y_target - y)
    duration = t - now

    if distance > duration:
        flag = False
        break
    
    elif distance % 2 != duration % 2:
        flag = False

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

Submission status: Accepted

Solution code:
n = float(input())
a = []
a.append([0,0,0])
for i in range(int(n)):
    in1, in2, in3 = map(float, input().split())
    a.append([in1,in2,in3])

for j in range(int(n)):
    i = j+1
    point_dif = abs(a[i][1]-a[i-1][1]) + abs(a[i][2] - a[i-1][2])
    time_dif = a[i][0]-a[i-1][0]
    if time_dif %2 != point_dif % 2:
        print('No')
        exit()
    if point_dif > time_dif:
        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())
for i in range(n):
    t,x,y=map(int,input().split())
    if (x+y)>t or (x+y)%2 != t%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 not((x+y)<=t and (x+y)%2 == t%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(not((x+y)<=t and (x+y)%2 == t%2)):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
#ABC086C
N=int(input())
txy=[[0,0,0]]
for n in range(N):
	txy.append(list(map(int,input().split())))
for n in range(N):
	tt=txy[n+1][0]-txy[n][0]
	xy=abs(txy[n+1][1]-txy[n][1])+abs(txy[n+1][2]-txy[n][2])
	if tt>=xy:
		if (xy-tt)%2==0:
			continue
	print('No')
	exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

if __name__ == "__main__":
    N = int(input())
    x = 0
    y = 0
    t = 0
    flag = True
    for i in range(N):
        ti, xi, yi = [int(i) for i in input().split()]
        d = abs(xi - x) + abs(yi - y)

        if flag and (ti - t) >= d and ((ti - t) - d) % 2 == 0:
            t = ti
            x = xi
            y = yi
        else:
            flag = False
    print("Yes" if flag else "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())
mx = [i for i in [input().split() for _ in range(n)]]
for i in range(n):
    mx[i] = [int(h) for h in mx[i]]
current_point = [0, 0, 0]
distance = [0, 0, 0]
canArriveAt = True
for p in mx:
    next_point = p
    for i in range(3):
        distance[i] = next_point[i] - current_point[i]
    if distance[0]%2 == (abs(distance[1])+abs(distance[2]))%2 and distance[0] >= abs(distance[1])+abs(distance[2]):
        current_point = next_point
    else:
        canArriveAt = False
print("Yes" if canArriveAt == True else "No")

Submission status: Accepted

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

flag=True

for i in range(0,N):
  dt=A[i+1][0]-A[i][0]
  dx=abs(A[i+1][1]-A[i][1])
  dy=abs(A[i+1][2]-A[i][2])
  if not (dx+dy<=dt and (dx+dy-dt)%2==0):
    flag=False
    break
    
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Traveling
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    t.insert(0, 0)
    x.insert(0, 0)
    y.insert(0, 0)
    print(trabelable(N, t, x, y))

def trabelable(N, t, x, y):
    for i in range(N):
        delta_t = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        if delta_t < dist:
            return NO
        if delta_t % 2 != dist % 2:
            return NO
    return YES

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, t, x, y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
ans='Yes'
for i in range(n):
  t,x,y=map(int,input().split())
  if x+y<=t:
    if t%2==(x+y)%2:
      continue
    else:
      ans='No'
  else:
    ans='No'
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
  A.append([a,b,c])
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
switch = 0
for li in L:
    t = li[0]
    co = li[1]+li[2]
    if t >= co:
        if co % 2 == 0 and t % 2 == 0:
            pass
        elif co % 2 != 0 and t % 2 != 0:
            pass
        else:
            switch += 1
            break
    else:
        switch += 1
        break
if switch == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    t = []
    x = []
    y = []

    for _ in range(n):
        ti, xi, yi = map(int, input().split())
        t.append(ti)
        x.append(xi)
        y.append(yi)
    
    if solve(n, t, x, y):
        print('Yes')
    else:
        print('No')

def solve(n, t, x, y):
    cur_t, cur_x, cur_y = 0, 0, 0

    for i in range(n):
        if t[i] % 2 != (x[i] + y[i]) % 2:
            return False
        
        if abs(x[i] - cur_x) + abs(y[i] - cur_y) > t[i] - cur_t:
            return False

    return True
        
main()

Submission status: Accepted

Solution code:
n = int(input())
plan_list = list()
#最初に0,0の座標を定義しなさい
plan_list.append([0,0,0])

for i in range(n):
    plan_list.append(list(map(int,input().split())))
    
for i in range(n):
    t_margin = abs(plan_list[i+1][0] - plan_list[i][0])
    x_margin = abs(plan_list[i+1][1] - plan_list[i][1])
    y_margin = abs(plan_list[i+1][2] - plan_list[i][2])
    xy_margin = x_margin + y_margin
    if t_margin < xy_margin or xy_margin % 2 != t_margin % 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

n = int(input())

ls = [[0, 0, 0]]

for i in range(n):
    temp = input_numbers()
    ls += [temp]

ls.sort(key = lambda x:x[0])

for i in range(1, n + 1):
    dis = abs(ls[i][1] - ls[i - 1][1]) + abs(ls[i][2] - ls[i - 1][2])
    time = abs(ls[i][0] - ls[i - 1][0])

    flag = 0
    if(dis > time):
        flag = 1
    elif((time - dis) % 2 == 1):
        flag = 1
    
    if(flag == 1):
        print('No')
        break

if(flag == 0):
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = [IL() for i in range(N)]

t,x,y = 0,0,0
for i in range(N):
	ti,xi,yi = l[i]
	if 0 <= ti-t\
		and (ti-t -abs(xi-x)-abs(yi-y)) >= 0\
		and (ti-t -abs(xi-x)-abs(yi-y)) %2 == 0:
		t,x,y = ti,xi,yi
	else:
		print("No")
		exit()
print("Yes")

Submission status: Accepted

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

N = int(input())
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2:
        flag = False


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

Submission status: Accepted

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

class Deer:
    def __init__(self):
        self.x = 0
        self.y = 0
        self.t = 0

    def move(self, ti, xi, yi):
        time_interval = ti - self.t
        manhattan_distance = abs(xi - self.x) + abs(yi - self.y)
        val = time_interval - manhattan_distance
        if (val >= 0) and (val % 2 == 0):
            self.x = xi
            self.y = yi
            self.t = ti
            return True
        else:
            return False

AtCoDeer = Deer()
N = int(input())
flag = True
for _ in range(N):
    ti, xi, yi = map(int, input().split())
    flag = flag and AtCoDeer.move(ti, xi, yi)


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

Submission status: Accepted

Solution code:
N = int(input())
data_ls = list()
flg = 0
for i in range(N):
    data_ls.append([int(i) for i in input().split()])
t,x,y = zip(*data_ls)
data_ls = [(t[0], x[0], y[0])]
for i in range(len(t) - 1):
    data_ls.append((t[i+1] - t[i], x[i+1] - x[i], y[i+1] - y[i]))

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

for i in data_ls:
    result = detect_possible(i)
    if not result:
        flg += 1
        break

if flg > 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
ti, xi, yi = 0, 0, 0

ans = 'Yes'
for i in range(n):
  t, x, y = map(int, input().split())
  t_diff = t - ti
  x_diff = x - xi
  y_diff = y - yi
  dis_diff = abs(x_diff) + abs(y_diff)
  if not(t_diff >= dis_diff and t_diff % 2 == dis_diff % 2):
    ans = 'No'
    break
print(ans)