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())
li=[]
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break

#ans=Trueにしておいて、チェックにひっ掛かったらFalseに変える
ans=True

#設定より負の値になっていればNO
for i in range(n):
    if li[i][1]>=0 and li[i][2]>=0:
        continue
    ans=False
    print('No')
    break
        
        
#進める最大値よりも先に存在した場合にNOを出す
if ans==True:
    for j in range(n):
        if li[j][0]>=li[j][1]+li[j][2]:
            continue
        ans=False
        print('No')
        break
#秒数とマス目の和の偶奇を調べる
if ans==True:        
    for k in range(n):
        if li[k][0]%2==(li[k][1]+li[k][2])%2:
            continue
        ans=False
        print('No')
        break
        
if ans==True:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
txy.insert(0,[0,0,0])
for i in range(n):
  d=txy[i+1][1]-txy[i][1]+txy[i+1][2]-txy[i][2]
  t=txy[i+1][0]-txy[i][0]
  if not(d<=t and t%2==d%2):
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	current = [0,0,0]
	flag = True
	for i in range(int(input())):
		c = list(map(int,input().split()))
		mh = abs(c[1]-current[1]) + abs(c[2]-current[2])
		if(abs(c[0]-current[0])%2 != mh%2 or abs(c[0]-current[0]) < mh):
			flag = False
		current = c
	if flag:
		print('Yes')
	else:
		print('No')
main()

Submission status: Accepted

Solution code:
from sys import exit

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

for i in range(N):
    d = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1])
    s = t[i+1] -t[i]
    if d > s or d%2!=s%2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
N=int(input())

t = [0]
x = [0]
y = [0]
for i in range(N):
    t1,x1,y1=[int(i) for i in input().split()]
    t.append(t1)
    x.append(x1)
    y.append(y1)

flag=True

for i in range(N):
    zahyo=abs(x[i]-x[i+1])+abs(y[i]-y[i+1])
    jikansa=t[i+1]-t[i]
    if zahyo<=jikansa and zahyo%2==jikansa%2:
        continue
    else:
        flag=False
        break

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

Submission status: Accepted

Solution code:
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
move = []
move.append([a[0][0], a[0][1], a[0][2]])
for i in range(1, n):
    move.append([a[i][0]-a[i-1][0], abs(a[i][1]-a[i-1][1]), abs(a[i][2]-a[i-1][2])])

for i in range(n):
    t = move[i][0]
    x = move[i][1]
    y = move[i][2]
    if x+y>t or (x+y)%2!=t%2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

ls = [[0, 0, 0]]
ls.extend(ls0)

for i in range(n):
	dst = ls[i+1][0] - ls[i][0]
	dsx = abs(ls[i+1][1] - ls[i][1])
	dsy = abs(ls[i+1][2] - ls[i][2])
	if dst < dsx + dsy:
		print('No')
		break
	elif (dst - (dsx + dsy)) % 2 == 1:
		print('No')
		break
	elif i == n - 1:
		print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
tt = [0]
xx = [0]
yy = [0]
for i in range(n):
    t,x,y = map(int,input().split())
    tt.append(t)
    xx.append(x)
    yy.append(y)
ans = "Yes"

for i in range(1,n+1):
    dist = abs(xx[i]-xx[i-1]) + abs(yy[i]-yy[i-1])
    time = tt[i]-tt[i-1]
    if time < dist or (time - dist)%2 != 0:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
tt = []
xx = []
yy = []
for i in range(n):
    t,x,y = map(int,input().split())
    tt.append(t)
    xx.append(x)
    yy.append(y)
ans = "Yes"

for i in range(n):
    if i == 0:
        dist = xx[i] + yy[i]
        time = tt[i]
    else:
        dist = abs(xx[i]-xx[i-1]) + abs(yy[i]-yy[i-1])
        time = tt[i]-tt[i-1]
    if time < dist or (time - dist)%2 != 0:
        ans = "No"
        break

print(ans)

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:
#10 abc086 c-traveling
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
for _ in range(n):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(next_x - x) + abs(next_y - y)
    if ((next_t - t) < diff) or (diff - (next_t - t)) % 2 ==1:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0
for i in range(int(input())):
  next_t, next_x, next_y = map(int, input().split())
  diff = abs(x - next_x) + abs(y - next_y)

  if diff > (next_t - t) or (diff - (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())

t0, x0, y0 = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - t0
    dx = x - x0
    dy = y - y0
    dxy = abs(dx) + abs(dy)  #; print(dt, dx, dy, dxy) 
    if dt%2 == dxy%2 and dxy <= dt :
        t0, x0, y0 = t, x, y
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

t0, x0, y0 = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - t0
    dx = x - x0
    dy = y - y0
    dxy = abs(dx) + abs(dy)  #; print(dt, dx, dy, dxy) 
    isEvenOdd = (dt%2 == 0 and dxy%2 == 0) or (dt%2 != 0 and dxy%2 != 0)
    if isEvenOdd and dxy <= dt :
        t0, x0, y0 = t, x, y
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
N = int(readline())
t = []
x = []
y = []
for i in range(N):
    _t, _x, _y = list(map(int, readline().split()))
    t.append(_t)
    x.append(_x)
    y.append(_y)

p = [0, 0]
pt = 0
px = 0
py = 0
f = True
for i in range(N):
    a = t[i] - pt
    b = abs(px - x[i]) + abs(py - y[i])
    # 距離が足りないかt~t+1間の座標の差のと偶奇が一致しない場合はたどり着けない
    if a < b or (a % 2 != b % 2):
        f = False
        break
    px = x[i]
    py = y[i]
    pt = t[i]

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

Submission status: Accepted

Solution code:
n = int(input())
t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

result = "Yes"

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

for i in range(n + 1):
    if i == 0:
        continue
    time = t[i] - t[i-1]
    kyori = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if time < kyori:
        result = "No"
        break
    elif t[i] % 2 != (x[i] + y[i]) % 2:
        result = "No"
        break

print(result)

Submission status: Accepted

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

l = len(p_list)

for i in range(l):
        if p_list[i][0] < (p_list[i][1] + p_list[i][2]) or p_list[i][0] % 2 != (p_list[i][1] + p_list[i][2]) % 2:
                print('No')
                exit(0)
        for j in range(3):
                if i != l-1:
                        p_list[i+1][j] -= p_list[i][j]

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] = map(int, input().split())

ans = 'Yes'
for i in range(1,n+1):
    time_diff = t[i] - t[i-1]
    x_diff = abs(x[i] - x[i-1])
    y_diff = abs(y[i] - y[i-1])
    if (time_diff < x_diff+y_diff or (time_diff-x_diff-y_diff)%2 != 0):
        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())
    if (t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]): #最短でも無理な場合
        print("No")
        break
    elif t[i]%2 != (x[i]+y[i])%2: #止まれないか
        print("No")
        break
    if i == N:
        print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
result = "Yes"
if N == 1:
    t,x,y = map(int,input().split())
    if (x+y+t) % 2 == 0 and x+y<=t and x+y+t>=0:
        pass
    else:
        result = "No"
else:
    S = [[int(i) for i in input().split()] for i in range(N)]
    for i in range(N-1):
        a,b = S[i],S[i+1]
        dt = b[0]-a[0]
        dx = b[1]-a[1]
        dy = b[2]-a[2]
        if (dx+dy+dt) % 2 == 0 and dx+dy<=dt and dx+dy+dt>=0:
            pass
        else:
            result = "No"
            break
print(result)

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())
A = [[0,0,0]]
for _ in range(N):
    A += [list(map(int,input().split()))]


def is_even(num):
    if num %2 ==0:
        return 0
    else:
        return 1

a = 0
for i in range(N):
    start = A[i][1]+A[i][2]
    goal = A[i+1][1]+A[i+1][2]
    if is_even(A[i+1][0] - A[i][0]) == is_even(start - goal):
        if abs(A[i][1]-A[i+1][1])+abs(A[i][2]-A[i+1][2]) <= (A[i+1][0] - A[i][0]):
            a += 1
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
txy = I[1:].reshape(-1, 3)

def main():
    t1, x1, y1 = txy[0]
    d1 = x1 + y1
    if d1 > t1 or (t1 - d1) & 1:
        return 'No'
    dt, dx, dy = np.absolute(np.transpose(txy[1:] - txy[:-1]))
    d = dx + dy

    return 'No' if np.any(np.logical_or(d > dt, (dt - d) & 1)) else 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
coordinate_list = []
t_init = 0
x_init = 0
y_init = 0
count = 0

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

for coordinate in coordinate_list:
    flag = True
    t, x, y = coordinate[0], coordinate[1], coordinate[2]
    t -= t_init
    x -= x_init
    y -= y_init
    t_init, x_init, y_init = coordinate[0], coordinate[1], coordinate[2]
    if t >= abs(x) + abs(y):
        if t % 2 == 0 and x % 2 == 0 and y % 2 == 0 or t % 2 == 0 and x % 2 == 1 and y % 2 == 1:
            flag = False
        elif t % 2 == 1 and x % 2 == 1 and y % 2 == 0 or t % 2 == 1 and x % 2 == 0 and y % 2 == 1:
            flag = False
    
    if flag:
        break
    count += 1

if n == count:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
  a,b,c = map(int, input().split())
  t.append(a)
  x.append(b)
  y.append(c)
dt = t[i+1]-t[i]
dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
ans = ""
for i in range(N):
  if dt < dist:
    ans = "No"
    break
  if (dt%2 == 0 and dist%2 == 0) or (dt%2 == 1 and dist%2 == 1):
    ans = "Yes"
  else:
    ans = "No"
    break
print(ans)

Submission status: Accepted

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

def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
# print(t_list)
# print(x_list)
# print(y_list)

is_reachable = False
for i in range(N):
    # t = 0, (x, y) = (0, 0)
    num_steps = t_list[i+1] - t_list[i]
    x_dist = abs(x_list[i+1] - x_list[i])
    y_dist = abs(y_list[i+1] - y_list[i])
    dist = x_dist + y_dist
    # print('i:', i, 'num_steps:', num_steps, 'distance:', dist)
    # print(num_steps >= dist and is_even(num_steps) == is_even(dist))

    if num_steps >= dist and is_even(num_steps) == is_even(dist):
        is_reachable = True
    else:
        is_reachable = False
        break

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
A = [[0,0,0]]
for _ in range(N):
    A.append([int(x) for x in input().split()])
A = np.array(A)
for i in range(1, N+1):
    A_ = abs(A[i] - A[i-1])
    if A_[0] < A_[1] + A_[2]:
        print("No")
        sys.exit()
    A_mod = (A_[1] + A_[2]) % 2
    if A_[0] % 2 != A_mod:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
t1=0
x1=0
y1=0
out='Yes'
for i in range(N):
  t2, x2, y2=map(int, input().split())
  if (t2-t1)%2!=(abs(x2-x1)+abs(y2-y1))%2 or (t2-t1)<abs(x2-x1)+abs(y2-y1):
    out='No'
  t1=t2
  x1=x2
  y1=y2
print(out)

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
  ti, xi, yi = map(int, input().split())
  d = abs(xi - x) + abs(yi - y)
  dt = ti - t
  if d > dt or d % 2 != dt % 2:
    print("No")
    break
  t, x, y = ti, xi, yi
else:
  print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
nx=0
ny=0
nt=0
for i in range(n):
  t,x,y=map(int,input().split())
  k=abs(x-nx)+abs(y-ny)
  if k>t-nt:
    print("No")
    exit()
  elif k%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] * (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())

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) or (dt%2 != dist%2): #t=1でx+yが奇数でt=2でx+yが偶数
        can = 'No'

print(can)

Submission status: Accepted

Solution code:
N=int(input())
t0,x0,y0=0,0,0
for i in range(N):
    ti,xi,yi = map(int,input().split())
    dT,dX,dY = abs(t0-ti),abs(x0-xi),abs(y0-yi)
    if dT>=dX+dY:
        if dT%2==(dX+dY)%2:
            t0,x0,y0 = ti,xi,yi
            continue
        else:
            print('No')
            exit()
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
info = [list(map(int,input().split())) for i in range(n)]
info = [[0,0,0]] + info
#点iと点i-1の時間と距離の差を計算
dif_time_length = [0 for _ in range(n)]
cnt = 0
for pre_i,i in zip(info,info[1::]):
    dif_time_length[cnt] = (i[0]-pre_i[0],abs(i[1]-pre_i[1]) + abs(i[2]-pre_i[2]))
    cnt+=1

def solve():
    for i in info:
        if i[0]%2!=(i[1]+i[2])%2:
            return "No"
    for t,d in dif_time_length:
        if t<d:
            return "No"
    return "Yes"
print(solve())

Submission status: Accepted

Solution code:
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
ans = 'Yes'

for a in A:
    if a[0] % 2 == 0:
        if (a[1] + a[2]) % 2 != 0 or (a[1] + a[2]) > a[0]:
            ans = 'No'
            break
    else:
        if (a[1] + a[2]) % 2 == 0 or (a[1] + a[2]) > a[0]:
            ans = 'No'
            break

print(ans)

Submission status: Accepted

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

for _ in range(n):
    travel_list.append(list(map(int, input().split())))

complete = True
for i in range(n):
    time = travel_list[i+1][0] - travel_list[i][0]
    x_distance =  abs(travel_list[i+1][1] - travel_list[i][1])
    y_distance =  abs(travel_list[i+1][2] - travel_list[i][2])
    xy_distance = x_distance + y_distance

    if time >= xy_distance:
        if time % 2 != xy_distance % 2:
            complete = False
            break
    else:
        complete = False
        break       

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

Submission status: Accepted

Solution code:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
time, x, y = 0, 0, 0
for i in range(N):
    timei, xi, yi = A[i][0], A[i][1], A[i][2]
    time = timei - time
    x = xi - x
    y = yi - y
    move = x + y
    if time >= move:
        if(move*time)%2==1 or (move*time)%4==0:
            ans = "Yes"
        else:
            ans = "No"
            break
    else:
        ans = "No"
        break
    time, x, y = timei, xi, yi
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
tlist = [0]
xlist = [0]
ylist = [0]
for i in range(n):
  a = list(map(int,input().split()))
  tlist.append(a[0])
  xlist.append(a[1])
  ylist.append(a[2])

count = 0
for i in range(n):
  dt = tlist[i+1] - tlist[i]
  dis = abs(xlist[i+1]-xlist[i]) + abs(ylist[i+1]-ylist[i])
  if dis > dt:
    print("No")
    exit()
  else:
    if dt%2 == 0 and dis%2==0:
      count +=1
    elif dt%2 == 1 and dis%2==1:
      count +=1
    else:
      print("No")
      exit()
      
      
if count == n:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
flag = 'Yes'
txy = [[0,0,0]]
for i in range(N):
    a = list(map(int,input().split()))
    txy.append(a)
    td = txy[i+1][0] - txy[i][0]
    xd = abs(txy[i+1][1] - txy[i][1])
    yd = abs(txy[i+1][2] - txy[i][2])
    if (td < xd + yd) or ((td-(xd+yd))%2 == 1):
        flag = 'No'
print(flag)

Submission status: Accepted

Solution code:
N = int(input())
flag = 'Yes'
for i in range(N):
    t,x,y = map(int,input().split())
    if (t < x + y) or ((t-(x+y))%2 == 1):
        flag = 'No'
print(flag)

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

tm = 0 
t_x = 0 
t_y = 0 
ans = "Yes"

for i in range(N):
        if abs(t_x - x[i]) + abs(t_y - y[i]) <= t[i] - tm and ((t[i] % 2 == 0) == ((x[i] + y[i]) % 2 == 0)):
                pass
        else:
                ans = "No"

        t_x = x[i]
        t_y = y[i]
        tm = t[i]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
A = 'Yes'
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t_list.append(ti)
    x_list.append(xi)
    y_list.append(yi)
    if ((abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i]) > (t_list[i+1] - t_list[i]))):
        A = 'No'
        break
    if (x_list[i+1] + y_list[i+1] - t_list[i+1])%2 != 0:
        A = 'No'
        break
print(A)

Submission status: Accepted

Solution code:
n = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(n):
    T, X, Y = map(int, input().split())
    t.append(T)
    x.append(X)
    y.append(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
    elif dist%2 != dt%2:
        can = False
        
print('Yes' if can else 'No')

Submission status: Accepted

Solution code:
n=int(input())
d=[(0,0,0)]+[tuple(map(int,input().split())) for _ in range(n)]
ans = 'Yes'
for i in range(n):
	dt = d[i+1][0]-d[i][0]
	dd = abs(d[i+1][1]-d[i][1])+abs(d[i+1][2]-d[i][2])
	if dt < dd or dt%2!=dd%2:
		ans='No'
		break
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
t=[]
x=[]
y=[]
for i in range(N):
    t1, x1, y1=map(int, input().split())
    t.append(t1)
    x.append(x1)
    y.append(y1)
for j in range (N):
    if t[j]%2==(x[j]+y[j])%2 and x[j]+y[j]<=t[j]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
t=[]
x=[]
y=[]
for i in range(N):
    t1, x1, y1=map(int, input().split())
    t.append(t1)
    x.append(x1)
    y.append(y1)
for j in range (N):
    if t[j]%2==(x[j]+y[j])%2 and x[j]<=t[j] and y[j]<=t[j] and x[j]+y[j]<=t[j]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
N = int(input())
txy2 = [list(map(int,input().split())) for _ in range(N)]
txy = [[0,0,0]]
for i in range(N):
    txy.append(txy2[i])
for i in range(N):
    if abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2]) > txy[i+1][0]-txy[i][0]:
        print("No")
        sys.exit()
    elif ((txy[i+1][0]-txy[i][0]) - (abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])))%2 != 0:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
prev_time = 0
prev_x = 0
prev_y = 0
for i in range(n):
  time, x, y = map(int,input().split())
  diff = (time - prev_time) - (x-prev_x) - (y - prev_y)
  if diff >= 0 and diff % 2 == 0:
    prev_time = time
    prev_x = x
    prev_y = y
  else:
    print("No")
    sys.exit()
print("Yes")

Submission status: Accepted

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

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
L.insert(0, [0,0,0])
flag='Yes'
for i in range(1, n+1):
    tmp = L[i][0] - L[i-1][0] -abs(L[i][1] - L[i-1][1]) - abs(L[i][2] - L[i-1][2])
    if tmp<0 or tmp%2!=0:
        flag='No'
        break
print(flag)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
plan = [tuple(map(int, input().split())) for _ in range(n)]
plan.insert(0, (0, 0, 0))
for i in range(1, n + 1):
    time_limit = plan[i][0] - plan[i - 1][0]
    distance = abs(plan[i][1] - plan[i - 1][1]) + \
        abs(plan[i][2] - plan[i - 1][2])
    if time_limit < distance or (time_limit % 2 != distance % 2):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

count = 0
for i in range(1, len(t)):
    dt = t[i]-t[i-1]; dist = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if dist > dt:
        break
    else:
        if (dt%2==0 and dist%2==0) or (dt%2==1 and dist%2==1):
            count = count + 1

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

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

# 5秒後に存在できるのは距離が5, 3, 1のときだけ

for a in A:
	t, x, y = a
	d = x+y
	if t < d or d%2 != t%2:
		print('No')
		sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
t1 = x1 = y1 = 0

num = int(input())

for i in range(num):
    t2,x2,y2 = map(int, input().split())

    if (x2-x1 + y2-y1) > (t2-t1):
        print('No')
        exit()
    elif ((t2-t1)-(x2-x1 + y2-y1) ) % 2 == 0:
        t1=t2
        x1=x2
        y1=y2
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

flg = False
for point in points:
  flg = (point[0] >= (point[1] + point[2])) and ((point[0] % 2 == 1) and ((point[1] + point[2]) % 2 == 1) or (point[0] % 2 == 0) and ((point[1] + point[2]) % 2 == 0))
  if not flg:
    break
print('Yes') if flg else print('No')

Submission status: Accepted

Solution code:
N = int(input())
now_x = 0
now_y = 0
now_t = 0
for i in range(N):
    t,x,y = map(int, input().split())
    margin = (t- now_t) - abs(x - now_x) - abs(y - now_y)
    if margin < 0 or margin%2!=0:
        print("No")
        break
    else:
        now_x = x
        now_y = y
        now_t = t
else:
    print("Yes")

Submission status: Accepted

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

t = 0
x = 0
y = 0
i = 0
flag = True
for i in range(n):
    if abs(l[i][1]-x)+abs(l[i][2]-y) <= l[i][0]-t:
        if (l[i][0]-t) % 2 != (l[i][1]-x + l[i][2]-y) % 2:
            flag = False
            break
    else:
        flag = False
        break
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]

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

Submission status: Accepted

Solution code:
N = int(input())

x = 0
y = 0

for _ in range(N):
    t, a, b = [int(i) for i in input().split()]

    diff_a = abs(a - x)
    diff_b = abs(b - x)

    p = t - (diff_a + diff_b)
    if p < 0 or p % 2 != 0:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
txy = [LIST() for _ in range(N)]

def dist(p1, p2):
	return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

now = [0, 0]
time = 0
for t, x, y in txy:
	if (t-time) < dist(now, [x, y]) or ((t-time) - dist(now, [x, y]))%2!=0:
		print("No")
		break
	time = t
	now[0] = x
	now[1] = y
else:
	print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
t=0
x=0
y=0
flag=True
for i in range(n):
    tt=l[i][0]-t
    d=abs(l[i][1]-x)+abs(l[i][2]-y)
    if tt<d or tt%2!=d%2:
        flag=False
    t=l[i][0]
    x=l[i][1]
    y=l[i][2]
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

N = int(input())
txy = [[0, 0, 0]]
for n in range(N):
    txy.append([int(i) for i in input().split()])

for n in range(N):
    now_time = txy[n][0]
    now_x = txy[n][1]
    now_y = txy[n][2]
    next_time = txy[n+1][0]
    next_x = txy[n+1][1]
    next_y = txy[n+1][2]

    interval = abs(next_time - now_time)

    distance_x = abs(next_x - now_x)
    distance_y = abs(next_y - now_y)
    distance_sum = distance_x + distance_y

    if distance_sum > interval:
        print('No')
        break
    else:
        margin = interval - distance_sum
        if margin % 2 != 0:
            print('No')
            break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t0=0
x0=0
y0=0

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

Submission status: Accepted

Solution code:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
if a[0][0] >= a[0][1] + a[0][2] and (a[0][0] - a[0][1] - a[0][2]) % 2 == 0:
    pass
else:
    print('No')
    exit()
for i in range(n - 1):
    x = a[i + 1][0] - a[i][0]
    y = abs(a[i + 1][1] - a[i][1])
    z = abs(a[i + 1][2] - a[i][2])
    if x >= y + z and (x - y - z) % 2 == 0:
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
def odd_even(a, b):
    if a % 2 == b % 2:
        return True
    else:
        return False

n = int(input())
T, X, Y = [0], [0], [0]
for _ in range(n):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

ans = 'Yes'

for i in range(1,n+1):
    t_dif = T[i] - T[i-1]
    x_dif = abs(X[i]-X[i-1])
    y_dif = abs(Y[i]-Y[i-1])
    if t_dif >= (x_dif + y_dif) and odd_even(t_dif, x_dif+y_dif):
        pass
    else:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

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

for i in range(len(ls)-1):
    t = ls[i+1][0] - ls[i][0]
    minkyori = abs(ls[i+1][1] - ls[i][1]) + abs(ls[i+1][2] - ls[i][2])
    if (t - minkyori) % 2 != 0 or (t - minkyori) < 0: #到着不可能,今回であればt=minkyori+2nなら到着できる
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N=input()

Flag= True
while True:
    try:
        ti,xi,yi = map(int, input().split())
        if ti>=(xi+yi) and ti%2==(xi+yi)%2:
            continue
        else:
            print("No")
            Flag=False
            break
    except:
        break

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

Submission status: Accepted

Solution code:
N = int(input())
now_x = 0
now_y = 0
now_t = 0
Flag = False
for i in range(N):
    t , x, y = map(int,input().split())
    dx = abs(x - now_x)
    dy = abs(y - now_y)
    dt = abs(t - now_t)
    if (dt - (dx + dy)) % 2 != 0 or dt < (dx + dy):
        Flag = True
    now_x = x
    now_y = y
    now_t = t
print("No" if Flag else "Yes")