Problem:


Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.

If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

1 ≤ N ≤ 10^5

0 ≤ x_i ≤ 10^5

0 ≤ y_i ≤ 10^5

1 ≤ t_i ≤ 10^5

t_i < t_{i+1} (1 ≤ i ≤ N-1)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
t_1 x_1 y_1
t_2 x_2 y_2
:
t_N x_N y_N

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at (100,100) two seconds after being at (0,0).

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No



Sample input:
2
3 1 2
6 1 1


Sample output:
Yes

Submission status: Accepted

Solution code:
def canContinue(d, p):
    distance = abs(d[p][1] - d[p - 1][1]) + abs(d[p][2] - d[p - 1][2])
    if d[p][0] - d[p - 1][0] < distance:
        return False
    remaining_action = d[p][0] - d[p - 1][0] - distance
    if remaining_action % 2 == 0:
        return True
    else:
        return False

N = int(input())
d = []
d.append([0,0,0])
i = 0
while i < N:
    d.append(list(map(int, input().split())))
    i += 1
position = 1
answer = True
while position < N + 1:
    if canContinue(d, position):
        i += 1
    else:
        answer = False
        break
    position += 1
if answer:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s = (0, 0)
t = 0
success = True

for move in In:
    before_x, before_y = s
    tn, after_x, after_y = move

    dist_xy = abs(after_x - before_x) + abs(after_y - before_y)
    walk = tn - t

    if walk < dist_xy:
        success *= False
        break

    if walk % 2 == 0 and dist_xy % 2 != 0:
        success *= False
        break
    elif walk % 2 != 0 and dist_xy % 2 == 0:
        success *= False
        break

    s = (after_x, after_y)
    t = tn

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

Submission status: Accepted

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

s = (0, 0)
t = 0
success = True

for move in In:
    before_x, before_y = s
    tn, after_x, after_y = move

    dist_xy = abs(after_x - before_x) + abs(after_y - before_y)
    walk = tn - t

    if walk < dist_xy:
        success *= False

    if walk % 2 == 0 and dist_xy % 2 != 0:
        success *= False
    elif walk % 2 != 0 and dist_xy % 2 == 0:
        success *= False

    s = (after_x, after_y)
    t = tn

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

Submission status: Accepted

Solution code:
#入力
N = int(input())

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

i = 0
while i<N:
    
    a, b, c = map(int, input().split(" "))
    t.append(a)
    x.append(b)
    y.append(c)

    i += 1

    
#tの値と同数だけ判断基準2を通過すればよいので、それを判断するためのフラグを設定
flag_yes = 0
    
#判断基準1（t秒後の座標xとyを足した値が、そのtの値以下かどうか）
for (num_t, num_x, num_y) in zip(t, x, y):
    
    #フラグを設定
    flag = 0
    
    #座標xとyを足した値
    sum_xy = num_x + num_y
    
    #判定
    if num_t>=sum_xy:
        flag += 1
        
    #判断基準2（tが偶数(奇数)であれば、座標xとyを足した値も偶数(奇数)であるかどうか）
    if num_t%2==0 and sum_xy%2==0 and flag==1:
        flag_yes += 1
        
    elif num_t%2==1 and sum_xy%2==1 and flag==1:
        flag_yes += 1
        
#tの値とflag_yesの値が一致していれば"Yes"、それ以外は"No"
if len(t)==flag_yes:
    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:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  t = [0] * n
  x = [0] * n
  y = [0] * n
  for i in range(n):
    t[i], x[i], y[i] = map(int, input().strip().split())
  
  ct = 0
  cx = 0
  cy = 0
  for nt, nx, ny in zip(t, x, y):
    diff = abs(nx - cx) + abs(ny - cy)
    if diff > nt or (diff - (nt - ct)) % 2 == 1:
      print('No')
      return
    ct, cx, cy = nt, nx, ny
  print('Yes')


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n = int(input())
yo =[]
for i in range(n):
    yo.append(list(map(int,input().split())))
now =[0, 0, 0]
for i in range(n):
    c = yo[i][0] - now[0]-(abs(yo[i][1]-now[1]) + abs(yo[i][2]-now[2]))
    if c >= 0 and c%2 == 0:
        now =yo[i]
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
A = []
A.append([0, 0, 0])
for i in range(n):
    A.append([int(i) for i in input().split()])
ans = 'Yes'

for i in range(n):
    dist = abs(A[i][1] - A[i + 1][1]) + abs(A[i][2] - A[i + 1][2])
    if (A[i + 1][0] - A[i][0])  < dist:
        ans = 'No'
        break
    if ((A[i + 1][0] - A[i][0]) - dist) % 2 == 1:
        ans = 'No'
        break
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
txy = []
for i in range(n):
    txy.append(list(map(int,input().split())))
ok = True
for i in range(n):
    if i == 0 : 
        if txy[0][0] < txy[0][1] + txy[0][2] or (txy[0][0] - txy[0][1] + txy[0][2])%2 != 0 :
            ok = False
    else:
        time = txy[i][0] - txy[i-1][0]
        dis = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
        if time < dis or (time-dis)%2 != 0:
            ok = False

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

Submission status: Accepted

Solution code:
n = int(input())
p,q = 0,0
ans = 'Yes'
for i in range(n):
    t,x,y = map(int,input().split())
    if not(x-p+y-q <= t and (x-p+y-q-t)%2 == 0):
        ans = 'No'
        break
print(ans)

Submission status: Accepted

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

def main():
    N = int(input())
    ta = []
    xa = []
    ya = []
    for i in range(N):
        sa = input().split(' ')
        ta.append(int(sa[0]))
        xa.append(int(sa[1]))
        ya.append(int(sa[2]))

    can_travel = True
    t = 0
    x = 0
    y = 0
    for i in range(N):
        if (ta[i] + xa[i] + ya[i]) % 2 != 0:
            can_travel = False
            break
        if ta[i] - t < abs(xa[i] - x) + abs(ya[i] - y):
            can_travel = False
            break
        t = ta[i]
        x = xa[i]
        y = ya[i]


    print('Yes' if can_travel else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
t_list = []
x_list = []
y_list = []
position = [0,0]
time = 0
count = 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)
for i in range(n):
    if abs(x_list[i]-position[0]) + abs(y_list[i]-position[1]) == t_list[i]-time:
        time = t_list[i]
        position = [x_list[i],y_list[i]]
        count += 1
    elif abs(x_list[i]-position[0]) + abs(y_list[i]-position[1]) < t_list[i]-time and ((t_list[i]-time)-(abs(x_list[i]-position[0])+abs(y_list[i]-position[1]))) % 2 == 0:
        time = t_list[i]
        position = [x_list[i],y_list[i]]
        count += 1
    else:
        print('No')
        break
if count == n:
    print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
a = [[]*N]*N
for i in range(N):
    a[i]=input().rstrip().split()

#x+y > tの時は到達不可能
#x+yの偶奇とtが一致してなければ無理

bool = True


for i in range(0,N):
    if bool==False:
        break

    p=int(a[i][1])+int(a[i][2])
    q=int(a[i][0])
    if p>q:
        bool=False
    if p%2==0:
        if q%2!=0:
            bool=False
    else:
        if q%2==0:
            bool=False
        

if bool==True:
    print('Yes')

if bool==False:
    print('No')

Submission status: Accepted

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

    for i in range(n):
        if abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > (t[i + 1] - t[i]) or \
                abs(abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) - (t[i + 1] - t[i])) % 2 == 1:
            print("No")
            return 0
    print("Yes")


abc086_c()

Submission status: Accepted

Solution code:
N = int(input())

ans="Yes"
ta = xa = ya = 0
for i in range(N):
    tb, xb, yb = map(int, input().split())
    sa = tb-ta-(abs(xb-xa)+abs(yb-ya))
    if (sa>=0)&(sa%2==0):
        continue
    else:
        ans="No"
        break
    
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 18:54:37 2018
ABC086
@author: maezawa
"""

n = int(input())
tarr = []
xarr = []
yarr = []
for _ in range(n):
    t, x, y = list(map(int, input().split()))
    tarr.append(t)
    xarr.append(x)
    yarr.append(y)

is_ok = True
x0 = 0
y0 = 0
t0 = 0
for i in range(n):
    xi = xarr[i]
    yi = yarr[i]
    ti = tarr[i] - t0
    d = abs(xi-x0) + abs(yi-y0)
    if d > ti:
        is_ok = False
        break
    if ti % 2 == 1 and d % 2 == 0:
        is_ok = False
        break
    if ti % 2 == 0 and d % 2 == 1:
        is_ok = False
        break
    x0 = xi
    y0 = yi
    t0 = tarr[i]
    
if is_ok:
    print('Yes')
else:
    print('No')

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:
    d = abs(nx-x) + abs(ny-y)
    if d <= t-nt and (t-nt)%2 == d%2:
        nt,nx,ny = t,x,y
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    table = [list(map(int, input().split())) for _ in range(n)]
    ct = cy = cx = 0
    for t, x, y in table:
        dist = abs(y - cy) + abs(x - cx)
        time = t - ct
        if dist > time or (time - dist) % 2 != 0:
            print('No')
            return
        ct = t
        cy = y
        cx = x
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
t = [0]
x = [0]
y = [0]
for a in range(1,N+1):
    S = list(map(int,input().split()))
    t.append(S[0])
    x.append(S[1])
    y.append(S[2])
for b in range(0,N):
    t_dist = t[b+1] - t[b]
    x_dist = x[b+1] - x[b]
    y_dist = y[b+1] - y[b]
    step = abs(x_dist) + abs(y_dist)
    if t_dist - step >= 0 and (t_dist - step)%2 ==0:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

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 (x+y+t)%2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

def check(t, x, y):
    if t < (x + y):
        return False
    if t % 2 != (x+y) % 2:
        return False
    return True


ok = True
for t, x, y  in data:
    if not check(t, x, y):
        ok = False
        break
print('Yes') if ok else print('No')

Submission status: Accepted

Solution code:
n=int(input())
#print(n)
flag=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if t < x+y or (t+x+y)%2 == 1:
    flag=1
print('Yes' if flag==0 else 'No')

Submission status: Accepted

Solution code:
N = int(input().strip())

prevt, prevx, prevy = 0, 0, 0
t = True
for n in range(N):
  t, x, y = map(int, input().strip().split())
  if t - prevt >= abs(x-prevx) + abs(y-prevy) and (t-prevt) % 2 == (abs(x-prevx) + abs(y-prevy)) % 2:
    prevt, prevx, prevy = t, x, y
  else:
    t = False
    break

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

Submission status: Accepted

Solution code:
N = int(input())
L = [input() for i in range(N)]
for l in L:
  t, x, y = map(int, l.split(" "))
  flag_t = t %2 == 0
  flag_xy = (x+y) % 2 == 0
  if flag_t == flag_xy and (x+y) <= t:
    continue
  else:
    print("No")
    exit(0)
print("Yes")

Submission status: Accepted

Solution code:
import sys
input()
pt, px, py = 0, 0, 0
for ct, cx, cy in [map(int, e.split()) for e in sys.stdin]:
    d = (ct - pt) - abs(cx - px) - abs(cy - py)
    if d < 0 or d % 2 == 1:
        print('No')
        break
    pt, px, py = ct, cx, cy
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
input()
pt, px, py = 0, 0, 0
for e in sys.stdin:
    ct, cx, cy = map(int, e.split())
    d = (ct - pt) - abs(cx - px) - abs(cy - py)
    if d < 0 or d % 2 == 1:
        print('No')
        break
    pt, px, py = ct, cx, cy
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
input()
e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]
for (t0, a0, b0), (t1, a1, b1) in zip(e, e[1:]):
    d = (t1 - t0) - abs(a1 - a0) - abs(b1 - b0)
    if d < 0 or d % 2 == 1:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
input()
for e in sys.stdin:
    t, x, y = map(int, e.split())
    d = t - (x + y)
    if d < 0 or d % 2 == 1:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
flag = 1
for i in a:
    if i[0] < i[1] + i[2]:
        flag = 0
    elif i[0] % 2 != (i[1] + i[2]) % 2:
        flag = 0
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
L = [[0, 0, 0]] + [[int(i) for i in input().split()] for _ in range(N)]
YN = "Yes"
for i in range(N):
    a = (L[i + 1][0] - L[i][0])
    b = (abs(L[i + 1][1] - L[i][1]) + abs(L[i + 1][2] - L[i][2]))
    if b > a:
        YN = "No"
        break
    if a % 2 == 0 and b % 2 != 0:
        YN = "No"
        break
    if a % 2 != 0 and b % 2 == 0:
        YN = "No"
        break
print(YN)

Submission status: Accepted

Solution code:
n = int(input())
l = [input().split() for _ in range(n)]
ot = ox = oy = 0
can = True
for (t, x, y) in l:
    dt = int(t) - ot
    dist = abs(int(x) - ox) + abs(int(y) - oy)
    if dt < dist:
        can = False
    if (dist % 2 != dt % 2):
        can = False
    ox = int(x)
    oy = int(y)
    ot = int(t)

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

Submission status: Accepted

Solution code:
def movement(x0, y0 , t, x1, y1) :
    total = abs(x1 - x0) + abs(y1 - y0)
    if total <= t and (t - total) % 2 == 0 :
        return "Yes"
    else :
        return "No"

n = int(input())
plan = []
x0, y0 = 0, 0


for i in range(n) :
    plan.append(list(map(int, input().split(" "))))

for i in range(1,n) :
    plan[n-i][0] -= plan[n-1-i][0]

for i in range(n) :
    judge = movement(x0, y0, plan[i][0], plan[i][1], plan[i][2])
    if judge == "Yes" :
        x0, y0 = plan[i][1], plan[i][2]
    else :
        print(judge)
        break

if x0 == plan[n-1][1] and y0 == plan[n-1][2] :
    print("Yes")

Submission status: Accepted

Solution code:
# Traveling
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:
import sys
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if (t >= x + y) & ((t - (x + y)) % 2 == 0):
        continue
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    in_t, in_x, in_y = map(int, input().split())
    t = in_t - t
    x = abs(in_x - x)
    y = abs(in_y - y)
    if (t >= x + y) & ((t - (x + y)) % 2 == 0):
        continue
    print('No')
    sys.exit()
print('Yes')

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])
if n==1:
  print("Yes")
  exit()
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:
import sys
n=int(input())
tmp_t=0
dist=0
for i in range(n):
    a,b,c=map(int,input().split())
    if i==0:
        if (b+c)%2==0 and a%2==0 and a>=(b+c) or (b+c)%2!=0 and a%2!=0 and a>=(b+c):
            tmp_t=a
            dist=b+c
        else:
            print("No")
            sys.exit()
    else:
        if abs((dist-(b+c)))%2==0 and (a-tmp_t)%2==0 and (a-tmp_t)>=(dist-(b+c)) or abs((dist-(b+c)))%2!=0 and (a-tmp_t)%2!=0 and (a-tmp_t)>=(dist-(b+c)):
            tmp_t=a
            dist=b+c
        else:
            print("No")
            sys.exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    n = int(input())

    flag = 0
    t, x, y = 0, 0, 0
    for i in range(n):
        newt, newx, newy = map(int, input().split())

        dift, difx, dify = newt - t, abs(newx - x), abs(newy - y)

        val = difx + dify
        if val > dift:
            flag = 1
            print("No")
            break
        if val % 2 != dift % 2:
            flag = 1
            print("No")
            break

        t, x, y = newt, newx, newy

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

Submission status: Accepted

Solution code:
n = int(input())
lattice_point = [[0,0,0]]
count = 0

for i in range(n):
    lattice_point.append(list(map(int, input().split())))

for i in range(n):
    min_distance = abs(lattice_point[i][1]-lattice_point[i+1][1]) + abs(lattice_point[i][2]-lattice_point[i+1][2])
    time_limit = lattice_point[i+1][0] - lattice_point[i][0]
    if  time_limit < min_distance or time_limit%2 != min_distance%2:
        print('No')
        break
    else:
        count += 1

if count == n:
    print('Yes')

Submission status: Accepted

Solution code:
t=[0]
x=[0]
y=[0]
N=int(input())
for i in range(N):
    a,b,c=list(map(int,input().split()))
    t.append(a)
    x.append(b)
    y.append(c)
    
def cal(x_0,x_1,y_0,y_1,t_0,t_1):
    dis=abs(x_1-x_0)+abs(y_1-y_0)
    T=t_1-t_0
    if(T>=dis and abs(T-dis)%2==0):
        return 1
    return 0

for i in range(N):
    if(cal(x[i],x[i+1],y[i],y[i+1],t[i],t[i+1])==0):
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
# encoding: utf-8
import math, sys

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

ans = "No"
x = y = 0
t_prev = 0
for ti, xi, yi in txy:
    dist = math.fabs(x - xi) + math.fabs(y - yi)
    if ti - t_prev < dist: break
    elif (ti - t_prev) % 2 != dist % 2: break
    else:
        x = xi
        y = yi
        t_prev = ti
else:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
prev = [0, [0, 0]]  # [t, [x, y]]
for i in range(n):
    # print(prev)
    t, x, y = [int(i) for i in input().split()]
    left = (t - prev[0]) - (abs(x - prev[1][0]) + abs(y - prev[1][1]))
    # print("left:{}".format(left))
    if left >= 0 and left % 2 == 0:
        prev = [t, [x, y]]
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
c=0
for j in range(n):
  if l[j+1][0]-l[j][0]<abs(l[j+1][1]-l[j][1])+abs(l[j+1][2]-l[j][2]) or (l[j+1][0]-l[j][0]+abs(l[j+1][1]-l[j][1])+abs(l[j+1][2]-l[j][2]))%2==1:
    c=1
    break
if c==0:print('Yes')
else:print('No')

Submission status: Accepted

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

can = True
for i in range(N):
    dt, dist = 0, 0
    dt = points[i + 1][0] - points[i][0]
    dist = abs(points[i + 1][1] - points[i][1]) + abs(points[i + 1][2] - points[i][2])
    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())
txy = [0]*(N+1)
txy[0] = [0, 0, 0]
for i in range(1, N + 1):
    txy[i] = [int(i) for i in input().split()]

for i in range(1, N + 1):
    dis = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
    time = txy[i][0] - txy[i-1][0]
    if time < dis or (time - dis) % 2 != 0:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

if a[0][0] < (a[0][1] + a[0][2]):
    print("No")
    sys.exit()
if a[0][0]%2 != (a[0][1]+a[0][2])%2:
    print("No")
    sys.exit()
if n==1 and a[0][0]%2 == (a[0][1]+a[0][2])%2:
    print("Yes")
    sys.exit()

# n>=2
for i in range(1, n):
    if (a[i][0] - a[i-1][0]) < (abs(a[i][1]-a[i-1][1]) + abs(a[i][2]-a[i-1][2])):
        print("No")
        sys.exit()
    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:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:

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

flag = False

for i in range(N):
    c = path[i]
    n = path[i+1]

    time_delta = n[0] - c[0]
    abs_distance = abs(n[1] - c[1]) + abs(n[2] - c[2])
    if abs_distance > time_delta:
        flag = True
        break
    else:
        if abs_distance%2 == 0 and time_delta%2 == 0:
            pass
        elif abs_distance%2 == 1 and time_delta%2 == 1:
            pass
        else:
            flag = True
            break

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

Submission status: Accepted

Solution code:
N=int(input())
T=[[int(j) for j in input().split()] for i in range(N)]
m=0
T.reverse()
T.append([0,0,0])
T.reverse()
for i in range(N):
    l_i=T[i][1]+T[i][2]
    l_iadd=T[i+1][1]+T[i+1][2]
    t_iadd_i=T[i+1][0]-T[i][0]
    l=t_iadd_i-l_iadd+l_i
    mod=l%2
    if l>=0:
        if mod==0:
            m+=1
        else:
            break
    else:
        break
if m==N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    if t%2!=0 and (x+y)%2!=0 and x+y<=t:
        cnt += 1
    elif t%2==0 and (x+y)%2==0 and x+y<=t:
        cnt += 1
    else:
        break

if cnt == n:
    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:
    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 != 0: # (xi,yi)という値は様々な値を動きますが
                                          # xi+yi は毎秒ごとに必ず偶奇が入れ替わることがわかります
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
atime,ax,ay = 0,0,0
for i in range(N):
    btime,bx,by = map(int,input().split(" "))
    distance = abs(bx-ax)+abs(by-ay)
    time = btime-atime
    if (time >= distance)and((time-distance)%2 == 0):
        ax = bx
        ay = by
        atime = btime
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def traveling():
    n = int(input())
    t, x, y = [0], [0], [0]

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

    can = True

    for i in range(n):
        dt = t[i+1] -t[i]
        distance = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])

        if dt < distance or distance % 2 != dt % 2:
            can = False

    return "Yes" if can else "No"


if __name__ == '__main__':
    print(traveling())

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(-s[i][1] - s[i][0] <= s[i][2] <= -s[i][1] + s[i][0] and s[i][1] - s[i][0] <= s[i][2] <= s[i][1] + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(-s[i][1] + s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= -s[i][1] + s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])\
            and s[i][1] - s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i][1] - s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(0 - s[i][0] <= s[i][1] <= 0 + s[i][0]) or not(0 - s[i][0] <= s[i][2] <= 0 + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(s[i - 1][1] - (s[i][0] - s[i - 1][0]) <= s[i][1] <= s[i - 1][1] + (s[i][0] - s[i - 1][0])) or not(s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t, x, y, ok = 0, 0, 0, True
for _ in range(n):
    t2, x2, y2 = map(int, input().split())
    dt = t2 - t
    delta = abs(x - x2) + abs(y - y2)
    if delta > dt:
        ok = False
    elif (delta - dt) % 2:
        ok = False
    t, x, y = t2, x2, y2
print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
import sys

n=int(input())

b_t=0
b_x=0
b_y=0
for _ in range(n):
    t,x,y=map(int,input().split())
    tmp= ( t - b_t) - abs(x - b_x) - abs( y - b_y )
    if( tmp % 2 != 0 or tmp <0):
        print( "No" )
        sys.exit()
    b_t,b_x,b_y=t,x,y

print("Yes")

Submission status: Accepted

Solution code:
import copy

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
s=copy.deepcopy(l)
l.insert(0,[0,0,0])
for i in range(1,n+1):
    s[i-1][0]=l[i][0]-l[i-1][0]
    s[i-1][1]=l[i][1]-l[i-1][1]
    s[i-1][2]=l[i][2]-l[i-1][2]
    #print(s)
    if s[i-1][0]<abs(s[i-1][1])+abs(s[i-1][2]) or (s[i-1][0])%2!=(abs(s[i-1][1])+abs(s[i-1][2]))%2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

flag = True
t0 = x0 = y0 = 0
for i in range(N):
    t1, x1, y1 = map(int, input().split())
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    if (abs(x) + abs(y)) == 0:
        if t % 2 == 0: pass
    elif t % (abs(x) + abs(y)) != 0:
        flag = False
    t0 = t1
    x0 = x1
    y0 = y1

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

Submission status: Accepted

Solution code:

import sys

def 解():
    def isNotValid(dt,dx,dy):
        iD = dx+dy
        if dt % 2 : #奇数
            if iD % 2 and iD <= dt:
                return False
            else:
                return True
        else: #偶数
            if iD % 2 == 0 and iD <= dt:
                return False
            else:
                return True
    iN = int(input())
    bt,bx,by =0, 0,0
    for t,x,y in [[int(_) for _ in sLine.split()] for sLine in  sys.stdin.readlines()]:
        if isNotValid(t-bt,abs(x-bx),abs(y-by)):
            print("No")
            exit()
        bt,bx,by = t, x,y
    print("Yes")
解()

Submission status: Accepted

Solution code:
import sys

def isValid(dt,dx,dy):
    iD = dx+dy
    if dt % 2 : #奇数
        if iD % 2 and iD <= dt:
            return True
        else:
            return False
    else: #偶数
        if iD % 2 == 0 and iD <= dt:
            return True
        else:
            return False
def 解():
    iN = int(input())
    bt,bx,by =0, 0,0
    for t,x,y in [[int(_) for _ in sLine.split()] for sLine in  sys.stdin.readlines()]:
        if not isValid(t-bt,x-bx,y-by):
            print("No")
            exit()
        bt,bx,by = t, x,y
    print("Yes")
解()

Submission status: Accepted

Solution code:
n = int(input())
t_c,x_c,y_c = 0,0,0

for i in range(n):
    t,x,y = map(int,input().split())
    dt, dx, dy = t-t_c, abs(x-x_c), abs(y-y_c)
    dd = dx + dy
    if dd > dt or dd % 2 != dt % 2:
        print('No')
        exit()
    else:
        t_c,x_c,y_c = t,x,y

print('Yes')

Submission status: Accepted

Solution code:
N=int(input())

T=0
X=0
Y=0

for j in range(N):
    t,x,y=map(int,input().split())
    
    if (t-T)>=abs(X-x)+abs(Y-y):
        if ((t-T)-(abs(X-x)+abs(Y-y)))%2==0:
            pass
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
    T=t
    X=x
    Y=y
print("Yes")

Submission status: Accepted

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

tmpx = 0
tmpy = 0
tmpt = 0
for _ in range(n):
    (t, x, y) = map(int, input().split())
    dist = abs(tmpx - x) + abs(tmpy - y)
    splt = t - tmpt
    if splt < dist:
        print('No')
        sys.exit(0)
    if (splt - dist) % 2 != 0:
        print('No')
        sys.exit(0)
    tmpx = x
    tmpy = y
    tmpt = t
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
tt = 0
xx = 0
yy = 0
z = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    t, x, y = z[i]
    dt = t - tt
    dx = abs(x - xx)
    dy = abs(y - yy)
    if dt < dx + dy or (dt - (dx + dy)) % 2:
        print('No')
        exit()
    tt = t
    xx = x
    yy = y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

t, x, y = [0]*N, [0]*N, [0]*N
t[0], x[0], y[0] = map(int, input().split())
if t[0] == x[0]+y[0] or ((-x[0]-y[0] + t[0]) > 0 and  (-x[0]-y[0] + t[0]) % 2 == 0):
    check = True
else:
    check = False
for i in range(1, N):
    tt, xx, yy = map(int, input().split())
    t[i], x[i], y[i] = tt-t[i-1] ,abs(xx-x[i-1]) , abs(yy-y[i-1])
    judge = -x[i]-y[i]+t[i]
    if judge < 0 or ( judge % 2 !=0 and judge > 0) or (x[i]==y[i]==0 and t[i]%2 !=0) :
        if t[i] != x[i]+y[i]:
            check = False
            break

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