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())
l = [list(map(int, input().split())) for _ in range(n)]
ans = True
for i in l:
    t, x, y = i[0], i[1], i[2]
    if x+y > t or (x+y)%2 != t%2:
        ans = False
 
print("Yes") if ans else print("No")

Submission status: Accepted

Solution code:

N = int(input())

t_prev=0
x_prev=0
y_prev=0

for i in range(N):
    t_i, x_i, y_i = map(int, input().split()) 

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    elif x_i-x_prev > t_i-t_prev or y_i-y_prev>t_i-t_prev:
        print('No')
        exit()

    t_prev=t_i
    x_prev=x_i
    y_prev=y_i

print("Yes")

Submission status: Accepted

Solution code:

N = int(input())

for i in range(N):
    t_i, x_i, y_i = map(int, input().split()) 

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
#!/bin/env python3

N = int(input())

t_prev = x_prev = y_prev = 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    elif (abs(x_i - x_prev) + abs(y_i - y_prev)) > (t_i - t_prev):
        print("No")
        exit()
    t_prev, x_prev, y_prev = t_i, x_i, y_i

print("Yes")

Submission status: Accepted

Solution code:
#!/bin/env python3

N = int(input())

#t_prev = x_prev = y_prev = 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    #elif (abs(x_i - x_prev) + abs(y_i - y_prev)) > (t_i - t_prev):
    #    print("No")
    #    exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
travel = [0, 0, 0]
flag = True
for i in range(N):
    new_travel =  list(map(int, input().split(' ')))
    change = [new_travel[i] - travel[i] for i in range(3)]
    if abs(change[1]) + abs(change[2]) - change[0] > 0 or\
    ((abs(change[1]) + abs(change[2])) - change[0])%2 !=0:
        print('No')
        flag = False
        break
    travel = new_travel

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

Submission status: Accepted

Solution code:
N=int(input())
t=[[int(x) for x in input().split()] for i in range(0,N)]

def func(N,t):
    if (t[0][0]-(t[0][1]+t[0][2]))%2==1 or t[0][0]-(t[0][1]+t[0][2])<0 : return "No"
    
    for i in range(1,N):
        if ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))%2==1 or ((t[i][0]-t[i-1][0])-(abs(t[i][1]-t[i-1][1])+abs(t[i][2]-t[i-1][2])))<0 : return "No"
    
    return "Yes"
    
print(func(N,t))

Submission status: Accepted

Solution code:
#!/bin/env python3

N = int(input())

t_prev = x_prev = y_prev = 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    elif (abs(x_i - x_prev) + abs(y_i - y_prev)) > (t_i - t_prev):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
S=[(0,0,0)]
for i in range(N):
  t,x,y=map(int,input().split())
  S.append((t,x,y))
flag=0
for i in range(N):
  if abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2])>S[i+1][0]-S[i][0]:
    flag=1
    break
  elif (S[i+1][0]-S[i][0])%2==1 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==0:
    flag=1
    break
  elif (S[i+1][0]-S[i][0])%2==0 and (abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2]))%2==1:
    flag=1
    break

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

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int,input().split())) for _ in range(n)]
flag = 0
for i in range(n):
  if txy[i][0]<txy[i][1]+txy[i][2] or (txy[i][1]+txy[i][2])%2 != txy[i][0]%2:
    flag = 1
    print("No")
    break
if flag == 0:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
ans = "Yes"
x = 0
y = 0
t = 0
for i in range(N):
    t_i,x_i,y_i = map(int,input().split())
    x_i = abs(x_i-x)
    y_i = abs(y_i-x)
    t_i = abs(t_i-t)
    
    if x_i+y_i <= t_i and (x_i+y_i-t_i)%2 == 0:
        continue
    else:
        ans = "No"
    x = x_i
    y = y_i
    t = t_i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = "Yes"
x = 0
y = 0
t = 0
for i in range(N):
    t_i,x_i,y_i = map(int,input().split())
    x_i = abs(x_i-x)
    y_i = abs(y_i-x)
    t_i = abs(t_i-t)
    
    if x_i+y_i <= t_i and (x_i+y_i-t_i)%2 == 0:
        continue
    else:
        ans = "No"

print(ans)

Submission status: Accepted

Solution code:
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 j in range(1,N+1):
  #print(j, abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]), t[i]-t[i-1])
  if abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]) > t[i]-t[i-1]:
    flag=False
    break
  else:
    if (t[i]-t[i-1] - (abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])))%2 != 0:
      flag=False
      break
    
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
li = []
pre_t = 0
pre_x = 0
pre_y = 0
flag = True

for i in range(n):
    t,x,y = map(int,input().split())
    if (t-pre_t)%2 == (x-pre_x+y-pre_y)%2 and (t-pre_t) >= (x-pre_x + y-pre_y):
        pre_t = t
        pre_x = x
        pre_y = y
    else:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
array = [[int(x) for x in input().split()] for y in range(n)]
sorted(array, key = lambda x:x[0])
now_x = 0
now_y = 0
now_t = 0
for t,x,y in array:
  if t - now_t < abs(x-now_x)+abs(y-now_y):
    break
  elif (t-now_t - abs(x-now_x) - abs(y-now_y)) % 2 ==1:
    break
  x = now_x
  y = now_y
  t = now_t
else:
  print("Yes")
  exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())
p_t = 0
p_x = 0
p_y = 0
answer = 'Yes'
for _ in range(N):
  n_t, n_x, n_y = map(int, input().split())
  time = n_t - p_t
  distance = abs(n_x - p_x) + abs(n_y - p_y)
  if time < distance or time % 2 != distance % 2:
    answer = 'No'
    break
  p_t = n_t
  p_x = n_x
  p_y = n_y
print(answer)

Submission status: Accepted

Solution code:
N = int(input())
previous_p = [{'t': 0, 'x': 0, 'y': 0}]
next_p = [{'t': t, 'x': x, 'y': y} for _ in range(N) for t, x, y in [map(int, input().split())]]
previous_p += next_p

answer = 'Yes'
for p_p, n_p in zip(previous_p, next_p):
  time = n_p['t'] - p_p['t']
  distance = abs(n_p['x'] - p_p['x']) + abs(n_p['y'] - p_p['y'])
  if time < distance or time % 2 != distance % 2:
    answer = 'No'
    break
  
print(answer)

Submission status: Accepted

Solution code:
N = int(input())
Flag = True
x_bef = 0
y_bef = 0
t_bef = 0
for _ in range(N):
    t_now,x_now,y_now = map(int,input().split())
    t = t_now - t_bef
    x = abs(x_now - x_bef)
    y = abs(y_now - y_bef)
    if t - x - y < 0 :
        Flag = False
        break
    elif (t - x - y)%2 != 0:
        Flag = False
        break
print('Yes' if Flag else 'No')

Submission status: Accepted

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


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

    points = [tuple(map(int, input().split())) for i in range(n)]

    pre_t, pre_x, pre_y = 0, 0, 0
    flg = True
    for t, x, y in points:
        time = t - pre_t
        ido_kyori = abs(x - pre_x) + abs(y - pre_y)

        if ido_kyori > time or time % 2 != ido_kyori % 2:
            flg = False
            break

        pre_t, pre_x, pre_y = t, x, y

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

    points = [tuple(map(int, input().split())) for i in range(n)]

    pre_t, pre_x, pre_y = 0, 0, 0
    flg = True
    for t, x, y in points:
        sabun_t = t - pre_t
        sabun_x = abs(x - pre_x)
        sabun_y = abs(y - pre_y)

        temp = sabun_t - (sabun_x + sabun_y)
        if temp < 0 or temp % 2 == 1:
            flg = False
            break

        pre_t, pre_x, pre_y = t, x, y

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

plan = []
for i in range(N):
    plan += [[int(n) for n in input().split(' ')]]

ret = "Yes"
t0 , x0, y0 = 0, 0, 0
for t, x, y in  plan:
    dt = t-t0
    dx = abs(x-x0)
    dy = abs(y-y0)
    result = dt - (dx+dy)
    if result<0:
        ret = "No"
        break
    if result%2!=0:
        ret = "No"
        break
    t0, x0, y0 = t, x, y
print(ret)

Submission status: Accepted

Solution code:
n = int(input())
for _ in range(1, n+1):
    t, x, y = map(int, input().split())
    # x+yは毎秒ごとに必ず偶奇が入れ替わる、といったパリティに関する考え方が重要
    if (x + y) > t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
#086_C
n = int(input())
txy =[(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(n)]

flg = True
for i in range(n):
    ti, xi, yi = txy[i]
    tj, xj, yj = txy[i+1]
    if abs(xj-xi) + abs(yj-yi) > tj - ti:
        flg = False
        break
    elif (tj - ti - abs(xj-xi) - abs(yj-yi)) % 2:
        flg = False
        break
print('Yes' if flg else 'No')

Submission status: Accepted

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

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	li=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]
	td=[]
	for i in range(n):
		td.append((li[i+1][0]-li[i][0],abs(li[i+1][1]-li[i][1])+abs(li[i+1][2]-li[i][2])))

	ans="Yes"

	for t,d in td:
		if t<d or t%2!=d%2:
			ans="No"

	print(ans)
















if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N=int(input())
t=[list(map(int,input().split())) for i in range(N)]
t[0:0] = [[0,0,0]]
# print(t)
# print(len(t))

for i in range(N):
  mv=t[i+1][0]-t[i][0]
  d=abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2])
  diff=mv-d
  # print("mv:{}, d:{}, diff:{}".format(mv,d,diff))
  if not (diff>=0 and diff%2==0):
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    pos = [0, 0]
    time = 0
    flag = False

    for i in range(n):
        tmp = list(map(int, input().split()))
        time = tmp[0] - time
        dist = tmp[1] - pos[0] + tmp[2] - pos[1]
        if time < dist or (dist - time) % 2 == 1:
            flag = True
        pos = [tmp[1], tmp[2]]
        time = tmp[0]

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

Submission status: Accepted

Solution code:
N=int(input())
number=0
numbers=[[0,0,0]]
for a in range(N):
    list=[]
    t,x,y=map(int,input().split())
    list.append(t)
    list.append(x)
    list.append(y)
    numbers.append(list)
for a in range(N):
    b=numbers[a][1]+numbers[a][2]
    c=numbers[a+1][1]+numbers[a+1][2]
    if (numbers[a+1][0]-numbers[a][0])%2==0:
        if abs(c-b)%2==0 and abs(c-b)<=numbers[a+1][0]-numbers[a][0]:
            number+=1
        else:
            pass
    else:
        if abs(c-b)%2==1 and abs(c-b)<=numbers[a+1][0]-numbers[a][0]:
            number+=1
        else:
            pass
if number==N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

a.insert(0,[0,0,0])

can="Yes"
for i in range(n):
    kyori=abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2])
    dt=a[i+1][0] - a[i][0]
    if dt < kyori:
        can="No"
        break
    if dt%2 != kyori%2:
        can="No"
        break
print(can)

Submission status: Accepted

Solution code:
now, tx, ty, cant = [0]*4
for i in range(int(input())):
        t, nx, ny = map(int, input().split())
        k = abs(nx-tx)+abs(ny-ty)
        if k>t or k%2!=(t-now)%2: cant = 1
        now, tx, ty = t, nx, ny
print("YNeos"[cant::2])

Submission status: Accepted

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

time=0
sum_xy=0
for t,x,y in a:
    if t-time<abs(sum_xy-(x+y)) or (t-time)%2!=(sum_xy-(x+y))%2:
        print('No')
        exit()
    time=t
    sum_xy=x+y
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())

z=0
for i in range(n):
    t,x,y= map(int,input().split())
    if x+y <= t and (x+y)%2 == t%2:
        z+=1
        
if z==n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input()) 
TXY = [[0,0,0]] + [list(map(int, input().split())) for _ in range(n)]
diff = [[t2 - t1, abs(x2 - x1), abs(y2 - y1)] for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:])]
if all([x + y <= t and (t - (x + y)) % 2 == 0 for t, x, y in diff]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input()) 
TXY = [[0,0,0]] + [list(map(int, input().split())) for _ in range(n)]
diff = [[t2 - t1, abs(x2 - x1), abs(y2 - y1)] for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:])]
for t, x, y in diff:
  if x + y > t or (t - (x + y)) % 2 == 1:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input()) 
TXY = [list(map(int, input().split())) for _ in range(n)]
currT = 0
currX = 0
currY = 0
for t, x, y in TXY:
  nextT = t - currT
  nextStep = abs(x - currX) + abs(y - currY)
  if nextStep > nextT or (nextT - nextStep) % 2 == 1:
    print("No")
    exit()
  currT = t
  currX = x
  currY = y
print("Yes")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
from itertools import accumulate, groupby
mod = 10**9 + 7

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

n = ni()
tp, xp, yp = 0, 0, 0
for _ in range(n):
    t, x, y = na()
    ta, l = t-tp, abs(x - xp) + abs(y - yp)
    if ta >= l and ta % 2 ==l % 2:
        continue
    else:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
a0 = [0,0,0]
ans = "Yes"
for i in range(n):
    ai = list(map(int,input().split()))
    t = ai[0] - a0[0]
    d = abs(ai[1] - a0[1])+ abs(ai[2] - a0[2])
    if t < d or t%2 != d%2:
        ans = "No"
    a0 = ai
print(ans)

Submission status: Accepted

Solution code:
# 2020/03/14
# AtCoder Beginner Contest 086 - C

# Input
n = int(input())
nx = 0
ny = 0
nt = 0

# Check
ans = "Yes"
for i in range(n):
    t, x, y = map(int,input().split())
    dist = abs(nx - x) + abs(ny - y)
    et = t - nt
    if dist > et or (dist <= et and (dist - et) % 2 != 0):
        ans = "No"
        break
    nx = x
    ny = y
    nt = t

# Output
print(ans)

Submission status: Accepted

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

n=int(input())

pt=0
pxy=0
for i in range(n):
    t,x,y=map(int,input().split())
    dt=t-pt
    dxy=abs(x+y-pxy)
    if dxy>dt or dt%2!=dxy%2:
        print('No')
        exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
tx=ty=tt=0
for i in range(n):
  t,x,y=map(int,input().split())
  m=abs(x-tx)+abs(y-ty)
  if t<x+y or(t-tt)%2!=m%2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

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

nx, ny = 0, 0
time = 0

ans = "Yes"
for i in range(N):
    t, x, y = TXY[i]
    dt = t - time
    move = abs(nx - x) + abs(ny - y)
    if move > dt:
        ans = "No"
        break
    if dt % 2 != move % 2:
        ans = "No"
        break
    time, nx, ny = t, x, y

print(ans)

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"
tmp_x = 0
tmp_y = 0
tmp_t = 0
for i in range(n):
    #print((abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])))
    if (abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])) % 2 != (txy[i][0] - tmp_t) % 2 or (abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])) > txy[i][0] - tmp_t:
        ans = "No"
    tmp_x = txy[i][1]
    tmp_y = txy[i][2]
    tmp_t = txy[i][0]
print(ans)

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())
    d = (t-t_)-abs(x-x_)-abs(y-y_)
    if d < 0 or d%2 != 0:
        print('No')
        exit()
    else:
        t_ = t
        x_ = x
        y_  = y

else:
    print('Yes')

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
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 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()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
pt = 0
px = 0
py = 0
for _ in range(n):
    t, x, y = MAP()
    tmp = abs(x - px) + abs(y - py) - (t - pt)
    if tmp > 0 or tmp % 2 != 0:
        print('No')
        exit()
    px = x
    py = y
    pt = t
print('Yes')

Submission status: Accepted

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

ans = True
pre = (0,0,0)
for t,x,y in P:
    dt, dx, dy = t-pre[0], abs(x-pre[1]), abs(y-pre[2])
    if dt < dx+dy or (dt-(dx+dy))&1:
        ans = False
        break
    pre = (t,x,y)

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

Submission status: Accepted

Solution code:
# 距離的に到達可能か、経過時間と距離差の偶奇が一致してるか

N = int(input())
pt = 0
px = 0
py = 0
#ans = True
for _ in range(N):
    t,x,y = map(int,input().split())
    if abs(x-px) + abs(y-py) > t-pt:
        print('No')
        exit()
    if (abs(x-px) + abs(y-py))%2 != (t-pt)%2:
        print('No')
        exit()
    pt = t
    px = x
    py = y
print('Yes')

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    TXY = [[int(i) for i in input().split()] for j in range(N)]
    time, px, py = 0, 0, 0
    for t, x, y in TXY:
        move = abs(x-px) + abs(y-py)
        # print(move, t-time)
        if (t - time) % 2 != move % 2 or t - time < move:
            return print("No")
        time, px, py = t, x, y
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
txy = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N):
    t1, x1, y1 = txy[i]
    t2, x2, y2 = txy[i+1]
    if abs(x2-x1) + abs(y2-y1) <= t2 - t1 and (x1+y1+x2+y2) % 2 == (t2-t1) % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
# coding:utf-8
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())

    for i in range(1,n+1):
        idou  =  abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
        jikan = t[i]-t[i-1]
        if idou > jikan:
            print('No')
            exit()
        elif jikan %2 != idou%2:
            print('No')
            exit()
    print('Yes')


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())
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,X,Y =0,0,0
count = 0
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(t-T) >= abs((x+y)-(X+Y)) 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())
T,X,Y =0,0,0
count = 0
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(t-T) >= abs((x+y)-(X+Y)) 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())
lst = []
for _ in range(n):
    a = [int(x) for x in input().split()]
    lst.append(a)

possible = True
for i in range(n):
    if i == 0:
        dif = lst[i][1] + lst[i][2]
        tdif = lst[i][0]
    else:
        dif = abs((lst[i][1] + lst[i][2]) - (lst[i-1][1] + lst[i-1][2]))
        tdif = lst[i][0] - lst[i-1][0]
    if tdif < dif:
        possible = False
        break
    if (tdif - dif) % 2 != 0:
        possible = False
        break

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

Submission status: Accepted

Solution code:
N = int(input())
list=[[int(j) for j in input().split()] for i in range(N)]
#print(list[0][0]) # 配列の要素の抜出し

ans = 'Yes'
for n in range(N):
    dist = int(list[n][0])
    x = int(list[n][1])
    y = int(list[n][2])
    if dist < x + y:
        ans = 'No'
        break
    if dist % 2 != (x + y) % 2: #偶数奇数が一致していなければ
        ans = 'No'
        break

print(ans)

Submission status: Accepted

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

ans = 'Yes'

for line in lst:
    t, x, y = line
    c1 = t < x + y
    c2 = t % 2 == 0 and (x + y) % 2 != 0
    c3 = t % 2 != 0 and (x + y) % 2 == 0
    
    if c1 or c2 or c3:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
def main():

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

    t_p, x_p, y_p = 0, 0, 0
    for i in range(N):
        t, x, y = txy[i][0], txy[i][1], txy[i][2]
        diff_xy = abs(x - x_p) + abs(y - y_p)
        diff_t = t - t_p
        if diff_t < diff_xy or (diff_t % 2) != (diff_xy % 2):
            print('No')
            exit()
        t_p, x_p, y_p = t, x, y

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
Ki=[list(map(int,input().split())) for i in range(N)]
f=False
for i in Ki:
  t,x,y=i
  s=x+y
  if (t%2==0 and s%2!=0) or (t%2!=0 and s%2==0) or t<s:
    f=True
    break
if f:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
P = [list(map(int,input().split())) for i in range(N)]
flag = False
for tmp in P:
  t,x,y = tmp
  sum_ = x + y
  if (t % 2 == 0 and sum_ % 2 != 0) or (t % 2 != 0 and sum_ % 2 == 0) or t < sum_:
    flag = True
    break
if flag:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


N = int(input())
pt, px, py = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(x - px) + abs(y - py)
    # print(t, d)
    if t - pt < d or (t - pt - d) % 2 != 0:
        print("No")
        sys.exit()
    pt = t
    px = x
    py = y
print("Yes")

Submission status: Accepted

Solution code:
def main():
  n=int(input())
  T,X,Y=0,0,0
  for _ in [0]*n:
    t,x,y=map(int,input().split())
    if (t-T<abs(x-X)+abs(y-Y)) or (t-T+abs(x-X)+abs(y-Y))%2!=0:
      print('No')
      exit()
  print('Yes')
if __name__=='__main__':
  main()

Submission status: Accepted

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

t,x,y=(0,0,0)
for point in points:
    t_move, x_move, y_move=(point[0] - t ,point[1] - x, point[2] - y)
    t, x,y=(point[0], point[1], point[2])
    if t<abs(x_move + y_move)\
            or(t_move%2==0 and (x_move+y_move)%2!=0)\
            or(t_move%2!=0 and (x_move+y_move)%2==0):
        break
else:
    print("Yes")
    exit(0)
print("No")

Submission status: Accepted

Solution code:
a = int(input())
for n in list(range(a+1)):
  if n == 1:
    b,c,d = map(int, input().split())
    if c + d > b or (c + d - b) % 2 != 0:
      print('No')
      break
  if n >= 2:
    b1 = b
    c1 = c
    d1 = d
    b,c,d = map(int, input().split())
    if abs(c-c1) + abs(d-d1) > b-b1 or (abs(c-c1) + abs(d-d1) - (b-b1)) % 2 != 0:
      print('No')
      break
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
s = [map(int,input().split()) for i in range(n)]
t,x,y = (0,0,0)
for next_pos in s:
    t_next,x_next,y_next = next_pos
    dist = abs(x_next - x) + abs(y_next - y)
    dt = t_next - t
    if dist > t_next - t:
        print('No')
        break
    elif dt % 2 == dist % 2:
        t,x,y = t_next,x_next,y_next
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
ab = [[0,0,0]]
for _ in range(n):
    a, b, c = (int(x) for x in input().split())
    if abs(ab[-1][0]-a) >= abs(ab[-1][1]-b)+abs(ab[-1][2]-c) and abs(abs(ab[-1][0]-a)-abs(ab[-1][1]-b)-abs(ab[-1][2]-c))%2==0:
        ab.append([a,b,c])
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t, x, y =0, 0, 0
for i in range(n):
    next_t, next_x, next_y = map(int, input().split())
    dif = abs(next_x - x) + abs(next_y - y)
    if dif > (next_t - t) or (dif - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y = next_t, next_x, next_y
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    d = abs(nx-x)+abs(ny-y)
    
    if nt-t<d or d%2!=(nt-t)%2:
        print('No')
        exit()
    
    t, x, y = nt, nx, ny

print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
des=[list(map(int,input().split())) for _ in range(N)]
des.insert(0,[0,0,0])
for i in range(N):
    time=des[i+1][0]-des[i][0]
    d_x=abs(des[i+1][1]-des[i][1])
    d_y=abs(des[i+1][2]-des[i][2])
    if (time-(d_x+d_y))%2!=0 or time<(d_x+d_y):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

    for i in range(1, n+1):
        dt = t[i]-t[i-1]
        dx = x[i]-x[i-1]
        dy = y[i]-y[i-1]

        if abs(dx) + abs(dy) > dt:
            print("No")
            return 0

        if dt % 2 != (abs(dx)+abs(dy)) % 2:
            print("No")
            return 0
            
    print("Yes")

main()

Submission status: Accepted

Solution code:
N = int(input())
t,x,y = 0,0,0
badtrip=False
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    absx = abs(x-xi)
    absy = abs(y-yi) 
    if (absx+absy)%2 == (ti-t)%2 and (ti-t)>=(absx+absy):
        t=ti
        x=xi
        y=yi
    else:
        badtrip=True
        break

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

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int, input().split())) for l in range(n)]
for i in l:
  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:
flag = False
n = int(input())
t = [[0,0,0]]
for i in range(n):
    t.append( [int(x) for x in input().split()])
 
for  i in range(n):
    if (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2])) /  (t[i+1][0]-t[i][0]) > 1:
            flag = False
            break
    elif (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))   / ( t[i+1][0]-t[i][0])  == 1:
            flag = True
            continue
    else:
            if not (( t[i+1][0]-t[i][0]) - (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))  )  &1:
                flag = True
                continue
            else:
                flag = False
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
L = [tuple(map(int, input().split())) for _ in range(n)]
for t, x, y in L:
    vio1 = x + y > t
    vio2 = t % 2 == 0 and (x + y) % 2 != 0
    vio3 = t % 2 != 0 and (x + y) % 2 == 0
    if vio1 or vio2 or vio3:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
P = [[0, 0, 0]]
f = True
for i in range(n):
    t, x, y = map(int, input().split())
    s = abs(x - P[i][1]) + abs(y-P[i][2])
    if s > t-P[i][0] or (t-P[i][0] - s)%2 == 1:
        f = False
    P.append([t, x, y])
if f: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = 0, 0, 0
flg = True
for i in range(N):
  t, x, y = input().split()
  t, x, y = int(t),int(x),int(y)
  dt = t - t0
  dx = abs(x - x0)
  dy = abs(y - y0)
  if dx + dy > dt or (dt + dx + dy) % 2 != 0:
    flg = False
    break
print("Yes" if flg else "No")