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:
import math
N = int(input())

now = 0
p = [0, 0]

for line in (map(int, input().split()) for _ in range(N)):
  t, x, y = line
  d = abs(p[0] - x) + abs(p[1] - y)
  now += d
  if now < t:
    now += math.ceil((t - now)/2)*2
  if now != t:
    print("No")
    break
  p = x, y
else:
  print("Yes")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(700000)

n = int(input())
schd = []

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

def travel(t, x, y, k):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    time_dist = t1-t
    
    if dist <= time_dist and dist%2 == time_dist%2:
        if k+1 == n:
            return "Yes"
        else:
            return travel(t1, x1, y1, k+1)
    else:
        return "No"

print(travel(0, 0, 0, 0))

Submission status: Accepted

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


time = [0]
x = [0]
y = [0]
for txy in Txy:
    time.append(txy[0])
    x.append(txy[1])
    y.append(txy[2])

def isPossible(N, time, x, y):
    for i in range(N):
        dt = (time[i + 1] - time[i]) ** 2 
        dx = (x[i + 1] - x[i]) ** 2
        dy = (y[i + 1] - y[i]) ** 2

        if dt >= (dx + dy) and (dt%2 == (dx+dy)%2):
            pass
        else:
            return False
    return True

if(isPossible(N, time, x, y)):
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: x[0])
s = [0] * 3

for i in range(N):
    sa = (X[i][0] - s[0]) - ((X[i][1] - s[1]) + (X[i][2] - s[2]))
    if sa >= 0 and sa % 2 == 0:
        start = X[i]
    else:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())

data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

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

for j in data:
    dist = abs(x-j[1]) + abs(y-j[2])
    if dist > j[0] - t:
        flag = False
    if dist == 0:
        flag = False
    if dist % 2 != (j[0] - t) % 2:
        flag = False
        
    t = j[0]
    x = j[1]
    y = j[2]
    
if flag == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
lst = []

for _ in range(N):
  lst.append(list(map(int, input().split())))

for l in lst:
  if l[0] % 2 != (abs(l[1]) + abs(l[2])) % 2 or (abs(l[1]) + abs(l[2])) > l[0]:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t,x,y = map(int , input().split())
if x+y>t or (x+y+t)%2 !=0:
	print('No')
	exit()
for i in range(n-1):
	t_i,x_i,y_i = map(int , input().split())
	e=abs(x-x_i)+abs(y-y_i)-t_i-t
	if e>0  or e%2 !=0:
		print('No')
		exit()
	x=x_i
	y=y_i
	t=t_i
print('Yes')

Submission status: Accepted

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

# print(place)

def can_reach(p1, p2):
    t = p2[0] - p1[0]
    dist =  abs(p2[1]-p1[1]) + abs(p2[2]-p1[2])
    if dist > t:
        return False
    elif dist == t:
            return True
    elif dist % 2 != t % 2:
            return False 
    elif can_reach(p1, [p2[0]-1, p2[1]+1, p2[2]]):
        return True
    elif can_reach(p1, [p2[0]-1, p2[1]-1, p2[2]]):
        return True
    elif can_reach(p1, [p2[0]-1, p2[1], p2[2]+1]):
        return True
    elif can_reach(p1, [p2[0]-1, p2[1], p2[2]-1]):
        return True
    else:
        return False

can = True
for i in range(n):
    if not can_reach(place[i], place[i+1]):
        can = False
        break

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ll = [list(map(int, list(input().split()))) for i in range(N)]
    # ll = [[3, 1, 2], [6, 5, 2]]
    for l in ll:
        t = l[0]
        x = l[1]
        y = l[2]
        if t < x + y:
            print('No')
            return
        if (t % 2) != ((x + y) % 2):
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
 
input = stdin.readline
lines = stdin.readlines
 
N = int(input())
 
txy = ((map(int, line.split())) for line in lines())
t,x,y =(0, 0, 0)
for nt, nx, ny in txy:
    dis=abs(nx-x)+abs(ny-y)
    tim = nt - t
    if tim >= dis and (tim - dis) % 2 ==0:
        t,x,y=nt, nx, ny
    else:
        print('No')
        break
else:
    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())
    dis=abs(nx-x)+abs(ny-y)
    tim = nt - t
    if tim >= dis and (tim - dis) % 2 ==0:
        t,x,y=nt, nx, ny
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    else:
      print("No")
      break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    flag = False
    t, x, y = map(int, input().split())
    for a in range(t - pre_t + 1):
        b = pre_x - x + a
        if b >= 0:
            for c in range(t - pre_t + 1  - a - b):
                d = t - pre_t - a - b - c
                if pre_y + c - d == y:
                    count += 1
                    flag = True
                    break
        if flag:
            break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
plan = [tuple(map(int, input().split())) for i in range(N)]
plan.insert(0, (0, 0, 0))

for i in range(1, N+1):
     t = plan[i][0] - plan[i-1][0]
     x = abs(plan[i][1] - plan[i-1][1])
     y = abs(plan[i][2] - plan[i-1][2])
     
     if t < x+y or (t - (x+y)) % 2 != 0:
         print('No')
         break
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t_1 ,x_1 ,y_1 = 0,0,0
f = 1

for i in range(n):
    t_2 ,x_2 ,y_2 = map(int,input().split())
    x = ((t_2 - t_1) - abs(x_1 - x_2) - abs(y_1 - y_2))
    if  x % 2 == 0 and x >= 0:
        t_1 ,x_1 ,y_1 = t_2 ,x_2 ,y_2
    else:
        f = 0
        print("No")
        break
if f:
    print("Yes")

Submission status: Accepted

Solution code:
# 入力割り当て
N = int(input())

# 可否判定
ans = 'Yes'
for i in range(N):
	t, x, y = map(int, input().split())
	if t < x + y or t%2 != (x+y)%2:
		ans = 'No'

# 結果の表示
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

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

## N < 1e5 なので普通にfor文で回してみる
lst_bool = []
for i in range(N):
  dt = X[i+1][0] - X[i][0]
  dx = X[i+1][1] - X[i][1]
  dy = X[i+1][2] - X[i][2]
  dl = abs(dx) + abs(dy)
  bool_1 = (dt >= dl)
  bool_2 = ((dt - dl) % 2 == 0)
  lst_bool.append(bool_1 and bool_2)

if all(lst_bool):
  print('Yes')
else:
  print('No')




#X = np.array(X)
#var = np.roll(X, -1, axis=0) - X
#print(var)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
t0,x0,y0=0,0,0
for i in range(N):
  t,x,y = list(map(int, input().strip().split(' ')))
  l=x+y-x0-y0
  if (t0-t)%2 ^ l%2:print("No");exit()
  if t-t0<l:print("No");exit()
  t0,x0,y0=t,x,y
print("Yes")

Submission status: Accepted

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

for i in range(N):
	T,X,Y = map(int,input().split())
	t_res = (T-t)
	xy_res = abs(X-x)+abs(Y-y)
	if (t_res - xy_res) % 2 == 0 and t_res >= xy_res:
		ans = 'Yes'
		t,x,y = T,X,Y
	else:
		ans = 'No'
		for j in range(N-(i+1)):
			input()
		break
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
nt=0
np=(0,0)
ok=True
for t,x,y in [map(int,input().split()) for _ in range(N)]:
  el,nt=t-nt,t
  dist=abs(np[0]-x)+abs(np[1]-y)
  
  if el<dist: 
    ok=False 
    break
  if (el-dist)%2!=0:
    ok=False 
    break
  np=(x,y)
if ok:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n):
    t, x, y = txy[i]
    if  x + y > t or (t - x - y) % 2:
        print("No")
        exit()
print("Yes")

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())
    dt = ti - t
    dx = abs(xi - x)
    dy = abs(yi - y)
    if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
        t, x, y = ti, xi, yi
        continue
    print('No')
    break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
ans = True
t = x = y = 0
for i in range(n):
    t1,x1,y1 = map(int,input().split())
    num = abs(x1-x) + abs(y1-y)
    tdif = abs(t1-t)
    if num <= tdif and (num-tdif) % 2 == 0:
        pass
    else:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

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())
  
def traveling(t,x,y):
  time_i=0
  x_i=0
  y_i=0
  for i,time in enumerate(t):
    time_i=time-time_i
    x_i=x[i]-x_i
    y_i=y[i]-y_i
    z=x_i+y_i
    if (time_i-z)%2!=0 or z>time_i:
      return "No"
    time_i=time
    x_i=x[i]
    y_i=y[i]
  return "Yes"
    
print("{}".format(traveling(t,x,y)))

Submission status: Accepted

Solution code:
N = int(input())
manhat = lambda x,y:abs(x[0]-y[0])+abs(x[1]-y[1])
flag = True
t_,x_,y_ = 0,0,0
for i in range(N):
  t,x,y = map(int, input().split())
  dt = t-t_
  dx = manhat((x,y), (x_,y_))
  if dt < dx or (dt - dx) % 2:
    flag = False
    break
  t_,x_,y_ = t,x,y

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

Submission status: Accepted

Solution code:
N = int(input())

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

can = "Yes"
for j in range(N):
    dt = t[j+1] - t[j]
    dr = abs(x[j+1]-x[j]) + abs(y[j+1] - y[j])

    if (dt < dr) | (dr % 2 != dt % 2):
        can = "No"
        break
    
print(can)

Submission status: Accepted

Solution code:
N = int(input())  # 1行目のNを取得する
Plan = [list(map(int, input().split())) for i in range(N)]  # 複数行の数値の入力を取得


# マス目が白か黒か判定する
def checkCel(x, y):
    if x % 2 == 0:
        if y % 2 == 0:  # 偶、偶
            return "Black"
        else:  # 偶、奇
            return "White"

    else:
        if y % 2 == 0:  # 奇、偶
            return "White"
        else:  # 奇,奇
            return "Black"


OKNG = 'Yes'
x, y = Plan[0][1], Plan[0][2]
remain = Plan[0][0]

for i in range(0, len(Plan)):

    # 残歩数のチェック
    if x + y < remain + 1:

        # 行き先のマス目色
        cel = checkCel(x, y)

        # マス目色に対して残歩数で行けるか偶奇判定
        if not ((remain % 2 == 0 and cel == "Black") or \
                (remain % 2 == 1 and cel == "White")):
            OKNG = 'No'
    else:
        OKNG = 'No'

    if i < len(Plan) - 1:
        remain = Plan[i + 1][0] - remain
        x = Plan[i + 1][1] - x
        y = Plan[i + 1][2] - y

print(OKNG)

Submission status: Accepted

Solution code:
#https://qiita.com/drken/items/fd4e5e3630d0f5859067

import numpy as np

n=int(input())
l=np.array([0,0,0])
d=l
rest="Yes"

for _  in range(n):
	t=np.array(list(map(int,input().split())))
	t2=t-d
	if t2[0]-t2[1]-t2[2] >=0 and (t2[0]-t2[1]-t2[2])%2 ==0:
		d=t2
	else:
		rest="No"

print(rest)

Submission status: Accepted

Solution code:
n=int(input())
tn,xn,yn=0,0,0
for _ in range(n):
    ti,xi,yi=map(int,input().split())
    td,xd,yd=ti-tn,xi-xn,yi-yn
    if td<xd+yd or (td+xd+yd)%2!=0:
        print('No')
        exit()
    tn,xn,yn=ti,xi,yi
print('Yes')

Submission status: Accepted

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

lt, lx, ly = 0, 0, 0
for t, x, y in TXY:
	difft = t - lt
	diffp = abs(x - lx) + abs(y - ly)
	if difft < diffp or (diffp - difft) % 2:
		print("No")
		break
	lt, lx, ly = t, x, y
else:
	print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
nt,nx,ny=0,0,0
for i in range(n):
    t,tx,ty=map(int,input().split())
    dis=abs(tx-nx)+abs(ty-ny)
    tm=t-nt
    if dis>tm or dis%2!=tm%2:
        print("No")
        exit()
    nt,nx,ny=t,tx,ty
print("Yes")

Submission status: Accepted

Solution code:
import sys
n=int(input())
nt,nx,ny=0,0,0
for i in range(n):
    t,tx,ty=map(int,input().split())
    dis=abs(tx-nx)+abs(ty-ny)
    if dis>(t-nt):
        print("No")
        sys.exit()
    if dis%2!=(t-nt)%2:
        print("No")
        sys.exit()
    nt,nx,ny=t,tx,ty
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
pos = [list(map(int,input().split())) for _ in range(N)]
posx = 0
posy = 0
disx = 0
disy = 0
dis  = 0
time = 0
for n in range(N):
    disx = abs(pos[n][1]-posx)
    disy = abs(pos[n][2]-posy)
    dis = disx + disy
    if((pos[n][0]-time)-dis)<0:
        print("No")
        exit()
    else:
        if ((pos[n][0]-time)-dis)%2!=0:
            print("No")
            exit()
        else:
            time = pos[n][0]
            posx = pos[n][1]
            posy = pos[n][2]
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
A = [[0, 0, 0]] + [[int(i) for i in input().split()] for _ in range(N)]

for (t, x, y), (nt, nx, ny) in zip(A[:N], A[1:]):
    d = abs(x - nx) + abs(y - ny)
    r = nt - t
    if d > r or d % 2 != r % 2:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

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

for ind,i in enumerate(t[1:]):
    dist = i[0]-t[ind][0]-(sum(i[1:])-sum(t[ind][1:]))
    if(dist==0):
        pass
    elif(dist>0):
        if(dist%2==0):
            pass
        elif(i[1]!=t[ind][1] and i[2]!=t[ind][2] and dist>1):
            pass
        else:
            flag = False
            break
    else:
        flag = False
        break
if(flag):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
ans=0
time_now=0
x_now=0
y_now=0
for i in range(n):
  time,x,y=map(int,input().split())
  jikan=time-time_now
  kyori=abs(x-x_now)+abs(y-y_now)
  if(jikan>=kyori and jikan%2==kyori%2):
    ans+=0
  else:
    ans+=1
  time_now=time
  x_now=x
  y_now=y
  
if(ans==0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys
N = int(input())

T = [0]
X = [0]
Y = [0]

for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

for i in range(N):
    diff_T = T[i+1] - T[i]
    diff_X = abs(X[i+1] - X[i])
    diff_Y = abs(Y[i+1] - Y[i])
    if diff_T < diff_X + diff_Y:
        print('No')
        sys.exit()
    if (diff_X + diff_Y - diff_T) % 2:
        print('No')
        sys.exit()
        
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
previous_t = 0
ans = "Yes"
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if x + y > t:
        ans = "No"
        break
    if (x + y) % 2 != t % 2:
        ans = "No"
        break
    if previous_t > 0 and (abs(x - previous_x) + abs(y - previous_y) > (t - previous_t)):
        ans = "No"
        break
    previous_t = t
    previous_x = x
    previous_y = y

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
previous_t = 0
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if x + y > t:
        print("No")
        break
    if (x + y) % 2 != t % 2:
        print("No")
        break
    if previous_t > 0 and (abs(x - previous_x) + abs(y - previous_y) > (t - previous_t)):
        print("No")
        break
    previous_t = t
    previous_x = x
    previous_y = y
else:
    print("Yes")

Submission status: Accepted

Solution code:
# ABC086C - Traveling
n = int(input())
for _ in range(n):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y) % 2 != 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for i in range(N):
    K = list(map(int,input().split()))
    if K[0]>=K[1]+K[2] and K[0]%2==(K[1]+K[2])%2:
        count += 1
#print(count)   
if count == N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline())
for i in range(n):
    t, x, y = map(int, stdin.readline().split())
    dist = x + y
    if t < dist or (dist % 2) != (t % 2):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
 
if li[0][0] - abs(li[0][1]) - abs(li[0][2]) < 0:
  print("No")
  exit()
elif li[0][0] - abs(li[0][1]) - abs(li[0][2]) > 0:
  if (li[0][0] - abs(li[0][1]) - abs(li[0][2])) % 2 != 0:
    print("No")
    exit()
else:
  for k in range(1,n):
    t = li[k][0]
    x = li[k][1]
    y = li[k][2]
    tt = li[k-1][0]
    xx = li[k-1][1]
    yy = li[k-1][2]
    if t - tt - abs(x - xx) - abs(y - yy) <0:
      print("No")
      exit()
    elif t - tt - abs(x - xx) - abs(y - yy) <0:
      if (t - tt - abs(x - xx) - abs(y - yy)) % 2 != 0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
#
# abc086 c
#
n = int(input())
ret = "Yes"
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t:
        ret = "No"
        break
    if t % 2 == 0 and (x + y) % 2 == 1:
        ret = "No"
        break
    elif t % 2 == 1 and (x + y) % 2 == 0:
        ret = "No"
        break
print(ret)

Submission status: Accepted

Solution code:
n=int(input())
flag=1
ct,cx,cy=0,0,0
for i in range(n):
  t,x,y=map(int,input().split())
  if t-ct<abs(x-cx)+abs(y-cy) or (t+x+y)%2!=0:
    flag=0
print("Yes" if flag==1 else "No")

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    poss = []

    time = 0
    x = 0
    y = 0 
    for i in range(n):
        t,a,b = f()
        dis = abs(a-x) + abs(y-b)
        if dis<= t - time and dis%2 == (t- time)%2:
            time = t
            x = a
            y = b
        else:
            print('No')
            return
    
    print('Yes')



solve()

Submission status: Accepted

Solution code:
# 2019/05/06
# AtCoder Beginner Contest 086 - C

# Input
n = int(input())

# Init
wt = 0
wx = 0
wy = 0
postra_flg = True

for i in range(n):
    t, x, y = map(int, input().split())
    et = t - wt
    dist = abs(x - wx) + abs(y - wy)
    remt = et - dist
    
    # Case Too far or Odd
    if remt < 0 or remt % 2 == 1:
        postra_flg = False
        break

if postra_flg == True:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = [[int(i) for i in input().split()] for i in range(n)]
status = (0,0,0)
result = "Yes"
for i in d:
    dist = abs((i[1]+i[2]) - (status[1]+status[2]))
    time = i[0] - status[0]
    if (time >= dist) and (time - dist) % 2 == 0:
        status = i
    else:
        result = "No"
        break
print(result)

Submission status: Accepted

Solution code:
N=int(input())
t,x,y=[None]*(N+1),[None]*(N+1),[None]*(N+1)
t[0],x[0],y[0]=0,0,0
for i in range(1,N+1):
    t[i],x[i],y[i] = map(int,input().split())
for i in range(N):
    l = t[i+1]-t[i]
    d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if d <= l and (l-d) % 2 == 0:
        if i == N-1:
            print("Yes")
            break
    else:
        print("No")
        break

Submission status: Accepted

Solution code:
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)
    
for i in range(1,n+1):
    t_margin = t_list[i] - t_list[i-1]
    x_margin = abs(x_list[i] - x_list[i-1])
    y_margin = abs(y_list[i] - y_list[i-1])
    t_temp = t_margin%2
    xy_temp = (x_margin+y_margin)%2
    if (t_temp != xy_temp) or (t_margin < x_margin + y_margin):
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

point = [0,0,0]
output = 'Yes'
for plan in plan_list:
    dist = abs(plan[1] - point[1]) + abs(plan[2] - point[2])
    time = plan[0] - point[0]
    if time >= dist and (dist - time)%2 == 0:
        point = plan
        continue
    else:
        output = 'No'
        break

print (output)

Submission status: Accepted

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

for i in range(1, n+1):
    t_diff = T[i] - T[i-1]
    pos_diff = abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1])
    a = t_diff - pos_diff
    if a % 2 != 0 or a < 0:
        break
else:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
def main():
  size = int(input())
  array = []
  for i in range(size):
    array.append(list(map(int, input().split())))
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = array[i][0]
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# input
n = int(input())

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

    t0 = t
    x0 = x
    y0 = y

print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# input
n = int(input())

t0 = x0 = y0 = 0
for i in range(n):
    t, x, y = map(int, input().split())
    dt = t - t0
    dm = abs(x - x0) + abs(y - y0)
    if dt < dm:
        print('No')
        exit()
    elif dt % 2 != dm %2:
        print('No')
        exit()

    t0 = t
    x0 = x
    y0 = y

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:
    print("No")
    exit()
  elif (x+y+t)%2 != 0:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
"""
可変長データの読み込み
"""
t = []
x = []
y = []

t.append(0)
x.append(0)
y.append(0)

for i in (range(0, 1000000, 1)):
  try:
    c = input()
    if i == 0:
      N = int(c)
    else:
      t.append(int(c.split(" ")[0]))
      x.append(int(c.split(" ")[1]))
      y.append(int(c.split(" ")[2]))
  except:
    break

for i in range(0, len(t) - 1, 1):
  
  con1 = t[i + 1] >= (x[i + 1] + y[i + 1]) 
  dt = t[i+1] - t[i]
  dist = (x[i+1]-x[i]) + (y[i+1] - y[i]) 

  if con1 is True and (dt - dist) %2 == 0:
    ans = "Yes"
  else:
    ans = "No"
    break
    
print(ans)

Submission status: Accepted

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

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

for k in range(n):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    if dist <= t1-t and (t1-t-dist)%2 == 0:
        t, x, y = t1, x1, y1
    else:
        print("No")
        exit()
else:
    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 :
        print('No')
        exit()
    elif (x + y + t) % 2 != 0 :
        print('No')
        exit()

print("Yes")

Submission status: Accepted

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

for i in range(1,N+1):
    r = abs(P[i][1]-P[i-1][1])+abs(P[i][2]-P[i-1][2])
    t = P[i][0]-P[i-1][0]
    if r % 2 != t % 2 or r > t:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
#AtCoder ABC086C - Traveling

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

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
u,x,y = 0,0,0

for i in range(n):
    t,a,b = map(int,input().split())
    dis = abs(x-a) + abs(y-b)
    if dis%2!=(t-u)%2 or dis>t:
        print('No')
        exit()
    u,x,y = t,a,b
print('Yes')

Submission status: Accepted

Solution code:
nt,nx,ny=0,0,0
ans="Yes"
for _ in range(int(input())):
	t,x,y=map(int, input().split())
	d=abs(x-nx)+abs(y-ny)
	if t-nt < d:
		ans="No"
		break
	elif (t-nt-d) % 2 != 0:
		ans="No"
		break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
bt,bx,by=0,0,0

ans=True
for i in range(n):
    t, x, y = map(int, input().split())
    dt=t-bt
    dist=abs(x-bx)+abs(y-by)
    if dt<dist:
        ans = False
    if dist % 2 != dt % 2:
        ans=False

    bt,bx,by=t,x,y
    
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
bt,bx,by=0,0,0
ans=True
for i in range(n):
    t, x, y = map(int, input().split())
    dt=t-bt
    l=abs(x-bx)+abs(y-by)
    if dt<l:
        ans = False
    if (dt-l)%2:ans=False

    bt,bx,by=t,x,y
print('Yes' if ans else 'No')

Submission status: Accepted

Solution code:
def check(x, y, new_x, new_y, dt):
  diff = abs(new_x - x) + abs(new_y - y)
  if dt%2 == diff%2 and diff <= dt:
    return True
  return False

n = int(input())
t, x, y, count = 0, 0, 0, 0
canReach = True
while(count < n):
  new_t, new_x, new_y = map(int, input().split())
  if not check(x, y, new_x, new_y, new_t-t):
    canReach = False
    break
  t, x, y = new_t, new_x, new_y
  count += 1
if canReach:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    l = [[int(s) for s in input().split()] for n in range(N)]
    can = True
    now = [0, 0, 0]
    for i in range(N):
        pos = l[i]
        d = abs(pos[1] - now[1]) + abs(pos[2] - now[2])
        t = pos[0] - now[0]
        if d % 2 != t % 2 or d > t:
            can = False
        now = pos
    if can:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
if N == 1:
    prob = data[0][0] - data[0][1] - data[0][2]
    if prob < 0 or prob % 2 != 0:
        print("No")
    else:
        print("Yes")
    quit()
for i in range(N-1):
    t = data[i][0]
    x = data[i][1]
    y = data[i][2]
    deltaT = data[i+1][0] - t
    absX = abs(data[i+1][1] - x)
    absY = abs(data[i+1][2] - y)
    prob = deltaT - absX - absY
    if prob < 0 or prob % 2 != 0:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = map(int, input().split())
  d = (t-pre_t) - abs(x-pre_x) - abs(y-pre_y)
  if d < 0 or d % 2 != 0:
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = map(int, input().split())
  if (((t-pre_t) - abs(x-pre_x) - abs(y-pre_y)) < 0
      or ((t-pre_t) - abs(x-pre_x) - abs(y-pre_y)) % 2 != 0):
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")