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())
for _ in range(n):
    t, x, y = map(int, input().split())
    if t < x + y or (x + y + t) % 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
list=[]
flag=True
for i in range (N):
    tuple=input()
    input_list=tuple.split()
    input_list=[int(i) for i in input_list]
    list.append(input_list)
for i in range(N):
    time=list[i][0]
    distance=abs(list[i][1])+abs(list[i][2])
    if distance<=time:
        if distance%2==time%2:
            continue
        else:
            flag=False
    else:
        flag=False
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(n):
    t = rn[i + 1][0] - rn[i][0]
    distx = rn[i + 1][1] - rn[i][1]
    disty = rn[i + 1][2] - rn[i][2]
    k = abs(distx) + abs(disty)
    if (t >= k) and ((t + k) % 2 == 0):
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
x = 0
y = 0
t = 0
for i in range(n):
 t_new, x_new, y_new = map(int, input().split())
 l = abs(x_new - x) + abs(y_new - y)
 dt = t_new - t
 if (l <= dt) and (l % 2 == dt % 2 ):
  x = x_new
  y = y_new
  t = t_new
 else:
  #print(t, x, y) 
  print('No')
  exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

Plan = [list(map(int, input().split())) for _ in range(N)]
Plan.append([0,0,0])
flag = True
for i in range(N):
    if abs(Plan[i][0] - Plan[i + 1][0]) < abs(Plan[i][1] - Plan[i + 1][1]) + abs(Plan[i][2] - Plan[i + 1][2]):
        flag = False
        break
    elif abs(Plan[i][0] - Plan[i + 1][0])%2 != (abs(Plan[i][1] - Plan[i + 1][1]) + abs(Plan[i][2] - Plan[i + 1][2]))%2:
        flag = False
        break

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

Submission status: Accepted

Solution code:
n=int(input())
plan=[list(map(int,input().split())) for i in range(n)]
pret=0
prexy=0
for t,x,y in plan:
  t_diff=t-pret
  xy_diff=abs((x+y)-prexy)
  if t_diff>=xy_diff:
    if t_diff%2==0 and xy_diff%2==0:
      pass
    elif t_diff%2==1 and xy_diff%2==1:
      pass
    else:
      print('No')
      exit()
  else:
    print('No')
    exit()
  pret=t
  prexy=x+y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
TXY = [[int(x) for x in input().split()] for _ in range(N)]

now = [0,0,0]
for txy in TXY:     
    time = txy[0]-now[0]
    dist = abs(txy[1]-now[1])+abs(txy[2]-now[2])
    if time>=dist and (time%2)==(dist%2):
        now = txy
        continue 
    else:
        print("No") 
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

start_x, start_y = (0, 0)
isReachAble = False
for n in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-start_x) + abs(y-start_y)
    if (dist > t):
        print('No')
        exit()
    isTimeEven = t % 2 == 0
    isDestEven = (x + y) % 2 == 0
    if (isTimeEven and isDestEven) or (not isTimeEven and not isDestEven):
        isReachAble = True
    else:
        print('No')
        exit()

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
input_X = [[int(i) for i in input().split()] for i in range(n)]
X = np.array(input_X)

pre_t = 0
pre_x = 0
pre_y = 0
for i in range(n):
    x_move = abs(X[i][1] - pre_x)
    y_move = abs(X[i][2] - pre_y)
    xy_sum = x_move + y_move
    spend_time = X[i][0]-pre_t
    if xy_sum%2 == spend_time%2 and spend_time >= xy_sum:
        pre_t = X[i][0]
        pre_x = X[i][1]
        pre_y = X[i][2]
        if i+1 == n:
            print('Yes')
        else:
            continue
    else:
        print('No')
        break

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+x+y)%2 == 1):
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
flag = 1
t_,x_,y_ = [0,0,0]
for _ in range(N):
    t,x,y = list(map(int,input().split()))
    if ((t-t_)-abs(x-x_)-abs(y-y_))%2 == 1 or ((t-t_)-abs(x-x_)-abs(y-y_)) < 0:
        flag = 0
    t_,x_,y_ = [t,x,y]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
N = int(input())

origin_x = 0
origin_y = 0
origin_t = 0

for i in range(0,N):
    t,x,y = map(int, input().split())
    distance_x = abs(x - origin_x)
    distance_y = abs(y - origin_y)
    sub_t = t - origin_t
    if distance_x + distance_y > sub_t:
        print('No')
        sys.exit()
    elif (sub_t - distance_x - distance_y) % 2 == 0:
        origin_x = x
        origin_y = y
        origin_t = t
    else:
        print('No')
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
from collections import defaultdict, Counter

t = [ list(map(int, input().split())) for _ in range(N)]
diff = lambda a,b : abs(a[0] - b[0]) + abs(a[1] - b[1])

pos = (0,0)
tim = 0

for i in range(N):
    distance = diff(pos, t[i][1:])
    dis_time = t[i][0] - tim
    if not dis_time % 2 == distance %2 or not dis_time>=distance:
        print("No")
        exit(0)
print("Yes")
exit(0)

# d = defaultdict(int)
# 
# for _ in range(N):
#     s = input()
#     d[s[0]] += 1

# print(d)

ans = 0
charlist = list("MARCH")
for i in range(1<<5):
    if not Counter( list ( "{0:05b}".format(i)) )["1"] == 3:
        continue
    
    s = 1
    for e,i in enumerate(list("{0:05b}".format(i))):
        if i == "1":
            s *= d[ charlist[e] ]

    ans += s
print(ans)

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(1,n+1): t[i],x[i],y[i] = list(map(int,input().split()))

def distance(x1,y1, x2,y2):
    return abs(x1-x2) + abs(y1-y2)

def check_route(n,t,x,y):
    for i in range(n):
        dist = distance(x[i],y[i], x[i+1],y[i+1])
        if t[i+1] < dist: return "No"
        if (t[i+1] - t[i])%2 != dist%2: return "No"
    return "Yes"
        
print(check_route(n,t,x,y))

Submission status: Accepted

Solution code:
import math


def solve(N, TXYs):
    now = 0
    p = (0, 0)
    for t, x, y in TXYs:
        td = t - now
        dd = abs(p[0] - x) + abs(p[1] - y)
        if td % 2 != dd % 2 or td < dd:
            return "No"
        now = t
        p = (x, y)
    return "Yes"

if __name__ == "__main__":
    N = int(input())
    TXYs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(solve(N, TXYs))

Submission status: Accepted

Solution code:
n = int(input())

p = [None]*n

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

plan = [[0,0,0]]
plan.extend(p)

for i in range(n):
    diff = [plan[i+1][k] - plan[i][k] for k in range(len(plan[0]))]
    if (abs(diff[1])+abs(diff[2]))>diff[0] or (diff[0]-(abs(diff[1])+abs(diff[2])))%2==1:
        print('No')
        exit()

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())
sx=0
sy=0
st=0
flag=True
for i in range(N):
    l=abs(x[i]-sx)+abs(y[i]-sy)
    if flag==False:
        break
    if l<=(t[i]-st) and ((t[i]-st)-l)%2==0:
        flag=True
    else:
        flag=False
    sx=x[i]
    sy=y[i]
    st=t[i]
if flag==True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def create_decrement_list(num):
    decrement_list = []
    while(num >= 0):
        decrement_list.append(num)
        num -=2
    return decrement_list

def check_route(num_list, offset):
    is_path_possible = False
    for num in num_list:
        if offset == num:
            is_path_possible = True
            break
    return is_path_possible

def route_checker(N, list_t, list_x, list_y):
    for n in range(N):
        if n == 0:
            offset_x = abs(list_x[n])
            offset_y = abs(list_y[n])
        else:
            offset_x = abs (list_x[n] - list_x[n-1])
            offset_y = abs (list_y[n] - list_y[n-1])
        offset_total = offset_x + offset_y
        time_offset = list_t[n] if n==0 else list_t[n] - list_t[n-1]
        time_offset_list = create_decrement_list(time_offset)
        if check_route(time_offset_list, offset_total)==False:
            print("No")
            break
    else:
        print("Yes")

N = int(input())
t = []
x = []
y = []
# 要素を配列に格納
for i in range(N):
    a_list = list(map(int, input().split()))
    t.append(a_list[0])
    x.append(a_list[1])
    y.append(a_list[2])

route_checker(N, t, x, y)

Submission status: Accepted

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

for i in range(N):
    t_tmp = 0
    x_tmp = 0
    y_tmp = 0

    t_tmp, x_tmp, y_tmp = map(int, input().split())

    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

flag = 0

for i in range(N):
    judge = (t[i+1] - t[i]) - abs(x[i+1] - x[i]) - abs(y[i+1] - y[i])
    if judge % 2 == 1 or judge < 0:
        flag = 1
        break

if flag == 0:
    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 t < x + y or (x+y+t) % 2:
		print("No")
		exit()

print("Yes")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc086/tasks/arc089_a

N = int(input())


def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


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

# print(route)

reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

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

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    plan = [
        [int(x) for x in input().split()] for _ in range(N)
    ]
    plan = [[0, 0, 0]] + plan

    for i in range(1, N+1):
        t0, x0, y0 = plan[i-1]
        t, x, y = plan[i]
        dx = x - x0
        dy = y - y0
        d = abs(dx) + abs(dy)

        if t - t0 < d:
            return False

        if (t-t0-d)%2 != 0:
            return False

    return True


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

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
A = deque([list(map(int, input().split())) for _ in range(N)])
A.appendleft([0, 0, 0])
counter = 0
for i in range(N):
    if not (sum(A[i]) + sum(A[i + 1])) % 2:
        d = sum([abs(A[i][j] - A[i + 1][j]) for j in range(1, 3)])
        if A[i + 1][0] - A[i][0] >= d:
            counter += 1
if counter == N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline())
TXY = [
    tuple(map(int, sys.stdin.readline().split())) for _ in range(N)
]

def check(st, sx, sy, et, ex, ey):
    timespan = et - st
    diff = abs(sx - ex) + abs(sy - ey)
    if diff > timespan:
        return False
    if (timespan - diff) % 2 == 0:
        return True
    return False


def main():
    TXY.insert(0, (0, 0, 0))
    for i in range(len(TXY) - 1):
        args = TXY[i] + TXY[i + 1]
        if not check(*args):
            print('No')
            return
    print('Yes')

main()

Submission status: Accepted

Solution code:
N = int(raw_input())

data = []

for i in range(N):
    t, x, y = map(int, raw_input().split())
    data.append((t, x, y))


for d in data:
    t, x, y = d
    if t < x + y:
        print('No')
        exit()
    if (x+y)%2 != t%2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
# encoding:utf-8

import numpy as np
import random

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

def check_move(t,x,y):
    check = True
    #距離が長いとダメ
    if x+y > t:
        check = False
    #偶奇の組み合わせだとダメ
    elif x+y+t%2 == 1:
        check = False

    return check

answer = True
x_now = 0
y_now = 0
t_now = 0
for i in range(n):
    answer *= check_move(t[i]-t_now,x[i]-x_now,y[i]-y_now)
    t_now = t[i]
    x_now = x[i]
    y_now = y[i]

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

Submission status: Accepted

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

ans = 'Yes'
t0, x0, y0 = 0, 0, 0
for t, x, y in li:
    d = abs(x - x0) + abs(y - y0)
    if d > t - t0 or d % 2 != (t - t0) % 2:
        ans = 'No'
        break
    t0, x0, y0 = t, x, y

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
pos = "Yes"

# all lines shuld be tested.
for l in range(1, N+1):
  t1, x1, y1 = [int(l) for l in input().split()]
  result = abs(x1) + abs(y1)
  if result > t1:
    pos = "No"
    break
  elif result <= t1:
    if t1 % 2 == 0 and result %2 != 0:
    	pos = "No"
    	break
    elif t1 % 2 != 0 and result %2 == 0:
    	pos = "No"
    	break
    else:
      continue
  else:
      print("Error")

print(pos)

Submission status: Accepted

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

ans ="Yes"
kyori = abs(info[0][1])+abs(info[0][2])
zikan = info[0][0]
if not(kyori <= zikan and kyori%2 ==zikan%2):
  print("No")
  exit()
  
for i in range(1,n):
  kyori = abs(info[i][1]-info[i-1][1])+abs(info[i][2]-info[i-1][2])
  zikan = info[i][0]-info[i-1][0]
  if not(kyori <= zikan and kyori%2 ==zikan%2):
    ans ="No"
    break
    
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

route = [[0, 0, 0]]
judge = "Yes"
for _ in range(n):
  m = [int(i) for i in input().split()]
  route.append(m)
for i in range(1, n+1):
  delt = abs(route[i][0] - route[i-1][0])
  absx = abs(route[i][1] - route[i-1][1])
  absy = abs(route[i][2] - route[i-1][2])
#  print(delt, absx, absy)
#  s1 = delt >= (absx + absy)
# s2 = (delt - (absx +absy))
# print(s1, s2)
  if (delt >= (absx + absy)) and (delt - (absx +absy)) % 2 == 0:
    continue
  else:
    judge = "No"
    break
    
print(judge)

Submission status: Accepted

Solution code:
N = int(input())
tmp_t, tmp_x, tmp_y = 0, 0, 0
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    T = t - tmp_t
    D = abs(x - tmp_x) + abs(y - tmp_y)
    if T >= D and T%2 == D%2:
        pass
    else:
        flag = False
result = 'Yes' if flag else 'No'
print(result)

Submission status: Accepted

Solution code:
n = int(input())
 
start = 0
startX = 0
startY = 0
 
for i in range(n):
    t, x, y = map(int, input().split())
    t_diff = t - start
    dis = abs(x - startX) + abs(y - startY)
    if t_diff < dis or (dis + t_diff) % 2 != 0:
        print('No')
        exit()
    start, startX, startY = t, x, y
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t = []
x = []
y = []
for _ in range(n):
    ti, xi, yi = map(int,input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
for i in range(n):
    if ((x[i]+y[i])%2==0 and t[i]%2==1 or (x[i]+y[i])%2==1 and t[i]%2==0 or x[i]+y[i]>t[i]):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

ans = 'Yes'
for i in range(n):
    time = txy[i + 1][0] - txy[i][0]
    dist = abs(txy[i][1] - txy[i + 1][1]) + abs(txy[i][2] - txy[i + 1][2])
    if time - dist == 0:
        pass
    elif time - dist > 0 and (time - dist) % 2 == 0:
        pass
    else:
        ans = 'No'
        
print(ans)

Submission status: Accepted

Solution code:
count = int(input())
poslist = ["0 0 0"]
acheive = True
for n in range(count):
	poslist.append(input())
for i in range(count):
	cur,cx,cy = map(int,poslist[i].split())
	next,nx,ny  = map(int,poslist[i+1].split())
	dif = next - cur
	difx = nx - cx
	dify = ny - cy
	chk = dif- difx -dify
	if chk%2 != 0 or chk < 0:
		acheive = False
		break
if acheive:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
N=int(input())

x=0
y=0

for _ in range(N):
    ti,xi,yi=map(int,input().split())
    if ti - (abs(x-xi) + abs(y-yi))<0 or (ti - (abs(x-xi) + abs(y-yi)))%2==1:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))


n = int(input())

nt, nx, ny = 0, 0, 0
for _ in range(n):
    t, x, y = inpl()
    if (abs(nx-x)+abs(ny-y))%2 != (t-nt)%2 or abs(nx-x)+abs(ny-y) > t-nt:
        # print((abs(nx-x)+abs(ny-y))%2 != (t-nt)%2,abs(nx-x)+abs(ny-y) > t-nt)
        # print((abs(nx-x)+abs(ny-y))%2,(t-nt)%2)
        print("No")
        exit()
    nt, nx, ny = t, x, y
print("Yes")

Submission status: Accepted

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

ans = 'Yes'

for i in range(N):
    if t[i+1]-t[i]<abs(x[i+1]-x[i])+abs(y[i+1]-y[i]):
        ans = 'No'
        break
    elif ((t[i+1]-t[i])-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2!=0:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t = []
x = []
y = []
for _ in range(n):
    ti, xi, yi = map(int,input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
for i in range(n):
    if ((x[i]+y[i])%2==0 and t[i]%2==1 or (x[i]+y[i])%2==1 and t[i]%2==0 or x[i]+y[i]>t[i]):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

now = 0
p = [0,0]
for i in range(n):
    t = a[i][0] - now
    dis = abs(a[i][1] - p[0]) + abs(a[i][2] - p[1])
    
    if dis <= t:
        if t % 2 == 0:
            if dis % 2 != 0:
                print('No')
                exit()
        else:
            if dis % 2 != 1:
                print('No')
                exit()
    else:
        print('No')
        exit()
        
    p[0] = a[i][1]
    p[1] = a[i][2]
    now = a[i][0]
else:
    print('Yes')

Submission status: Accepted

Solution code:
import numpy as np
num = int(input())
ary = [[0, 0, 0]]
for _ in range(num):
    ary += [list(input().split())]
ary = np.array(ary, dtype=int)

dt = ary[1:, 0] - ary[:-1, 0]
dx = ary[1:, 1:] - ary[:-1, 1:]
dx = np.abs(dx).sum(axis=1)

if np.all(dt >= dx) and np.all((dt - dx) % 2 == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math
import sys

sys.setrecursionlimit(100000)

def solve():
    n = int(input())
    success_trip = True
    now_t, now_x, now_y = 0, 0, 0
    for i in range(n):
        next_t, next_x, next_y = map(int, input().split(' '))
        if success_trip:
            if not find_path(now_t, now_x, now_y, next_t, next_x, next_y):
                success_trip = False
            now_t, now_x, now_y = next_t, next_x, next_y
    
    if success_trip:
        print("Yes")
    else:
        print("No")

def find_path(now_t, now_x, now_y, next_t, next_x, next_y):
    time = next_t - now_t
    return recursion_find(time, now_x, now_y, next_x, next_y)
    
def recursion_find(time, now_x, now_y, target_x, target_y):
    # print("-----------")
    # print("time:", time)
    # print("now_x:", now_x)
    # print("now_y:", now_y)
    # print("target_x:", target_x)
    # print("target_y:", target_y)
    # print("-----------")

    if (abs(target_x - now_x) + abs(target_y - now_y) - time) % 2 == 1:
        # cant
        return False

    if time == 0:
        if now_x == target_x or now_y == target_y:
            return True
        else:
            return False
    else:
        # distant
        if time < abs(target_x - now_x) + abs(target_y - now_y):
            # cant
            return False
            
        if recursion_find(time-1, now_x-1, now_y, target_x, target_y):
            return True
        elif recursion_find(time-1, now_x, now_y-1, target_x, target_y):
            return True
        elif recursion_find(time-1, now_x+1, now_y, target_x, target_y):
            return True
        elif recursion_find(time-1, now_x, now_y+1, target_x, target_y):
            return True
        else: 
            return False

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

def hantei(t, z):
    if t >= z and t % 2 == z % 2:return 'Y'
    else: return 'N'
    
E.insert(0, [0, 0 , 0])

a=''
for i in range(1, len(E)):
    if 'Y' == hantei(E[i][0] - E[i-1][0] , (E[i][1] + E[i][2]) - (E[i-1][1] + E[i-1][2])):
        continue
    else:
        a = 'No'
        break
if a != 'No':
    a = 'Yes'
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
flag = True
for i in range(N):
    nt = txy[i+1][0]
    nx = txy[i+1][1]
    ny = txy[i+1][2]
    t = txy[i][0]
    x = txy[i][1]
    y = txy[i][2]
    move = nt - t
    tmp = abs(nx-x)+abs(ny-y)
    if move >= tmp:
        if abs(move-tmp) % 2 != 0:
            print('No')
            exit()
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
flag = True
for i in range(N):
    nt = txy[i+1][0]
    nx = txy[i+1][1]
    ny = txy[i+1][2]
    t = txy[i][0]
    x = txy[i][1]
    y = txy[i][2]
    move = nt - t
    tmp = abs(nx-x)+abs(ny-y)
    if move >= tmp:
        if abs(move-tmp) % 2 != 0:
            flag = False
            break
    else:
        flag = False
        break
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
import sys
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t[i],x[i],y[i] = [int(n) for n in input().split()]
dt = t[0]
d = x[0] + y[0]
if(dt < d or dt%2 != d%2):
    print("No")
    sys.exit()
for i in range(1,N):
    dt = t[i] - t[i-1]
    d = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if(dt < d or dt%2 != d%2):
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= [0]
l = [0]
m=[]
co = range(1,10**5+2,2)
ce = range(0,10**5+2,2)
f = 1
def say(i):return print("Yes" if i == 1 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
#def rep(i):return for i in range()
def addarray(k,l):
    for i in range(n):
        a ,b,c = map(int,input().split())
        k.append(a)
        l.append(b+c)
n = ai()
addarray(k,l)
for i in range(1,n+1):
    t = k[i]-k[i-1]
    if t%2==1 and abs(l[i]-l[i-1]) in co[:t//2+1]:
        f = 1
    elif t%2==0 and abs(l[i]-l[i-1]) in ce[:t//2+1]:
        f = 1
    else:
        f = 0
        break
say(f)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):

    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    # 時刻ｔにx, yを訪れる
    # t+1 で (x+1, y), (x-1, y), (x, y+1), (x, y-1)に移動
    T = [0] * (N + 1)
    X = [0] * (N + 1)
    Y = [0] * (N + 1)
    for n in range(N):
        t = il()
        T[n + 1] = t[0]
        X[n + 1] = t[1]
        Y[n + 1] = t[2]
    for i in range(N):
        dt = T[i + 1] - T[i]
        dst = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
        if dt < dst or dt % 2 != dst % 2:
            return "No"
    return "Yes"


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

Submission status: Accepted

Solution code:
N = int(input())
data = [list(map(int,input().split())) for l in range(N)] 
data = [[0,0,0]] + data

for i in range(1,N+1):
    t_a,t_b = data[i][0],data[i-1][0]
    x_a,x_b = data[i][1],data[i-1][1]
    y_a,y_b = data[i][2],data[i-1][2]

    x_d = x_a - x_b
    y_d = y_a - y_b

    check = t_a - t_b - abs(x_d) - abs(y_d)
    if (check >= 0) and (check%2 == 0):
        continue
    else:
        print('No')
        exit()
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l_t = []
l_pos = []

l_pos.append([0, 0])
l_t.append(0)
# input
for i in range(n):
    a, b, c = (list)(map(int, input().split()))
    l_t.append(a)
    l_pos.append([b, c])


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos1[1]-pos2[1])


# check
ans = 'Yes'
for i in range(n):
    dis = manhattan(l_pos[i], l_pos[i+1])
    time = abs(l_t[i+1]-l_t[i])
    if dis > time:
        ans = 'No'
        break
    elif dis % 2 != time % 2:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
txy = []
for i in range(N):
    txy.append(list(map(int,input().split())))
flag = 0
if N == 1:
    dt = txy[0][0]
    dx = txy[0][1]
    dy = txy[0][2]
    if (dx+dy-dt)%2 == 0 and (dx+dy) <= dt:
        pass
    else:
        flag = 1
        print("No")
for j in range(N-1):
    if j == 0:
        dt = txy[0][0]
        dx = txy[0][1]
        dy = txy[0][2]
    else:
        dt = txy[j+1][0]-txy[j][0]
        dx = abs(txy[j+1][1]-txy[j][1])
        dy = abs(txy[j+1][2]-txy[j][2])
    if (dx+dy-dt)%2 == 0 and (dx+dy) <= dt:
        pass
    else:
        flag = 1
        print("No")
        break
if flag == 0:
    print("Yes")

Submission status: Accepted

Solution code:

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

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

    return n, points


def check_transition(point1, point2):
    t_diff = point2[0] - point1[0]
    x_diff = point2[1] - point1[1]
    y_diff = point2[2] - point1[2]

    x_diff = abs(x_diff)
    y_diff = abs(y_diff)

    distance = x_diff + y_diff

    if t_diff >= distance:
        if t_diff % 2 == distance % 2:
            return True

    return False


def check_all_transition():
    n, points = read_input()
    for p1, p2 in zip(points, points[1:]):
        if not check_transition(p1, p2):
            return False
    return True


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

Submission status: Accepted

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

for _ in range(N):
    t, _x, _y = map(int, input().split())
    dist = abs(_y - y) + abs(_x - x)
    if dist > t or (t - dist) % 2 == 1:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

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

temp_t, temp_x, temp_y = 0, 0, 0
is_reachable = True
for t, x, y in l:
    diff_t = t - temp_t
    diff_x = abs(x-temp_x)
    diff_y = abs(y-temp_y)
    distance = diff_x + diff_y
    if diff_t < distance or diff_t%2 != distance%2:
        print("No")
        is_reachable = False
        break

if is_reachable:
    print("Yes")

Submission status: Accepted

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

ans = 'Yes'
count = 0
for i in range(n):
    count += abs(A[i][1] - A[i+1][1]) + abs(A[i][2] - A[i+1][2])
    time = A[i+1][0]
    if time < count:
        ans = 'No'
    elif (time - count) % 2 != 0:
        ans = 'No'
    else:
        count += (time -count)
            
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
now = [0, 0, 0]

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