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())

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

x0 = 0
y0 = 0
t0 = 0
res = "Yes"
for t, x, y in pairs:
    dx = x - x0
    dy = y - y0
    dt = t - t0

    if abs(dx) + abs(dy) != dt:
        tmp = dt - (abs(dx) + abs(dy))
        if tmp <= 0 or tmp % 2 != 0:
            res = "No"
            break
    x0 = x
    y0 = y
    t0 = t

print(res)

Submission status: Accepted

Solution code:
N = int(input())
nowx = 0
nowy = 0
nowt = 0

result = 'Yes'
for i in range(N):
  [t, x, y] = list(map(int,input().split(' ')))
  if (t - nowt) >= abs(x - nowx) + abs(y - nowy) and ((t - nowt) - (x - nowx) - (y - nowy)) % 2 == 0:
    nowx = x
    nowy = y
    nowt = t
    continue
  else:
    result = 'No'
    break
    
print(result)

Submission status: Accepted

Solution code:
n=int(input())
data=[list(map(int,input().split())) for _ in range(n)]
x_past=0
y_past=0
t_past=0
for t,x,y in data:
  if abs(x-x_past)+abs(y-y_past)>t-t_past:
    print("No")
    exit()
  if (abs(x-x_past)+abs(y-y_past))%2!=(t-t_past)%2:
    print("No")
    exit()
  x_past=x
  y_past=y
  t_past=t
print("Yes")

Submission status: Accepted

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

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

  
can = "Yes"
for i in range(n):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if (dt < dist):
    can = "No"
  if(dist % 2 != dt % 2):
    can = "No"
print(can)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
b = 0
c = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    l = t - c
    m = abs((a + b) - (x + y))
    if l >= m and (l - m) % 2 == 0:
        a = x
        b = y
        c = t
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

d_t = 0
d_x = 0
d_y = 0
    
can = False
for ti in range(len(txy)):
    dist = abs(d_x - txy[ti][1]) + abs(d_y - txy[ti][2])
    dt = abs(d_t - txy[ti][0])
    if dt >= dist and (dt % 2 == 0 and dist % 2 == 0 or dt % 2 != 0 and dist % 2 != 0):
        d_t = txy[ti][0]
        d_x = txy[ti][1]
        d_y = txy[ti][2]
        if ti == len(txy) - 1:
            can = True
    else:
        break
print("Yes" if can else "No")

Submission status: Accepted

Solution code:
N = int(input())

flag = "Y"
t = list(range(N))
x = list(range(N))
y = list(range(N))

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

for i in range(N):
    if i==0:
        if t[0] < abs(x[0]) + abs(y[0]):
            flag = "N"
            
    if i>0:
        td = abs(t[i] - t[i-1])
        xd = abs(x[i] - x[i-1])
        yd = abs(y[i] - y[i-1])
        
        if td < abs(xd) + abs(yd):
            flag = "N"
        else:
            if td%2 == 1 and xd%2 == 0 and yd%2 == 0:
                flag = "N"
            elif td%2 == 1 and xd%2 == 1 and yd%2 == 1:
                flag = "N"
            elif td%2 == 0 and xd%2 == 1 and yd%2 == 0:
                flag = "N"
            elif td%2 == 0 and xd%2 == 0 and yd%2 == 1:
                flag = "N"

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

Submission status: Accepted

Solution code:
n = int(input())

t = []

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

#print(t)

res = 0

for i in range(len(t)) :
    if i==0 :
        before = [0, 0, 0]
    else :
        before = t[i-1]

    diff = [t[i][0] - before[0], t[i][1] - before[1], t[i][2] - before[2]]
    #print(diff)

    abs_diff_xy = abs(diff[1]) + abs(diff[2])

    #print("diff : " + str(diff))
    #print("abs_diff_xy : " + str(abs_diff_xy))

    if diff[0] % 2 == 0 and abs_diff_xy % 2 == 0 and abs_diff_xy <= diff[0] :
        continue
    elif diff[0] % 2 == 1 and abs_diff_xy % 2 == 1 and abs_diff_xy <= diff[0] :
        continue
    else :
        res=-1
        break

if res==0 :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
u,v,w=0,0,0
for t,x,y in txy:
  p=t-u
  q=abs(v-x)+abs(w-y)
  if p<q or p%2!=q%2:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
flg = 0
for i in range(n):
	t,x,y = map(int, input().split())
	if x+y > t:
		print ("No")
		exit()
	if x+y < t:
		if (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 (x+y) <= t and (x+y+t) % 2 == 0:
        continue
    else:
        break
else:
    print("Yes")
    quit()
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")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
p = [[0,0,0]]
for i in range(n):
    p.append([int(k) for k in input().split()])
res = 'No'

for i in range(1, n+1):
    t = p[i][0] - p[i-1][0]
    d = p[i][1] - p[i-1][1] + p[i][2] - p[i-1][2]
    if t % 2 == d % 2 and t >= d:
        continue
    break
else:
    res = 'Yes'

print(res)

Submission status: Accepted

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

for i in range(n):
    diff = posdata[i][1] - nowpos[1] + posdata[i][2] - nowpos[2]
    l_parity = diff % 2
    t_parity = (posdata[i][0] - nowpos[0]) % 2
    
    if (posdata[i][0] - nowpos[0]) >= diff and l_parity == t_parity:
        nowpos = posdata[i]
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

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

N = int(input())
t_prev, x_prev, y_prev = 0, 0, 0

for n in range(N):
    t, x, y = map(int, input().split())
    if (t - t_prev) >= (abs(x-x_prev) + abs(y-y_prev)) and (t + x + y) % 2 == 0:
        t_prev, x_prev, y_prev = t, x, y
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n)] 
t=0
x=0
y=0
for i in range(n):
    
    t1=l[i][0]
    x1=l[i][1]
    y1=l[i][2]
    dt=t1-t
    md=abs(x-x1)+abs(y-y1)

    if dt >= md and (dt - md) % 2 == 0:
        t=t1
        x=x1
        y=y1
    else:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

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

lst1.sort()

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

    x,y = lst1[i][1],lst1[i][2]

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
# 初期状態t=0,(x,y)=(0,0)を入れて置く
t, x, y = [0], [0], [0]
for i in range(N):
    tmp_t, tmp_x, tmp_y = map(int, input().split())
    t.append(tmp_t), x.append(tmp_x), y.append(tmp_y)
#print(t,x,y)

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

flag = True
for i in range(1,n+1):
    dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if t[i] - t[i-1] < dist or (t[i] - t[i-1])%2 != dist%2:
        flag = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    for i in range(1, N + 1):
        t, x, y = txy[i]
        pt, px, py = txy[i - 1]
        if abs(px - x) + abs(py - y) > abs(pt - t) or (abs(px - x) + abs(py - y) - abs(pt - t)) % 2 == 1:
            print("No")
            break
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

tmp_x = 0
tmp_y = 0
tmp_t = 0

for i in range(N):
  t, x, y = map(int, input().split())
  T = t - tmp_t
  d = (x - tmp_x) + (y - tmp_y)
  
  if T < d:
    print('No')
    break
  elif T % 2 == 0 and d % 2 == 1:
    print('No')
    break
  elif T % 2 == 1 and d % 2 == 0:
    print('No')
    break
    
else:
  print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

buff = [0, 0, 0]
ans = "Yes"

for i in range(N):
    t, x, y = travel[i]
    time = t - buff[0]
    distance = abs(x - buff[1]) + abs(y - buff[2])
    if time < distance or (time - distance) % 2 == 1:
        ans = "No"
        break
    buff = travel[i]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = "Yes"
i = 0
while i < N:
    t,x,y = [int(num) for num in input().split()]
    if x+y <= t and (t-x-y)%2 == 0:
        i += 1
    else:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
import sys

def main():
    N = int(input())
    t, x, y = 0, 0, 0

    for _ in range(N):
        next_t, next_x, next_y = [int(__) for __ in input().split()]

        delta_t = next_t - t
        distance = abs(next_x - x) + abs(next_y - y)

        if distance > delta_t:
            print("No")
            sys.exit()

        if (delta_t - distance) % 2 != 0:
            print("No")
            sys.exit()

        t, x, y = next_t, next_x, next_y

    print("Yes")

main()

Submission status: Accepted

Solution code:
N = int(input())

ans = "Yes"
i = 0

while i < N:
  t,x,y = [ int(num) for num in input().split() ]
  
  if x+y <= t and (t-x-y)%2 == 0:
    i += 1
  else:
    ans = "No"
    break

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
"""AtCoder Beginner Contest 086: C - Traveling
https://atcoder.jp/contests/abc086/tasks/arc089_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())
    current = {'t': 0, 'x': 0, 'y': 0}

    answer = 'Yes'
    for _ in range(N):
        t, x, y = map(int, input().split())
        length = abs(x-current['x']) + abs(y-current['y'])
        t_d = t - current['t']
        # t=1: odd, t=2: even, t=3: odd, t=4: even, ...
        if length <= t_d and length % 2 == t_d % 2:
            current = {'t': t, 'x': x, 'y': y}
        else:
            answer = 'No'
            break

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
"""AtCoder Beginner Contest 086: C - Traveling
https://atcoder.jp/contests/abc086/tasks/arc089_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())
    position = {'t': 0, 'x': 0, 'y': 0}

    answer = 'Yes'
    for _ in range(N):
        t, x, y = map(int, input().split())
        # print('x:' + str(abs(x-position['x'])))
        # print('y:' + str(abs(y-position['y'])))
        # print('t:' + str(t - position['t']))
        # print(abs(x-position['x']) + abs(y-position['y']))
        length = abs(x-position['x']) + abs(y-position['y'])
        t_d = t - position['t']
        if length <= t_d and length % 2 == t_d % 2:
            position = {'t': t, 'x': x, 'y': y}
        else:
            answer = 'No'
            break

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
current_time = 0
current_pos = 0
ans = True
for _ in range(n):
    t, x, y = map(int, input().split())
    time_dif = t - current_time # 3
    pos_dif = (x+y) - current_pos # 3
    if time_dif % 2 == 1 and pos_dif % 2 == 1 and pos_dif <= time_dif:
        current_time += time_dif
        current_pos += pos_dif
    elif time_dif % 2 == 0 and pos_dif % 2 == 0 and pos_dif <= time_dif:
        current_time += time_dif
        current_pos += pos_dif
    else:
        ans = False

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

Submission status: Accepted

Solution code:
N = int(input())
x, y = 0, 0
b = False
for _ in range(N):
    T, X, Y = map(int, input().split())
    if abs(X-x)+abs(Y-y) > T or abs(X-x)+abs(Y-y)+T&1:
        b = True
print("YNeos"[b::2])

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())
        dt = t - pt
        dx = abs(x - px)
        dy = abs(y - py)
        if (dx + dy) % 2 != dt % 2:
            print('No')
            return
        if (dx + dy) > dt:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
t0 = x0 = y0 = 0
OK = True
for _ in range(N):
  t, x, y = map(int, input().split())
  dt = t-t0
  d = abs(x-x0) + abs(y-y0)
  OK *= dt>=d and dt%2==d%2
  t0 = t
  x0 = x
  y0 = y
print('Yes' if OK else 'No')

Submission status: Accepted

Solution code:
N = int(input())
# 初期状態
T = [0]
X = [0]
Y = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

# パリティに着目せよ
count = 0
for i in range(N):
    totalDisplacement = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
    delta_T = T[i+1]-T[i]
    if (delta_T - totalDisplacement) % 2 == 0 and (delta_T - totalDisplacement) >= 0:
        count += 1

if count == N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
# 初期状態
T = [0]
X = [0]
Y = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

# パリティに着目せよ
count = 0
for i in range(N):
    distanceSum = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
    T_parity = (T[i+1]-T[i])
    Distance_parity = distanceSum
    if (T_parity-Distance_parity) % 2 == 0 and (T_parity-Distance_parity) >= 0:
        count += 1

if count == N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
# 初期状態
T = [0]
X = [0]
Y = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

# パリティに着目せよ
count = 0
for i in range(N):
    distanceSum = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
    T_parity = (T[i+1]-T[i]) % 2
    Distance_parity = distanceSum % 2
    if distanceSum <= (T[i+1]-T[i]) and T_parity == Distance_parity:
        count += 1

if count == N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
ans = 'Yes'
pt,px,py=0,0,0
for i in range(N):
  t,x,y=map(int, input().split())
  fg = abs(t-pt)-(abs(x-px)+abs(y-py))
  if fg%2!=0 or fg<0:
    ans = 'No'
    break
  pt,px,py=t,x,y
print(ans)

Submission status: Accepted

Solution code:
# Traveling
import sys
import numpy as np
input = sys.stdin.readline

N = int(input())
memo = np.array([[0, 0, 0], []])
for _ in range(N):
  memo[1] = np.array([int(x) for x in input().split()])
  dt, dx, dy = np.abs(memo[0]-memo[1])
  d = dx + dy
  if dt < d:
    print('No')
    exit()
  else:
    if (dt - d)%2 != 0:
      print('No')
      exit()
    else:
      memo = np.array([memo[1], []])
print('Yes')

Submission status: Accepted

Solution code:
def man(a,b,c,d):
  return abs(a-c)+abs(b-d)
n=int(input())
li = [[0,0,0]]+[list(map(int,input().split())) for i in range(n)]
for i in range(1,n+1):
  if man(li[i][1],li[i][2],li[i-1][1],li[i-1][2])<= li[i][0]-li[i-1][0] and (li[i][0]-li[i-1][0]-man(li[i][1],li[i][2],li[i-1][1],li[i-1][2]))%2==0:
    continue
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

    for i in range(N):
        t = num_list[i][0]
        xy = num_list[i][1] + num_list[i][2]
        if t < num_list[i][1] or t < num_list[i][2]:
            print('No')
            exit()
        if t < xy:
            print('No')
            exit()
        if t % 2 == 0 and xy % 2 != 0:
            print('No')
            exit()
        if t % 2 != 0 and xy % 2 == 0:
            print('No')
            exit()


    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
number=input().rstrip()
number=int(number)
destination=[]
#destination.append(input().rstrip().split() for i in range(number))
destination=[input().rstrip().split() for i in range(number)]
destination.insert(0,['0','0','0'])
count=0
for i in range(number):
    time=int(destination[i+1][0])-int(destination[i][0])
    length=abs(int(destination[i][1])-int(destination[i+1][1]))+abs(int(destination[i][2])-int(destination[i+1][2]))
    if time<length:
        break
    elif time==length:
        count+=1
    else:
        a=time-length
        if a%2==0:
            count+=1
        else:
            break
if count==number:
    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())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())

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])
    if dt-dx-dy >= 0 and (dt-dx-dy)%2 == 0:
        continue
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:

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

hantei="Yes"


for i in range(N):
    t[i], x[i], y[i] = map(int, input().split())
    if t[i]-x[i]-y[i]>=0 and t[i]%2==(x[i]+y[i])%2:
        continue
    else:
        hantei="No"
        break

print(hantei)

Submission status: Accepted

Solution code:
N = int(input())

flag = 1

for i in range(N):
    t, x, y = map(int, input().split())
    if (x+y)%2!=t%2 or x+y>t:
        flag = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
txy = []
for i in range(n):
  txy.append(list(map(int, input().split())))
pt = 0
py = 0
px = 0
for t, x, y in txy:
  dt = t - pt
  dx = x - px
  dy = y - py
  ax = abs(dx) % 2
  ay = abs(dy) % 2
  a = (ax + ay) % 2
  if abs(dx) + abs(dy) > dt or a != dt % 2:
    print("No")
    sys.exit()
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 t%2!=(x+y)%2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
pt, px, py = [0, 0, 0]
ans = 'Yes'
for i in range(N):
    t, x, y = [int(n) for n in input().split()]
    dt = t-pt
    dxy = sum([abs(x-px), abs(y-py)])
    if dt < dxy or dt%2 != dxy%2:
        ans = 'No'
        break
    else:
        pt, px, py = t, x, y
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

can = True
for i in range(N):
    t, x, y = list(map(int, input().split()))
    
    if not t%2 == (x+y)%2 or (x+y) > t:
        can = False
        break
        
if can:
    s = "Yes"
else:
    s = "No"
print(s)

Submission status: Accepted

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

for i in range(n):
    dt = txy[i][0]
    dst = txy[i][1] + txy[i][2]
    if dt < dst:
        print('No')
        exit()

    if txy[i][0] % 2 == 0:
        if (txy[i][1]+txy[i][2]) % 2 != 0:
            print('No')
            exit()

    elif txy[i][0] % 2 != 0:
        if (txy[i][1]+txy[i][2]) % 2 == 0:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
n = input()

t_now = 0
x_now = 0
y_now = 0
can_travel = True
for i in range(int(n)):
  next_value = list(map(int,input().split()))
  dt = next_value[0]-t_now
  dist = abs(next_value[1]-x_now)+abs(next_value[2]-y_now)
  if dt < dist:
    can_travel = False
    break
  elif dt%2 != dist%2:
    can_travel = False
    break

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

Submission status: Accepted

Solution code:
n=int(input())

from numpy import array

i=0
o=array([0,0,0])
while i<n:
   c=list(map(int,input().split()))
   z=array(c)
   w=z-o
   a,b=map(int,[w[0],abs(w[1])+abs(w[2])])

   if a<b:
       print("No")
       break

   else:
       if (a+b)%2==0:
           o=z
           i=i+1
       else:
           print("No")
           break
else:
    print("Yes")

Submission status: Accepted

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

for i in range(1, N+1):
  t[i] = int(list_xy[i-1][0])
  x[i] = int(list_xy[i-1][1])
  y[i] = int(list_xy[i-1][2])
  
flag = 'Yes'
for i in range(N):
  dt = t[i+1] - t[i]
  dist = (x[i+1] - x[i]) + (y[i+1] - y[i])
  if dist > dt:
    flag = 'No'
  if (t[i] % 2) != ((x[i] + y[i]) % 2):
    flag = 'No'

print(flag)

Submission status: Accepted

Solution code:
n = int(input())
ans = True
for i in range(n):
    t,x,y = map(int,input().split())
    if (x+y)%2 != t%2:
        ans = False
    if x+y>t:
        ans = False

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

Submission status: Accepted

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

flag = True
for i in range(n):
    delta_t = 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 delta_t < dist or delta_t % 2 != dist % 2:
        flag = False
        break

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

Submission status: Accepted

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

t, x, y = 0, 0, 0

N = int(input())
for _ in range(N):
    t_next, x_next, y_next = map(int, input().split())

    diff_kyori = abs(x - x_next) + abs(y - y_next)
    diff_time = t_next - t

    if diff_kyori > diff_time:  # 距離が時間より大きい
        print('No')
        exit(0)
    if (diff_kyori - diff_time) % 2 == 1:  # 距離と時間の差
        print('No')
        exit(0)

    t, x, y = t_next, x_next, y_next

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = [0]*N
X = [0]*N
Y = [0]*N
for i in range(N):
  T[i], X[i], Y[i] = map(int, input().split())

pt=px=py = 0
for i in range(N): # マンハッタン距離
  d = abs(X[i]-px) + abs(Y[i]-py)
  dt = T[i]-pt # 使える時間
  
  # 時間内に移動できるか or 時間調整できるか
  if dt < d or (dt-d)%2 == 1:
    print("No")
    exit()
  
  pt = T[i]
  px = X[i]
  py = Y[i]
print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8

import sys

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

for i in range(N):
	d = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
	dt = t[i + 1] - t[i]
	if dt < d or dt % 2 != d % 2:
		print("No")
		sys.exit()
	
print("Yes")

Submission status: Accepted

Solution code:

N = int(input())

current = (0, 0, 0)
for i in range(N):
  ct, cx, cy = map(int, current)
  t, x, y = map(int, input().split())

  v = abs(x-cx) + abs(y-cy)
  if abs(t-ct) < v:
    print("No")
    exit()

  if abs(t-ct) % 2 != v % 2:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n=int(input())

t1,x1,y1=0,0,0
flg=True
for i in range(n):
    t2,x2,y2=map(int,input().split())
    l=abs(x2-x1)+abs(y2-y1)
    #print(l,t2-t1)
    if l<=(t2-t1) and (t2-t1-l)%2==0:
        t1,x1,y1=t2,x2,y2
    else:
        flg=False
        break
print("Yes" if flg else "No")

Submission status: Accepted

Solution code:
n = int(input())

travel = list()
#start point
travel.append((0,0,0))

for i in range(n):
  travel.append(tuple(map(int,input().split())))


for j in range(n):
  dist = abs(travel[j][0]-travel[j+1][0])

  dd = abs(travel[j][1]-travel[j+1][1])+abs(travel[j][2]-travel[j+1][2])
  
#fail
  if dist < dd or (dd%2 != dist%2):
    print("No")
    exit(0) 

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

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

def is_possible(travels):
    current = (0, 0, 0)

    for t, x, y in travels:
        prev_t, prev_x, prev_y = current

        dt = t - prev_t
        dx = x - prev_x
        dy = y - prev_y
        dxy = dx + dy
        if dt < dxy:
            return False
        if dt == dxy:
            continue
        if (dt - dxy) % 2 != 0:
            return False

        current = (t, x, y)

    return True


if is_possible(travels):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
tabi=[0]*(N+1)
dic={'t':0,'x':0,'y':0}
tabi[0]=dic

for i in range(1,N+1):
  te=input()
  t=int(te.split()[0])
  x=int(te.split()[1])
  y=int(te.split()[2])
  
  dic={'t':t,'x':x,'y':y}
  tabi[i]=dic

flag=True
temp=tabi[0]
for dic in tabi:
  if temp['t']==dic['t']:
    continue
    
  diff_t=dic['t']-temp['t']
  diff_x=dic['x']-temp['x']
  diff_y=dic['y']-temp['y']
  if abs(diff_x+diff_y)>diff_t:
    flag=False
    break
  if abs(abs(diff_x+diff_y)-diff_t)%2!=0:
    flag=False
    break
  
  temp=dic

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

Submission status: Accepted

Solution code:
from sys import exit, stdin
# stdin = open("input.txt")

if __name__ == "__main__":
    N = int(stdin.readline().rstrip())
    cords = [(int(t), int(x), int(y)) 
            for t, x, y in 
            [stdin.readline().rstrip().split() for i in range(N)]]

    dist = lambda x, y: abs(x) + abs(y)
    
    for t, x, y in cords:
        if dist(x, y) > t:
            # no way!
            print("No")
            exit(0)
        
        if not (x + y) % 2 == t % 2:
            print("No")
            exit(0)
    
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
t = 0
n = int(input())
x, y = 0, 0
for _ in range(n):
    t_i, x_i, y_i = map(int, input().split(' '))
    t_d = t_i - t
    x_d = abs(x_i - x)
    y_d = abs(y_i - y)
    
    t, x, y = t_i, x_i, y_i
    if x_d + y_d <= t_d and (x_d + y_d) % 2 == t_d % 2:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
# ABC86 C - Traveling
N = int(input())
ans = "Yes"
t, x, y = 0, 0, 0
for i in range(N):
    ti, xi, yi = map(int, input().split())
    dt, dx, dy = ti - t, abs(xi - x), abs(yi - y)
    if dt >= dx + dy and (dt - (dx + dy)) % 2 == 0:
        t, x, y = ti, xi, yi
    else:
        ans = "No"
        break
print(ans)