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 numpy as np
N = int(input())
plan = np.array([[0, 0, 0]] + [list(map(int, input().split())) for i in range(N)])

diff = np.diff(plan, axis = 0)

def is_possible(t, x, y):
    if (t + x + y) % 2 == 0 and abs(x) + abs(y) <= t:
        return True
    else:
        return False

for i in range(N):
    ti, xi, yi = diff[i]
    if not is_possible(ti, xi, yi):
        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 t < x + y or t % 2 != (x + y) % 2:
        print("No")
        exit()
        
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
data = [ list(map(int, input().split())) for i in range(n)]
data.insert(0, [0,0,0])
for i in range(n):
    differ = [(data[i+1][j] - data[i][j]) for j in range(3)]
    if abs(differ[0]) < (differ[1] + differ[2]):
        print("No")
        exit()
    elif differ[0] % 2 != (differ[1] + differ[2]) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    now_t, now_x, now_y = 0, 0, 0
    for i in range(N):
        t, x, y = map(int, input().split())

        a = abs(now_x - x) + abs(now_y - y)
        b = t - now_t
        if a > b or a % 2 != b % 2:
            print(No)
            return

        now_t, now_x, now_y = t, x, y

    print(Yes)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(n):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
  
for i in range(n):
  tdiff = t[i+1]-t[i]
  ddiff = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if tdiff < ddiff or (tdiff % 2) != (ddiff % 2):
    print("No")
    exit(0)

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

flag = True
for i in range(n):
	dist = abs(txy[i][1]-txy[i+1][1]) + abs(txy[i][2]-txy[i+1][2])
	time = txy[i+1][0] - txy[i][0]
	dif = time - dist
	if dif<0 or dif%2==1:			# 到達不可能
		flag = False
		break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
f = True
t1,x1,y1 = 0,0,0
for i in range(N):
  t0,x0,y0 = t1,x1,y1
  t1,x1,y1 = map(int,input().split())
  d=(t1-t0)-abs(x0-x1)-abs(y0-y1)
  if 0<=d and (d&1)==0:
    pass
  else:
    f = False
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
N=int(input())
txy=[list(map(int, input().split())) for _ in range(N)]
is_No=0
for row in txy:
    if row[0]%2==0:
        if row[1]+row[2]<=row[0] and (row[1]+row[2])%2==0:
            continue
        else:
            is_No=1
            break
    elif row[0]%2==1:
        if row[1]+row[2]<=row[0] and (row[1]+row[2])%2==1:
            continue
        else:
            is_No=1
            break
    else:
        is_No=1
        break
print("No" if is_No else "Yes")

Submission status: Accepted

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

flag = False
for i in range(n):
    for j in range(data_list[i+1][0] - data_list[i][0]):
        t_diff = abs(data_list[i+1][0] - data_list[i][0])
        x_diff = abs(data_list[i+1][1] - data_list[i][1])
        y_diff = abs(data_list[i+1][2] - data_list[i][2])
        if x_diff + y_diff <= t_diff:
            if ((x_diff + y_diff) % 2 == 0 and t_diff % 2 == 0) or ((x_diff + y_diff) % 2 == 1 and t_diff % 2 == 1):
                pass
            else:
                print('No')
                flag = True
                break
        else:
            print('No')
            flag = True
            break
    if flag:
        break
if flag == False:
    print('Yes')

Submission status: Accepted

Solution code:
def main():
    N = int(input())

    pt = 0
    px = 0
    py = 0
    for i in range(N):
        tin = input().split(" ")
        t, x, y = int(tin[0]), int(tin[1]), int(tin[2])
        d = abs(px-x) + abs(py-y)
        dr = t - pt - d
        if dr < 0 or dr % 2 != 0:
            print("No")
            return
    print("Yes")
    return
main()

Submission status: Accepted

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

b = [0,0,0]
for a in txy:
    t = a[0] - b[0]
    d = abs(a[1] - b[1]) + abs(a[2] - b[2])
    if d > t or d % 2 != t % 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Aug  9 01:39:56 2018

@author: Yuki
"""

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

Yes_flag = True
# 移動距離が遠すぎないかのチェック
for i in range(N):
    if (abs(plans[i+1][1] - plans[i][1]) + abs(plans[i+1][2] - plans[i][2])) > (plans[i+1][0] - plans[i][0]):
        Yes_flag = False
        break
for i in range(1, N+1):
    if plans[i][0] % 2 == 0:
        if (plans[i][1] + plans[i][2]) % 2 != 0:
            Yes_flag = False
            break
    else:
        if (plans[i][1] + plans[i][2]) % 2 == 0:
            Yes_flag = False
            break
if Yes_flag:
    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) % 2 != t % 2:
        print('No')
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
# now_t, now_x, now_y
nt, nx, ny = 0, 0, 0
l = [list(map(int, input().split())) for _ in range(n)]
for t, x, y in l:
    dist =  abs(nx - x) + abs(ny - y)
    if dist > t - nt:
        print("No")
        exit()
    elif (dist - (t-nt)) % 2 != 0:
        print("No")
        exit()
    nt, nx, ny = t, x, y
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

t_old = 0
x_old = 0
y_old = 0

possible = True

for _ in range(N):
    t, x, y = list(map(int, input().split()))

    t_diff = t - t_old
    x_diff = x - x_old
    y_diff = y - y_old

    xy_diff = x_diff + y_diff

    checker = t_diff - xy_diff

    if (checker >= 0) & (checker % 2 == 0):
        pass

    else:
        possible = False
        break

    t_old = t
    x_old = x
    y_old = y

if possible:
    print("Yes")

else:
    print("No")

Submission status: Accepted

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

def judge(N:int, TXY:tuple) -> bool:
    for i in range(N):
        delta_t = TXY[i+1][0] - TXY[i][0]
        delta_x = abs(TXY[i+1][1] - TXY[i][1])
        delta_y = abs(TXY[i+1][2] - TXY[i][2])
        
        if (delta_t%2 != (delta_x+delta_y)%2)\
          or (delta_t < (delta_x+delta_y)):
            return False
        
    return True

if judge(N,TXY):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

N = int(input())
x1 = y1 = t1 = 0

for _ in range(N):
	t2,x2,y2 = inpl()
	dt = t2 - t1
	d = abs(x2 - x1) + abs(y2 - y1)
	if dt < d:
		print('No')
		sys.exit()
	else:
		if (dt-d)%2 != 0:
			print('No')
			sys.exit()
	x1,y1,t1 = x2,y2,t2

print('Yes')

Submission status: Accepted

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

for txy_i in txy:
	t, x, y = txy_i
	remain = t - x - y
	if not (0 <= remain and remain % 2 == 0):
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
st, sx, sy = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    distance = abs(x - sx) + abs(y - sy)
    dt = t - st
    if dt < distance or (dt - distance) % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
k = 0
t2 = 0
x2 = 0
y2 = 0

for i in range(n):
    t1,x1,y1 = map(int,input().split())
    t = t1 - t2
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    if t < x + y or t % 2 != (x + y) %2:
        print('No')
        break
    t2 = t1
    x2 = x1
    y2 = y1
    if i == n-1:
        print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
x,y,e=0,0,0
f=True
for _ in range(N):
    a,b,c=map(int,input().split())
    d=(a-e)-(b-x)-(c-y)
    x=b
    y=c
    e=a
    if d%2 or d<0:
        f=False
if f:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
n=int(input())
t=[list(map(int,input().split()))for i in range(n)]
t.insert(0,[0,0,0])
for i in range(n):
    dxy=abs(t[i][1]-t[i+1][1])+abs(t[i][2]-t[i+1][2])
    dt=abs(t[i][0]-t[i+1][0])
    dd=dt-dxy
    if dxy<=dt and dd%2==0:
        pass
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
#AT3875
n = int(input())
r = 'Yes'

for i in range(n):
    t, a, b = map(int, input().split())
    s = abs(a) + abs(b)
    if s > t or (t - s) % 2 != 0:
        r = 'No'
print(r)

Submission status: Accepted

Solution code:
#coding:utf-8

n = int(input())

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

prev_t = 0
prev_x = 0
prev_y = 0
ans = 'Yes'
for i in range(n):
    dt = T[i] - prev_t
    dis = abs(X[i] - prev_x) + abs(Y[i] - prev_y)
    if dt < dis or (dt - dis)%2 == 1:
        ans = 'No'
        break
    prev_t = T[i]
    prev_x = X[i]
    prev_y = Y[i]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

chkflg=True
for i in range(1,1+n):
    
    t=int(arr_data[i][0])
    x=int(arr_data[i][1])
    y=int(arr_data[i][2])
    
    if not((t%2==0 and (x+y) % 2==0 and t>=x+y) or (t%2!=0 and (x+y) % 2!=0 and t>=x+y)):
        
        chkflg=False
        break
        
print("Yes" if chkflg else "No")

Submission status: Accepted

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

def main():
    #入力
    N = int(input())
    lists = []
    for i in range(N):
        lists.append(list(map(int, input().split())))
    
    #変数
    position = [0, 0]
    begin_time = 0
    move_flag = 0

    #時間の変位-移動距離が0位上かつ、2の倍数であったらその位置に行くことができる
    for i in range(N):
        #時間の変位
        time_diff = lists[i][0] - begin_time
        begin_time = lists[i][0]
        #距離を求める
        distance = abs(lists[i][1] - position[0]) + abs(lists[i][2] - position[1])
        position = [lists[i][1], lists[i][2]]
        if time_diff - distance >= 0 and (time_diff - distance) % 2 == 0:
            move_flag = 1
        else:
            move_flag = 0
            break
    
    if move_flag == 1:
        print('Yes')
    elif move_flag == 0:
        print('No')

    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
pre_t,pre_x,pre_y=0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d_t = t-pre_t
    d_x = abs(x-pre_x)
    d_y = abs(y-pre_y)
    if d_x + d_y > d_t or (d_x + d_y + d_t) % 2:
        print("No")
        quit()
    pre_t,pre_x,pre_y=t, x, y
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
B = [[0]*3]*N
for i in range(N):
    B[i] = list(map(int,input().split()))
ans = 'Yes'
B.insert(0,[0,0,0])
for i in range(N):
    T = B[i+1][0] - B[i][0] 
    S = abs(B[i+1][1] - B[i][1]) + abs(B[i+1][2] - B[i][2])
    if T >= S and (T - S)%2 == 0:
        pass
    else:
        ans = 'No'
        break
print(ans)

Submission status: Accepted

Solution code:
t = x = y = 0
T = [0]
X = [0]
Y = [0]

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

f = True
d = s = 0
for i in range(N):
    d = (T[i+1]-T[i]) - abs(X[i+1]-X[i]) - abs(Y[i+1]-Y[i])
    if f and d >= 0 and d%2 == 0:
        f = True
    else:
        f = False

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

Submission status: Accepted

Solution code:
N = int(input())

s_x = 0
s_y = 0
s_t = 0
travel_flag = True

def judge_ok(d_p, d_t):
  if d_p > d_t:
    return False
  if d_p % 2 != d_t % 2:
    return False
  return True

for n in range(N):
  n_t, n_x, n_y = list(map(lambda x:int(x), input().split(" ")))

  if not judge_ok(abs(n_x - s_x) + abs(n_y - s_y), n_t - s_t):
    travel_flag = False
  
  s_x = n_x
  s_y = n_y
  s_t = n_t

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

Submission status: Accepted

Solution code:
def goal_check(start,goal):
  distance = abs(start[1]-goal[1]) + abs(start[2]-goal[2])
  time = goal[0] - start[0]
  if time < distance: return False
  if (time-distance)%2 == 1: return False
  return True


N = int(input())
ans = "Yes"
dest = []
dest.append([0,0,0])
for i in range(N):
    dest.append(list(map(int,(input().split()))))
    
dest.sort(key=lambda point: point[0]) #O(NlogN)

for p,q in zip(dest[:-1],dest[1:]):
  if goal_check(p,q):
    pass
  else:
    ans = "No"
    break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())


def main():
    t0, x0, y0 = 0, 0, 0
    for i in range(n):
        t1, x1, y1 = map(int, input().split())
        l = abs(x1 - x0) + abs(y1 - y0)
        t = t1 - t0
        if l - t > 0 or (t - l) % 2 != 0:
            print('No')
            return
        t0, x0, y0 = t1, x1, y1
    print('Yes')


main()

Submission status: Accepted

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

pt,px,py = 0,0,0
for t,x,y in src:
    d = abs(x-px) + abs(y-py)
    if t-pt < d or (t-pt)%2 != d%2:
        print('No')
        exit()
    pt,px,py = t,x,y
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
travel_plan = [tuple(map(int, input().split())) for i in range(n)]
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

can = True
t = 0
pos = [0, 0]
for row in matrix:
    t_diff = row[0] - t
    max_step = abs(row[1] - pos[0]) + abs(row[2] - pos[1])
    if max_step > t_diff:
        can = False
        break
    elif max_step % 2 != t_diff % 2:
        can = False
        break
    else:
        t = row[0]
        pos = row[1:3]

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

Submission status: Accepted

Solution code:
N = int(input())

moves = []
for i in range(N):
	moves.append(tuple(map(int, input().split())))
	
current = (0, 0, 0)
for nextPosition in moves:
	dt = nextPosition[0] - current[0]
	dist = abs(nextPosition[1] - current[1]) + abs(nextPosition[2] - current[2])
	if (dist > dt):
		print('No')
		exit()
	if (dt%2 != dist%2):
		print('No')
		exit()

print('Yes')

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

flag = True
for i in range(n):
    t_diff = t[i+1] - t[i]
    x_diff = x[i+1] - x[i]
    y_diff = y[i+1] - y[i]

    if abs(x_diff) + abs(y_diff) > t_diff:
        flag = False
        break

    if (x_diff % 2 == 0 and y_diff % 2 == 0) or (x_diff % 2 != 0 and y_diff % 2 != 0):
        match = True
    else:
        match = False

    if t_diff % 2 == 0 and not match:
        flag = False
        break
    elif t_diff % 2 != 0 and match:
        flag = False
        break

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

Submission status: Accepted

Solution code:
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - prev_t
    dx = x - prev_x
    dy = y - prev_y
    if dt < dx + dy:
        print("No")
        break
    elif (dx + dy - dt) % 2 == 0:
        prev_t, prev_x, prev_y = t, x, y
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

for i in range(N) :
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)
    

cur_x = 0
cur_y = 0
cur_time = 0 
flg_possible = True

for i in range(N) :
    min_dist = abs(x[i] - cur_x) + abs(y[i] - cur_y)

    if min_dist > t[i] or not((t[i] - cur_time) % 2 == min_dist % 2):
        print("No")
        flg_possible = False
        break
    else :
        cur_x, cur_y, cur_time = x[i], y[i], t[i]
        
if flg_possible == True :
    print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# ABC086 C Traveling
def main():
    n = int(input().strip())
    z = [[int(i) for i in input().split()] for _ in range(n)]

    def func(z, z0):
        t0, x0, y0 = z0
        t, x, y = z
        dist = abs(x - x0) + abs(y - y0)
        t = t - t0
        if dist > t:
            return False

        if dist % 2 == t % 2:
            return True
        else:
            return False

    z = [[0, 0, 0]]  + z
    for i in range(1, len(z)):
        if not func(z[i], z[i-1]):
            print("No")
            return

    print("Yes")
        

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(N) :
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

cur_x, cur_y = 0, 0
cur_t = 0
flg_impossible = "Yes"

for i in range(N) :
    dloc = (x[i] - cur_x) + (y[i] - cur_y)
    dt = t[i] - cur_t
    
    if ((dloc % 2 == 0 and dt % 2 == 0) or (dloc % 2 != 0 and dt % 2 != 0)) and dloc <= dt :
        cur_x, cur_y, cur_t = x[i], y[i], t[i]
    else :
        flg_impossible = "No"
        
print(flg_impossible)

Submission status: Accepted

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

def distance(x1,y1,x2,y2):
    return(abs(x1-x2)+abs(y1-y2))
flag = True
for  i in range(1,n+1):
    dis = distance(txy[i][1],txy[i][2],txy[i-1][1],txy[i-1][2])
    if  not (dis <= txy[i][0]-txy[i-1][0] and (txy[i][0]-txy[i-1][0] - dis)%2==0):
        flag=False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
past_x = 0
past_y = 0
past_t = 0
for _ in range(n):
    t, x, y = tuple(map(int, input().split(" ")))
    diff = abs(past_x - x) + abs(past_y - y)
    if (t - past_t) >= diff and ((t - past_t) - diff) % 2 == 0:
        past_t, past_x, past_y = t, x, y
        continue
    else:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

Solution code:
N = int(raw_input())
T = [0]
X = [0]
Y = [0]
for i in range(N):
  t, x, y = map(int, raw_input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
ret = "Yes"
for i in range(N):
  d = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
  dt = T[i+1]-T[i]
  if d > dt or (dt-d)%2==1:
    ret = "No"
print ret

Submission status: Accepted

Solution code:
import sys
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
t = [0]
x = [0]
y = [0]
for lists in grid:
  t.append(lists[0])
  x.append(lists[1])
  y.append(lists[2])
i = 0
while i < N:
  d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
  dt = t[i+1]-t[i]
  if dt >= d and (dt-d)%2==0:
    i += 1
  else:
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

Solution code:

import sys

n = int(sys.stdin.readline())
before_t, before_x, before_y = 0, 0, 0
for i in range(n):
	txy_strs = sys.stdin.readline().split()
	t, x, y = tuple(map(int, txy_strs))

	movable = t - before_t
	min_move = abs(x - before_x) + abs(y - before_y)

	remaining = movable - min_move
	if 0 <= remaining and remaining % 2 == 0:
		before_t, before_x, before_y = t, x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys

n = int(input())
before_t, before_x, before_y = 0, 0, 0
for i in range(n):
	txy_strs = input().split()
	t, x, y = tuple(map(int, txy_strs))
	
	movable = t - before_t
	min_move = abs(x - before_x) + abs(y - before_y)

	remaining = movable - min_move
	if 0 <= remaining and remaining % 2 == 0:
		before_t, before_x, before_y = t, x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
# Relative rela
import sys

n = int(input())
txy_list = [[int(n) for n in input().split()] for i in range(n)]
times_list = [txy_list[0][0]] + [txy_list[i+1][0] - txy_list[i][0] for i in range(n-1)]

before_x, before_y = 0, 0
for i, txy in enumerate(txy_list):
	t, x, y = txy
	rela_x, rela_y = x - before_x, y - before_y
	remaining = times_list[i] - (abs(rela_x) + abs(rela_y))
	if 0 <= remaining and remaining % 2 == 0:
		before_x, before_y = x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
def md(x,y):
    return abs(x)+abs(y)
def isOdd(a,b):
    if a%2==b%2:
        return False
    else:
        return True 
pt=0
px=0
py=0
for _ in range(n):
    t,x,y=map(int,input().split())
    dt=t-pt
    dx=x-px
    dy=y-py
    pt=t
    px=x
    py=y
    if dt<md(dx,dy) or isOdd(dt,md(dx,dy)):
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

t_pre,x_pre,y_pre = 0,0,0 #initial
for i in range(n):
    t,x,y = map(int, input().split())
    t_dif, x_dif, y_dif = abs(t_pre-t), abs(x_pre-x), abs(y_pre-y)
    
    if 0 <= x_dif+y_dif <= t_dif:
        if (x_dif+y_dif)%2 == t_dif%2: # 偶奇が一致
            t_pre, x_pre, y_pre = t, x, y
            continue
    print('No')
    sys.exit()
    
print('Yes')

Submission status: Accepted

Solution code:
import sys

def dis(x0, y0, x1, y1):
    d = 0
    d += abs(x0 - x1)
    d += abs(y0 - y1)
    return d

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    lines = sys.stdin.readlines()

    ls = [[0, 0, 0]]
    for line in lines:
        ls.append([int(i) for i in line.split()])

    for i in range(1, len(ls)):
        d = dis(ls[i][1], ls[i][2], ls[i-1][1], ls[i-1][2])
        t = ls[i][0] - ls[i-1][0]
        # print(ls[i], d, t)
        if d <= t and t % 2 == d %  2:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

plan = True

pret = 0
prex = 0
prey = 0
for i in range(N):
    t,x,y = (int(k) for k in input().split())
    distance = abs(prex - x) + abs(prey - y)
    if distance > (t - pret):
        plan = False
    elif (distance - (t - pret)) % 2 != 0:
        plan = False
    pret = t
    prex = x
    prey = y

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

Submission status: Accepted

Solution code:
N = int(input())
txy = [[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    t = txy[i+1][0] - txy[i][0]
    move = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if t < move or (t - move)%2 != 0:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
# N = 2
# a = [[3,1,2],[6,1,1]]
N = input()
N = int(N)
a = [input().split() for _ in range(N)]
b = [[0,0,0]]
b.extend(a)
rtn = 'Yes'
for i in range(N):
    t1 = int(b[i][0])
    x1 = int(b[i][1])
    y1 = int(b[i][2])
    t2 = int(b[i+1][0])
    x2 = int(b[i+1][1])
    y2 = int(b[i+1][2])

    td = t2-t1
    xyd = (x2+y2) - (x1+y1)

    # 偶数
    if((td%2==xyd%2) & (td>=xyd)):
        rtn = rtn
    else:
        rtn = 'No'

print(rtn)

Submission status: Accepted

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

# その場に留まることは出来ないが、往復は出来る
# 

def move(xy1, xy2):
    return abs(xy1[0]-xy2[0]) + abs(xy1[1]-xy2[1])

for i in range(N):
    move_distance = move(txy[i+1][1:], txy[i][1:])
    tmp = txy[i+1][0]-txy[i][0]
    if tmp < move_distance:
        print("No")
        exit()
    if move_distance%2==0: # 移動距離が偶数なら
        if tmp%2==1:
            print("No")
            exit()
    else: # 移動距離が奇数なら
        if tmp%2==0:
            print("No")
            exit()

    
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
tmp = [0,0,0]
data = [0,0,0]
flag = True
for i in range(N):
  tmp = list(map(int,(input()).split()))
  if (tmp[0] - data[0])%2 == (tmp[1] + tmp[2] - data[1] - data[2]) % 2 + 1 or (tmp[1] - data[1] + tmp[2] - data[2] > tmp[0] - data[0]):
    flag = False
    break
  else:
    data = tmp

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