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:
# C-Traveling
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().split())
flg = 1
for i in range(N):
    if i == 0:
        deltax = x[i]
        deltay = y[i]
        deltat = t[i]
    else:
        deltax = abs(x[i] - x[i-1])
        deltay = abs(y[i] - y[i-1])
        deltat = t[i] - t[i-1]
    trip_len = deltax + deltay
    if (((deltat - trip_len)%2) != 0) or (deltat < trip_len) :
        flg = 0
if flg == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(N):
    timelimit = scedule[i+1][0] - scedule[i][0]
    x_distance = abs(scedule[i+1][1] - scedule[i][1])
    y_distance = abs(scedule[i+1][2] - scedule[i][2])

    if timelimit < (x_distance + y_distance):
        print("No")
        exit()
    if timelimit % (x_distance + y_distance) != 0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
pos = []
for i in range(n):
  b = list(input().split( ))
  pos.append(b)
tp, xp, yp = 0, 0, 0
rflag = True
for p in pos:
  t, x, y = map(int, p)
  tint = t - tp
  xd = x - xp
  yd = y - yp
  tp, xp, yp = t, x, y
  pd = abs(xd) + abs(yd)
  if ((tint >= pd) & ((tint % 2) == (pd % 2))):
    continue
  else:
    rflag = False
    break
  
if rflag == True:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
pos = []
for i in range(n):
  b = list(input().split( ))
  pos.append(b)
tp, xp, yp = 0, 0, 0
rflag = True
for p in pos:
  t = int(p[0])
  x = int(p[1])
  y = int(p[2])
  tint = t - tp
  xd = x - xp
  yd = y - yp
  pd = abs(xd) + abs(yd)
  if ((tint >= pd) & ((tint % 2) == (pd % 2))):
    continue
  else:
    rflag = False
    break
  
if rflag == True:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
t0 = x0 = y0 = 0
for _ in range(n):
  t, x, y = map(int, input().split())
  dt, dx, dy = t - t0, x - x0, y - y0
  dist = abs(dx) + abs(dy)
  if dist > dt or dist % 2 != dt % 2 :
    print('No')
    exit()
  t0, x0, y0 = t, x, y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
a = 0
b = 0
c = 0
for i in range(N):
    t,x,y = [int(x) for x in input().split()]
    kyori = abs(a-x)+abs(b-y)
    if t-c-kyori >= 0 and (t-c-kyori) % 2 == 0:
        a = x
        b = y
        c = t
        continue
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
def dif(two_lists):
    return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]


n = int(input())

txy = [[0, 0, 0]] + [[int(s) for s in line.split()] for line in sys.stdin]
dtxy = list(map(dif, zip(txy, txy[1:])))

for i in range(n):
    dt, dx, dy = dtxy[i]
    if  dx + dy > dt or (dt - dx - dy) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def dif(two_lists):
    return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]


n = int(input())

txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
dtxy = list(map(dif, zip(txy, txy[1:])))

for i in range(n):
    dt, dx, dy = dtxy[i]
    if  dx + dy > dt or (dt - dx - dy) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

t_arr = [0]*(n+1)
x_arr = [0]*(n+1)
y_arr = [0]*(n+1)

for i in range(n+1):
    # 先頭はt0 x0 y0 なのでそのままにする
    if i == 0:continue
    pos = input().split()
    t_arr[i] = int(pos[0])
    x_arr[i] = int(pos[1])
    y_arr[i] = int(pos[2])

is_possible = True

for i in range(n):
    # 次の場所までに移動できる時間(回数)
    t = t_arr[i+1] - t_arr[i];
    
    # 次の場所までの距離
    x = abs(x_arr[i] - x_arr[i+1])
    y = abs(y_arr[i] - y_arr[i+1])
    d = x + y
    
    if d <= t and t%2 == d%2:
        continue
    else:
        is_possible = False
        break
    
print("Yes" if is_possible else "No")

Submission status: Accepted

Solution code:
#
# NoKnowledgeGG @YlePhan
# ('ω')
#
#import collections
#aa = collections.Counter(a) # list to list
def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
    n = int(input())
    T = []
    X = []
    Y = []
    for i in range(n):
        t,x,y = readInts()
        T.append(t)
        X.append(x)
        Y.append(y)
    cx,cy,ct = 0,0,0
    for i in range(n):
        dist_place = abs(X[i] - cx) + abs(Y[i] - cy)
        dist_time = abs(T[i] - ct)
        if dist_time >= dist_place and (dist_time - dist_place) % 2 == 0:
            cx = X[i]
            cy = Y[i]
            ct = T[i]

            pass
        else:
            print('No')
            exit()
    print('Yes')



if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n=int(input())
t0=0
x0=0
y0=0
ok=True
for i in range(n):
  t1,x1,y1=map(int,input().split())
  c=t1-t0-x1+x0-y1+y0
  if c<0 or c%2==1:
    ok=False
    break
print('Yes' if ok else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def distance(point1, point2):
    return abs(point1[0] - point2[0]) + abs(point1[1] - point2[1])
def solve(t1, t2, point1, point2):
    t = abs(t2 - t1)
    d = distance(point1, point2)
    if d==t:
        return True
    elif d<t and t%2==d%2:
        return True
    return False

n = int(input())
t = [0]*(n+1)
xy = [[0,0]]*(n+1)
for i in range(1,n+1):
    t[i], *xy[i] = list(map(int, input().split()))
ans = True
for i in range(1, n+1):
    if not solve(t[i-1], t[i], xy[i-1], xy[i]):
        ans = False

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

Submission status: Accepted

Solution code:
N = int(input())
t = [0 for i in range(N)]    # リストには最初に要素を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())

a = "Yes"
# ここまでが入力
for i in range(N):
    if i == 0:
        dt = t[0]
        dist = abs(x[0]) + abs(y[0])
    else:
        dt = t[i]-t[i-1]
        dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    if dist > dt or (dist+dt) % 2 == 1:
        a = "No"
print(a)

Submission status: Accepted

Solution code:
import sys

def main():
    def input():
      return sys.stdin.readline().rstrip()
    
    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())
    
    flag = True
    for i in range(N):
        dt = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        if dt % 2 != dist % 2 or dt < dist:
            flag = False
            break
            
    print('Yes' if flag else 'No')
    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def main():
    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())
    
    flag = True
    for i in range(N):
        dt = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        if dt % 2 != dist % 2 or dt < dist:
            flag = False
            break
            
    print('Yes' if flag else 'No')
    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
t = 0
x = 0
y = 0
for _ in range(N):
    nt, nx, ny = map(int, input().split())
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if dt >= dx + dy and dt % 2 == (dx+dy) % 2:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc086/tasks/arc089_a
# 12:38-12:53


def main():
    N = int(input())
    t, x, y = [None] * N, [None] * N, [None] * N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())

    for i in range(N):
        if i == 0:
            root = abs(x[i]) + abs(y[i])
            if root > t[i] or (t[i] - root) % 2 > 0:
                return "No"

            continue

        root = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
        if root > t[i] - t[i-1] or (t[i] - t[i-1] - root) % 2 > 0:
            return "No"

    return "Yes"


print(main())

Submission status: Accepted

Solution code:
N = int(input())

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

t = 0
x = 0
y = 0
for i in range(N):
    # 必要な移動距離
    ido = abs(x-TXY[i][1])+abs(y-TXY[i][2])

    # 時間までにたどり着けるか
    if ido > TXY[i][0]-t:
        break

    # その場所にいることができるか
    if ido % 2 != (TXY[i][0]-t) % 2:
        break

    t = TXY[i][0]
    x = TXY[i][1]
    y = TXY[i][2]

else:
    print('Yes')
    exit(0)
print('No')

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n):
    ti, xi, yi, = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
    
is_can = True
for i in range(len(t) - 1):
    dt = t[i + 1] - t[i]
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dt < dist:
        is_can = False
        break
    if(dt % 2 != dist % 2):
        is_can = False
        break
if is_can:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
IN = [list(map(int, input().split())) for x in range(N)]

flag = True
for t in IN:
    if t[0] < t[1] + t[2]:
        flag = False
        break
    if t[0] % 2:
        if (t[1]+t[2]) % 2 == 0:
            flag = False
            break
    else:
        if (t[1]+t[2]) % 2:
            flag = False
            break

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


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


def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    pti = 0
    pxi = 0
    pyi = 0
    for ti, xi, yi in zip(t, x, y):
        dt = ti - pti
        dx = xi - pxi
        dy = yi - pyi
        if abs(dx) + abs(dy) > dt or (dx + dy + dt) % 2 != 0:
            print(NO)
            return
        pti = ti
        pxi = xi
        pyi = yi
    print(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())
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
import numpy as np

def judge(bef, aft):
    t, a, b = map(int, np.abs(aft-bef))
    if a+b <= t and (a+b)%2 == t%2:
        return True
    return False
    
def main():
    input = sys.stdin.readline
    n = int(input())
    bef = np.array([0, 0, 0])
    flag = True
    for i in range(n):
        aft = np.array([int(x) for x in input().split()])
        if judge(bef, aft):
            continue
        flag = False
    if flag:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]
    T = 0
    X = 0
    Y = 0
    for d in D:
        t, x, y = d
        ans = "Yes"
        dxy = abs(X-x) + abs(Y-y)
        dt = t-T
        if dxy > dt or dxy % 2 != dt % 2: 
            # 直進したとしても到達できない，移動による偶奇
            ans = "No"
            break
    print(ans)

Submission status: Accepted

Solution code:

n = int(input())

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

for i in range(1, n + 1):
    dis = abs(data[i][1] - data[i - 1][1]) + abs(data[i][2] - data[i- 1][2])
    dif = data[i][0] - data[i - 1][0]
    if (dif % 2 != dis % 2 or dis > dif):
        print("No")
        exit() 

print("Yes")

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    t_i, x_i, y_i = 0, 0, 0
    for i in range(N):
        t_j, x_j, y_j = map(int, input().split())
        dt = t_j - t_i
        dxy = x_j - x_i + y_j - y_i
        if (dxy < -dt) | (dxy > dt):
            return "No"
        if ((t_i - t_j) % 2) != (dxy % 2):
            return "No"
        t_i, x_i, y_i = t_j, x_j, y_j
    return "Yes"
print(solve())

Submission status: Accepted

Solution code:
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().split())

judg = 0    

for i in range(N):
    if x[i]+y[i]<=t[i]:
        if t[i]%2==0 and (x[i]+y[i])%2==0:
            judg += 1
        elif t[i]%2!=0 and (x[i]+y[i])%2!=0:
            judg += 1

if judg == 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)%2 != t%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
#初期値に関する処理がないのでNG
import sys

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

#初期値対応
if arr[0][0] < arr[0][1] + arr[0][2]:
    print("No")
    exit()

for i in range(len(arr)-1):
    if arr[i+1][0]-arr[i][0] < abs(arr[i+1][1]-arr[i][1])+abs(arr[i+1][2]-arr[i][2]) or (arr[i+1][0]-arr[i][0])%2 != (abs(arr[i+1][1]-arr[i][1])+abs(arr[i+1][2]-arr[i][2]))%2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys

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

for i in range(len(arr)):
    if arr[i][0] < arr[i][1]+arr[i][2] or arr[i][0]%2 != (arr[i][1]+arr[i][2])%2:
        print("No")
        exit()

for i in range(len(arr)-1):
    if arr[i+1][0]-arr[i][0] < abs(arr[i+1][1]-arr[i][1])+abs(arr[i+1][2]-arr[i][2]):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t_x_y_list = [list(map(int, input().split())) for _ in range(n)]
pt = 0
px = 0
py = 0
for t, x, y in t_x_y_list:
    if t - pt < abs(px - x) + abs(py - y):
        print("No")
        exit()
    if (t - pt) % 2 != (abs(px - x) + abs(py - y)) % 2:
        print("No")
        exit()
    pt = t
    px = x
    py = y
print("Yes")

Submission status: Accepted

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

for i in range(N):
    t = abs(S[i][0] - S[i + 1][0])
    d = abs(S[i][1] - S[i + 1][1]) + abs(S[i][2] - S[i + 1][2])
    if t < d:
        print("No")
        exit()
    if t % 2 != d % 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

    time = 0
    pos = [0, 0]
    for i in range(n):
        dist = abs(txy[i][1] - pos[0]) + abs(txy[i][2]-pos[1])
        t = txy[i][0] - time
        if dist > t:
            print('No')
            exit()
        elif (t - dist) % 2 == 1:
            print('No')
            exit()
        pos = [txy[i][1], txy[i][2]]
        time = txy[i][0]

    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
nt,nx,ny = 0,0,0
 
for i in range(n):
    t,x,y = map(int,input().split())
    if (abs(nx-x)+abs(ny-y)) > t-nt:
        print("No")
        exit()
    else:
        t2 = t-nt-abs(nx-x)
        if abs(ny-y)%2 == 0 and t2%2 == 0:
            nt,nx,ny = t,x,y
        elif abs(ny-y)%2 == 1 and t2%2 == 1:
            nt,nx,ny = t,x,y
        else:
            print("No")
            exit()
 
print("Yes")

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    t_i, x_i, y_i = 0, 0, 0
    for i in range(N):
        t_j, x_j, y_j = map(int, input().split())
        dt = t_j - t_i
        dxy = x_j - x_i + y_j - y_i
        if (dxy < -dt) | (dxy > dt):
            return "No"
        if ((t_i - t_j) % 2) != (dxy % 2):
            return "No"
        t_i, x_i, y_i = t_j, x_j, y_j
    return "Yes"


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
n = int(input())
list_A = [ list(map(int,input().split(" "))) for i in range(n)]
list_A.insert(0, [0, 0, 0])
ans = "Yes"
for i in range(1, n+1):
    l = list_A[i]
    k = list_A[i-1]
    distance = abs(l[1]-k[1]) + abs(l[2]-k[2])
    if distance > l[0] - k[0]:
        ans = "No"
        break
    else:
        if (distance - (l[0]-k[0])) % 2 == 1:
            ans = "No"

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n):
    a,b,c = map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)


ans = True
move=(x[0]+y[0])
time = t[0] - 0
if move > time:ans = False
if (time - move)%2 ==1:ans = False

for i in range(1,n):
    move =x[i] + y[i] - x[i-1] - y[i-1]
    time =t[i] - t[i-1]
    if move > time:ans = False
    if (time - move)%2 ==1:ans = False

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

Submission status: Accepted

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

for i in range(N):
  a,b,c = map(int, input().split())
  tmp = abs(a-t) - abs(b-x) - abs(c-y) 
  if tmp >= 0 and tmp % 2 == 0:
    t,x,y = a,b,c
  else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
nt,nx,ny=0,0,0

for i in range(n):
    t,x,y=map(int,input().split())
    if (abs(nx-x)+abs(ny-y)) > t-nt:
        print("No")
        exit()
    else:
        t2=t-nt-abs(nx-x)
        if abs(ny-y)%2==0 and t2%2==0:
            nt,nx,ny=t,x,y
        elif abs(ny-y)%2==1 and t2%2==1:
            nt,nx,ny=t,x,y
        else:
            print("No")
            exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
T, X, Y = 0, 0, 0
result = "Yes"
for t, x, y in txy:
    d =  (x-X) + (y-Y)
    if t<d or (t-d)%2==1:
        result = "No"
        break
print(result)

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int,input().split())) for _ in range(n)]
txy.insert(0,[0,0,0])
for i in range(n):
  t = txy[i+1][0] - txy[i][0]
  x = abs(txy[i+1][1] - txy[i][1])
  y = abs(txy[i+1][2] - txy[i][2])
  if t < x+y:
    print('No')
    exit()
  elif t == x+y:
    pass
  else:
    if ((t%2 == 0) and ((x+y)%2 == 0)) or ((t%2 != 0)and((x+y)%2 != 0)):
      pass
    else:
      print('No')
      exit()
print('Yes')

Submission status: Accepted

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

fault=0
for el in txy:
    t, x, y = el
    #print(t,x,y)
    if t % 2 == 0 and (x+y) % 2 == 0 or\
        t % 2 == 1 and (x+y) % 2 == 1:
        pass
    else:
        fault = 1
if fault == 1:

    print('No')
else:
    txy.insert(0, (0,0,0))
    for i in range(N):
        time = txy[i+1][0] - txy[i][0]
        distance = abs(txy[i+1][1]- txy[i][1]) +\
            abs(txy[i+1][2] - txy[i][2])
        #print(distance, time)
        if time >= distance:
            pass
        else:
            fault=1
    if fault == 1:
        print('No')
    else:
        print('Yes')

Submission status: Accepted

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

flagCount = 0

for i in range(n):
    if t[i] < x[i] + y[i]:
        flagCount += 1
    if t[i]%2 != (x[i]+y[i])%2:
        flagCount += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    if i == 0:
        dt = txy[0][0]
        dxy = txy[0][1] + txy[0][2]
    else:
        dt = txy[i][0] - txy[i-1][0]
        dxy = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
    if dxy > dt:
        print("No")
        break
    else:
        if (dxy - dt) % 2 == 1:
            print("No")
            break
        else:
            continue
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
flg = True
x,y = 0,0
for i in range(n):
  a,b,c = map(int,input().split())
  if (a < abs(b) + abs(c) - (x+y)) or (a % 2 != (abs(b) + abs(c)) % 2):
    flg = False
    break
  else:
    x = b
    y = c
#print(flg)
print("Yes" if flg else "No")

Submission status: Accepted

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

t, x, y = 0, 0, 0

flag = True
for ti, xi, yi in d:
  if ti >= xi + yi:
    if (ti - t) % 2 != (abs(xi - x) + abs(yi - y)) % 2:
    	flag = False
    	break
    t = ti
    x = xi
    y = yi
    
  else:
    flag = False
    break
    
print("Yes" if flag else "No")

Submission status: Accepted

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

t = 0
x = 0
y = 0
flag = True

for i in range(N):
    t_next = P[i][0] - t
    d_next = abs(P[i][1] - x) + abs(P[i][2] - y)
    # 次までの距離より時間が短いと無理
    # または、次までの距離と時間との差が奇数なら無理（同じところにとどまれないので）
    if (t_next - d_next)%2 == 1 or t_next < d_next:
        flag = False
        break
    t = P[i][0]
    x = P[i][1]
    y = P[i][2]

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

Submission status: Accepted

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

for i in range(n):
    T,X,Y = lst[i+1][0]-lst[i][0],abs(lst[i][1]-lst[i+1][1]),abs(lst[i][2]-lst[i+1][2])
    if X+Y>T or (X+Y-T)%2!=0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
t=0
x=0
y=0
n=int(input())
for i in range(n):
    ti,xi,yi=map(int,input().split())
    t=ti-t
    x=xi-x
    y=yi-y
    if t%2!=(abs(x+y))%2:
        print('No')
        exit()
    elif t<abs(x)+abs(y):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
tl=[]
xl=[]
yl=[]
al=[]
bl=[]
cl=[]
dl=[]

for i in range(N):
 t,x,y=map(int,input().split())
 tl.append(t)
 xl.append(x)
 yl.append(y)
 al.append((x+y)%2)
 bl.append(t%2)

for i in range(N):
 c=abs((xl[i]+yl[i])-(xl[i-1]+yl[i-1]))
 d=abs(tl[i]-tl[i-1])
 cl.append(c)
 dl.append(d)

count=0
for i in range(N):
 if al[i]==bl[i] and (xl[i]+yl[i])<=tl[i] and cl[i]<=dl[i]:
  count+=1
if count==N:
  print("Yes")
else :
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
maps = []
maps.append([0,0,0])
for i in range(n):
  t,x,y = map(int,input().split())
  maps.append([t,x,y])
count = 0
for j in range(n):
  tgap = maps[j+1][0] - maps[j][0]
  total = maps[j+1][1] - maps[j][1] + maps[j+1][2] - maps[j][2]
  gap = tgap - total
  if gap >= 0 and gap % 2 == 0:
    count += 1
if count == n:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
sx, sy = 0, 0
t = 0
check = True
for i in range(N):
  nt, nx, ny = list(map(int, input().split()))
  if abs(nx-sx) + abs(ny - sy) <= (nt -t) and (abs(nx-sx) + abs(ny - sy)) % 2 == (nt -t) % 2:
    sx, sy, t = nx, ny, nt
  else:
    check = False
    break
if check:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
pret = 0
prex = 0
prey = 0
for _ in range(n):
    t, x, y = MAP()
    dis = abs(x - prex) + abs(y - prey)
    delta = t - pret
    if delta - dis >= 0 and (delta - dis) % 2 == 0:
        pret = t
        prex = x
        prey = y
        continue
    else:
        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 txy:
    if i[1] + i[2] > i[0] or i[0] % 2 != (i[1] + i[2]) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
txy = []
for i in range(n):
    txy.append([int(i) for i in input().split()])

ans = "Yes"
bx = 0
by = 0
bt = 0
for i in range(n):
    tmp = ((txy[i][1] - bx) + (txy[i][2] - by))
    if tmp % 2 != (txy[i][0] - bt) % 2 or tmp > (txy[i][0] - bt):
        ans = "No"
    bx = txy[i][1]
    by = txy[i][2]
    bt = txy[i][0]
print(ans)

Submission status: Accepted

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

for i,t in enumerate(txy[1::]):
    dist=abs(t[1]-txy[i][1])+abs(t[2]-txy[i][2])
    time=t[0]-txy[i][0]
    if dist<=time and (time-dist)%2==0:
        pass
    else:
        answer="No"
        break
print(answer)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    txy = []
    for _ in range(n):
        txy.append(list(map(int,input().split())))
    
    x = 0
    y = 0
    pt = 0
    for t in txy:
        d = abs(t[1]-x) + abs(t[2]-y)
        dt = t[0]-pt
        if d > dt or (d % 2) != (dt % 2):
            print("No") 
            exit(0)
        x = t[1]
        y = t[2]
        pt = t[0]
    
    print("Yes")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import exit
N = int(input())
posx = 0
posy = 0
now = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    time_elapsed = t - now
    now = t
    if abs(posx - x) + abs(posy - y) <= time_elapsed and time_elapsed % 2 == (abs(posx - x) + abs(posy - y)) % 2:
        posx = x
        posy = y
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]
T = X = Y = 0
ans = "Yes"
for t, x, y in txy:
  a = (t-T) - (abs(X-x) + abs(Y-y))
  if a % 2 == 0 and abs(X-x) + abs(Y-y) <= t - T:
    T, X, Y = t, x, y
  else:
    ans = "No"
    break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
TXY = [tuple(map(int,input().split())) for i in range(N)]
ct = cx = cy = 0
for t,x,y in TXY:
    d = abs(cx-x) + abs(cy-y)
    if d > t-ct or d%2 != (t-ct)%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y
print('Yes')

Submission status: Accepted

Solution code:
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    t=x=y=0
    for _ in range(n):
        nt,nx,ny=MI()
        d=abs(x-nx)+abs(y-ny)
        dt=nt-t
        if d&1!=dt&1 or d>dt:
            print("No")
            exit()
        t,x,y=nt,nx,ny
    print("Yes")

main()

Submission status: Accepted

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

flg = False
for i in range(n):
    t, x, y = txy[i]
    if x + y > t:
        flg = False
        break

    if (x + y) % 2 == 0:
        if t % 2 == 0:
            flg = True
        else:
            flg = False
            break
    else:
        if t % 2 != 0:
            flg = True
        else:
            flg = False
            break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
nt, nx, ny = [0]*3
cant = False
for i in range(int(input())):
	t, x, y = map(int, input().split())
	a = abs(x-nx)+abs(y-ny)
	if a>t or (t-nt-a)%2: cant = True
	nt, nx, ny = t, x, y
print("YNeos"[cant::2])

Submission status: Accepted

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

t = 0
x = 0
y = 0
for t1, x1, y1 in info:
    diff = abs(x - x1) + abs(y - y1)
    diff_t = abs(t - t1)
    if diff_t >= diff and diff % 2 == diff_t % 2:
        continue
    else:
        print("No")
        exit()
print("Yes")