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:
# coding: utf-8


def main():
    N = int(input())
    ans = 'Yes'
    t, x, y = 0, 0, 0
    for _ in range(N):
        nt, nx, ny = map(int, input().split())
        d = abs(x - nx) + abs(y - ny)
        if d > nt - t or (nt - t - d) % 2 != 0:
            ans = 'No'
            break
        t, x, y = nt, nx, ny

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
txy = [map(int, input().split()) for _ in range(N)]
t, x, y = [list(i) for i in zip(*txy)]
t = deque(t)
x = deque(x)
y = deque(y)
t.appendleft(0)
x.appendleft(0)
y.appendleft(0)
for i in range(N):
    direct = t[i+1] - t[i] - abs(x[i+1] - x[i]) - abs(y[i+1] - y[i])
    if direct < 0 or direct % 2 != 0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
l = []
now = [0,0,0]
ans = 'Yes'
for _ in range(N):
    inp = list(map(int,input().split()))
    l.append(inp)

for i in range(N):
    shortest = abs(l[i][1] - now[1]) + abs(l[i][2] - now[2])
    if shortest > l[i][0]-now[0]:
        ans = 'No'
        break
    a = l[i][0] -now[0]- shortest
    if a % 2 !=0:
        ans = 'No'
        break
    else:
        now = l[i]
print(ans)

Submission status: Accepted

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

for i in range(1,n+1):
    k=abs(l[i][1]-l[i-1][1])+abs(l[i][2]-l[i-1][2])
    t=l[i][0]-l[i-1][0]
    if k>t or k%2!=t%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
pt, px, py = 0,0,0
f = 0
for i in range(n):
    t,x,y = map(int, input().split())
    gt = t-pt
    gx, gy = abs(x-px), abs(y-py)
    gt -= gx+gy
    if gt < 0 or gt%2==1:
        f=1
    pt,px,py = t,x,y
if f:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

plan = []

Feasible = True

for i in range(N):
  t,x,y = map(int,input().split())
  plan.append([t,x,y])

t0,x0,y0 = 0,0,0

for t1,x1,y1 in plan:
  dx = x1-x0
  dy = y1-y0
  dt = t1-t0
  dist = abs(dx)+abs(dy)
  d = dt - dist
  
  if dt < dist:
    Feasible = False
  elif (dist+dt)%2 != 0:
    Feasible = False
  t0,x0,y0 = t1,x1,y1
print("Yes" if Feasible else "No")

Submission status: Accepted

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

pT, pX, pY = 0, 0, 0

for i in range(N):
    cT, cX, cY = l[i]
    mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)
    
    dam = mvT - (mvX+mvY)

    if dam %2 == 1 or dam < 0:
        print('No')
        exit()

    pT, pX, pY = l[i]

print('Yes')

Submission status: Accepted

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

pT, pX, pY = 0, 0, 0

for i in range(n):
    cT, cX, cY = d[i]
    mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)
    
    dam = mvT - (mvX+mvY)

    if dam%2 == 1 or dam<0:
        print('No')
        exit()

    pT, pX, pY = d[i]

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
L = []
for i in range(N):
    t = list(map(int, input().split()))
    L.append(t)

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

for i in range(1, N+1):
    time = abs(L[i-1][0] - L[i][0])
    distance = abs(L[i-1][1] - L[i][1]) + abs(L[i-1][2] - L[i][2])
    if (time < distance) or (time%2 != distance%2):
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())

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

out='Yes'
for i in range(1,N+1):
    x = np.array(txy[i])
    y = np.array(txy[i-1])
    mv = abs(x-y)
    # print(mv)
    dam = mv[0] - (mv[1] + mv[2])
    if dam%2==1 or dam<0:
        out='No'

print(out)

Submission status: Accepted

Solution code:
import sys
N = int(input())
t_param = 0
x_param = 0
y_param = 0

for i in range(N):
    t, x, y = map(int, input().split())
    if (abs(x - x_param) + abs(y - y_param))  > (abs(t - t_param)) or ((x + y + t)%2) != 0 :
        print('No')
        sys.exit()
    t_param = t
    x_param = x
    y_param = y
print('Yes')

Submission status: Accepted

Solution code:
def check(dest,start):
    ll = dest[1] - start[1] + dest[2]-start[2]
    if ll < 0:
        ll = -ll
    time = dest[0] - start[0]
    tmp = ll - time
    if tmp <= 0 and tmp%2 == 0 :
        return True
    else:
        return False

n = int(input())
start = [0,0,0]
for i in range(n):
    dest = list(map(int, input().split()))
    if check(dest,start):
        start = dest
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n):
    move = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    time = txy[i+1][0]-txy[i][0]
    if time % 2 ^ move % 2 == 1 or time < move:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 21 23:53:42 2020

@author: liang
"""

N = int(input())

prev = (0, 0, 0)

flag = True

for i in range(N):
    t, x, y = map(int, input().split())
    if t%2 != (x+y)%2:
        flag = False
    if abs(x+y - prev[1] - prev[2]) > t-prev[0]:
        flag = False
    prev = (t,x,y)

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

Submission status: Accepted

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

#print(T)
#print(S)

for i in range(1,N+1):
  if (T[i]-T[i-1])<(abs(S[i][0]-S[i-1][0])+abs(S[i][1]-S[i-1][1])):
    f=1
  if (T[i]-T[i-1])%2!=(abs(S[i][0]-S[i-1][0])+abs(S[i][1]-S[i-1][1]))%2:
    f=1

print("Yes" if f==0 else "No")

Submission status: Accepted

Solution code:
N = int(input())

px = 0
py = 0
pt = 0

for _ in range(N):
  T, X, Y = (int(i) for i in input().split())

  d = abs(X - px + Y - py)
  dt = (T - pt)
  if d > dt or (d % 2) != (dt % 2):
    print('No')
    import sys
    sys.exit()
  else:
    px = X
    py = Y
    pt = T

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = []
XY = []
ans = "Yes"

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

if T[0]>=abs(XY[0][0])+abs(XY[0][1]) and T[0]%2==(abs(XY[0][0])+abs(XY[0][1]))%2:
  None
else:
  ans = "No"

for i in range(1,N):
  dT=T[i]-T[i-1]
  dX=abs(XY[i][0]-XY[i-1][0])
  dY=abs(XY[i][1]-XY[i-1][1])
  if dT >= dX+dY and dT%2 == (dX+dY)%2:
    None
  else:
    ans = "No"

print(ans)

Submission status: Accepted

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

n = int(input())
prev_time = 0
prev_point = (0, 0)
for i in range(n):
    t, x, y = map(int, input().split())
    dist = abs(x - prev_point[0]) + abs(y - prev_point[1])
    if dist > (t - prev_time):
        print('No')
        sys.exit(0)

    if (t - prev_time) % 2 != dist % 2:
        print('No')
        sys.exit(0)
    prev_time = t
    prev_point = (x, y)
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

t = [0]
x = [0]
y = [0]
for i in range(N):
    l = [int(c) for c in input().split()]
    t.append(l[0])
    x.append(l[1])
    y.append(l[2])

for i in range(N):
    move = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = t[i+1]-t[i]
    if time%2 ^ move%2 == 1 or time < move:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    txy = [list(map(int,input().split())) for _ in range(N)]
    txy = [[0,0,0]] + txy
    #print(txy)
    for i in range(N):
        temp = txy[i+1][0] - txy[i][0] - abs(txy[i+1][1] - txy[i][1]) - abs(txy[i+1][2] - txy[i][2])  
        if not (temp % 2 == 0 and temp >= 0):
            print("No")
            return
    print("Yes")
        
main()

Submission status: Accepted

Solution code:
from collections import namedtuple
plan = namedtuple('plan', ['time', 'x', 'y'])

def main():
    with open(0) as f:
        N = int(f.readline())
        plans = []
        for _ in range(N):
            t, x, y = map(int, f.readline().split())
            plans.append(plan(t, x, y))
    current = plan(0, 0, 0)
    for p in plans:
        t = p.time - current.time
        way = abs(p.x-current.x) + abs(p.y-current.y)
        if t < way:
            print('No')
            return None
        if (t - way) & 1:
            print('No')
            return None
        current = p
    else:
        print('Yes')

main()

Submission status: Accepted

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

for i in range(N):
  dt = txy[i+1][0] - txy[i][0]
  dx = txy[i+1][1] - txy[i][1]
  dy = txy[i+1][2] - txy[i][2]
  
  if dt < abs(dx + dy):
    print('No')
    break
  else:
    if (dt - (dx + dy)) % 2 != 0:
      print('No')
      break
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

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

judge = 'Yes'

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(1, n+1):
    delt_t = T[i] - T[i-1]
    t_parity = delt_t % 2
    d = abs(X[i] - X[i -1]) + abs(Y[i] - Y[i - 1])
    d_parity = d % 2
    if delt_t >= d and t_parity == d_parity:
        continue
    else:
        judge = 'No'
        break

print(judge)

Submission status: Accepted

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

t=list(range(N+1))
x=list(range(N+1))
y=list(range(N+1))

for i in range(N):
    t[i+1] = l[i][0]
    x[i+1] = l[i][1]
    y[i+1] = l[i][2]

ans = list()

for i in range(N):
    dt = t[i+1] - t[i]
    dp = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dt-dp >= 0 and (dt-dp) % 2 == 0:
        ans.append("y")
    else:
        ans.append("n")
        
if "n" in ans:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
pt,px,py = 0, 0, 0

for _ in range(n):
  ct,cx,cy = map(int,input().split())
  t = ct - pt
  d = abs(cx-px) + abs(cy-py)
  if t < d or (t%2) != (d%2):
    print('No')
    break
  pt,px,py = ct,cx,cy
else:
  print('Yes')

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    xb = 0
    yb = 0
    tb = 0
    for i in range(n):
        t,x,y = i_map()
        walk = abs(x-xb) + abs(y-yb)
        if walk > t-tb: # 時間足りない
            print("No")
            exit()
        if ((t-tb)-walk)%2 != 0: # 戻って来れん
            print("No")
            exit()
        xb = x
        yb = y
        tb = t
    print("Yes")






if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

n = int(input())

t, x, y = 0, 0, 0
for i in range(n):
    t_new, x_new, y_new = list(map(int, input().split()))

    time = t_new-t
    dis = abs(x_new-x)+abs(y_new-y)

    if time < dis:
        print("No")
        exit()
    if time % 2 != dis % 2:
        print("No")
        exit()
    t, x, y = t_new, x_new, y_new
print("Yes")

Submission status: Accepted

Solution code:
n_num = int(input())
plan_list = [[0, (0, 0)]]

def movable(p1, p2):
    time = p2[0] - p1[0]
    distance = 0
    
    distance += abs(p1[1][0] - p2[1][0])
    distance += abs(p1[1][1] - p2[1][1])
    
    if distance > time:
        return 0
    else:
        if (time - distance) % 2 != 0:
            return 0
        else:
            return 1
    

for _ in range(n_num):
    line = [int(i) for i in input().split()]
    plan_list.append([line[0], (line[1], line[2])])
    
vector = (0, 0)

flag = 0
for n in range(1, n_num+1):
    if movable(plan_list[n-1], plan_list[n]) == 0:
        flag = 1
    
if flag == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
t=[]
x=[]
y=[]
for i in range(N):
    txy=list(map(int,input().split()))
    t.append(txy[0])
    x.append(txy[1])
    y.append(txy[2])

now_x=0
now_y=0
now_time=0
isOK=True
for i in range(N):
    dist=(x[i]-now_x)**2+(y[i]-now_y)**2
    time=t[i]-now_time

    if dist<=time**2 and dist%2 ==time%2:
        now_x=x[i]
        now_y=y[i]
        now_time=t[i]
    else:
        isOK=False
        break
        

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

Submission status: Accepted

Solution code:
N = int(input())
T = [0, 0, 0]
ans = "Yes"
for _ in range(N):
    t = list(map(int, input().split()))
    k = abs((t[1]+t[2])-(T[1]+T[2]))
    n = t[0]-T[0]
    if n % 2 == 0:
        if k > n or k % 2 != 0:
            ans = "No"
    else:
        if k > n or k % 2 == 0:
            ans = "No"
    T = t

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
d = [list(map(int,input().split())) for l in range(N)]
d.insert(0,[0,0,0])
#print(N)
#print(d)

def get_length(l1,l2):
    return abs(l1[1] - l2[1]) + abs(l1[2] - l2[2])

for cnt in range(N):
    length = get_length(d[cnt],d[cnt+1])
    time = abs(d[cnt][0]-d[cnt+1][0])
    if length <= time and abs(time - length) % 2 == 0:
        pass
    else:
        print("No")
        sys.exit(0)

print("Yes")

Submission status: Accepted

Solution code:
from collections import deque

N = int(input())
t = deque([0] * N)
x = deque([0] * N)
y = deque([0] * N)

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

N += 1
t.appendleft(0)
x.appendleft(0)
y.appendleft(0)

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

print('Yes')

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())
    if (abs(x - prev_x) + abs(y - prev_y) <= t - prev_t and
        (abs(x - prev_x) + abs(y - prev_y)) % 2 == (t - prev_t) % 2):
        prev_t, prev_x, prev_y = t, x, y
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

# cythonライブラリよみこみ

from libc.stdlib cimport abs as iabs

# define 
ctypedef long long LL
ctypedef LL[:] Arr

import numpy as np
from functools import partial
zeros=partial(np.zeros, dtype=np.int64)


# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち

def exit(*argv,**kwarg):
    print(*argv,**kwarg)
    sys.exit()


cdef LL a_int(): return int(readline())

cdef read_matrix(LL H,LL W):
    #return np.ndarray shape=(H,W) matrix
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)

cdef LL i,j,k,_


# tの偶奇は市松模様の分布になる
# つまり0,0からのマンハッタン距離が偶数のとき偶数時刻を許容でき、距離が奇数のとき奇数時刻を許容できる
# またt[n]-t[n-1]がマンハッタン距離を上回る場合は到達不可能なことに気をつけよう

N=a_int()
data=zeros((N+1,3))
data[1:] = read_matrix(N,3)

cdef Arr T =data[:,0]
cdef Arr X =data[:,1]
cdef Arr Y =data[:,2]

cdef LL manhattan(LL x, LL y):
    return iabs(x)+iabs(y)

cdef LL dt, dd,
for i in range(N):
    dt=T[i+1]-T[i]
    dd=manhattan(X[i+1]-X[i], Y[i+1]-Y[i])
    if (manhattan(X[i+1],Y[i+1])&1 != T[i+1]&1) or (dd>dt):
        exit('No')
print('Yes')



'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode

Submission status: Accepted

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

for i in range(N):
    X=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    T=abs(t[i+1]-t[i])
    if X>T or X%2!=T%2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    x_cur, y_cur, t_cur = 0, 0, 0
    for _ in range(n):
        t, x, y = input_int_list()
        dx = abs(x - x_cur)
        dy = abs(y - y_cur)
        dt = t - t_cur
        if dx + dy > dt:
            print("No")
            return
        if dt % 2 != (dx + dy) % 2:
            print("No")
            return
        else:
            x_cur, y_cur, t_cur = x, y, t
    print("Yes")
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
s = 0
a = 0
b = 0
for i in range(n):
    t,x,y=map(int,input().split())
    if t-s - abs(x-a) - abs(y-b)>=0 and (t-s - abs(x-a) - abs(y-b)) %2 == 0:
        s = t
        a = x
        b = y
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
x0 = 0
y0 = 0
t0 = 0
for i in range(n):
  
  t, x, y = map(int, input().split())
  d = abs(x - x0) + abs (y - y0)
  if d > t - t0:
    print('No')
    exit()
  elif (t - t0 - d) % 2 == 1:
    print('No')
    exit()
  else:
    x0 = x
    y0 = y
    t0 = t

print('Yes')

Submission status: Accepted

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

for i in range(N):
  nt, nx, ny = map(int,input().split())
  if ((nt - t) - abs(nx - x) - abs(ny - y))%2 != 0 or abs(nx - x) + abs(ny - y) > (nt - t):
    ans = "No"
    break
  else:
    t = nt
    x = nx
    y = ny

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
success = True

t0,x0,y0 = 0,0,0
for i in range(N):
  t1,x1,y1 = map(int,input().split())
  dist = abs(x1-x0) + abs(y1-y0)
  time = t1 - t0
  
  check1 = (time == dist)
  check2 = (time > dist) and ((time - dist) % 2 == 0)
  if not (check1 or check2):
    success = False
    break
    
  t0,x0,y0 = t1,x1,y1
    
if success:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
f = 0
a = 0
b = 1
c = 1
for i in range(N):
  a2, b2, c2 = map(int, input().split())
  dis = abs(b2 - b) + abs(c2 - c)
  dis_t = a2 - a
  if dis > dis_t or (dis_t - dis) % 2 == 1:
    f = 1
    break
  a = a2
  b = b2
  c = c2
if f == 1:
  print("No")
else:
  print("Yes")

Submission status: Accepted

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

check = True
for i in range(1,N+1):
  K = txy[i][0] - txy[i-1][0]
  tmp = K - abs(sum(txy[i][1:]) - sum(txy[i-1][1:]))
  if tmp < 0 or tmp % 2 == 1:
    check = False
    break
    
print("Yes" if check else "No")

Submission status: Accepted

Solution code:
n=int(input())
arr=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
  t1,x1,y1=arr[i]
  t2,x2,y2=arr[i+1]
  if abs(x1-x2)+abs(y1-y2)>t2-t1:
    print('No')
    exit()
  if (abs(x1-x2)+abs(y1-y2))%2!=(t2-t1)%2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
 
num,a,b=0,0,0
 
for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num>=su and num%2 == su%2:
    ans="Yes"
  else:
    ans="No"
    break
      
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

for i in range(N):
    if i == 0:
        if (a[i][0] - a[i][1] - a[i][2]) % 2 != 0 or (a[i][0] - a[i][1] - a[i][2]) < 0:
            print("No")
            exit()
    else:
        if (a[i][0] - a[i][1] - a[i][2]) % 2 != 0 or (a[i][0]- a[i-1][0]) -( (a[i-1][1] + a[i-1][2] )-(a[i][1] + a[i][2])) < 0:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
#2パターンでのfail
#①→偶奇がstepと位置で違う
#単純に遠すぎる
n = int(input())

t_pre =0
x_pre =0
y_pre =0
for i in range(n):
    t,x,y = list(map(int,input().split()))
    if (t-t_pre)<abs(x-x_pre)+abs(y-y_pre):
        print('No')
        break
    if t%2 != (x+y)%2:
        print('No')
        break
    t_pre = t
    x_pre =x
    y_pre = y
    
    if i ==n-1:
        print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
P = [list(map(int,input().split())) for i in range(N)] # list of [t, x, y]
pret = prex = prey = 0
f = 1
for i in range(N):
    t = P[i][0]
    x = P[i][1]
    y = P[i][2]
    td = t - pret
    xd = abs(x - prex)
    yd = abs(y - prey)
    diff = xd + yd # 最低かかるt
    if td < diff:
        f = 0
        break
    if (td - diff) % 2 == 0:
        pret = t
        prex = x
        prey = y
        continue
    else:
        f = 0
        break
if f == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

    if abs(dt - t) < dist or (dt - t - dist) % 2:
        print("No")
        exit()

    x, y, t = dx, dy, dt
print("Yes")

Submission status: Accepted

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

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

    if abs(dt - t) < dist:
        print("No")
        exit()
    if abs(dt - t) % 2:
        if dist % 2 == 0:
            print("No")
            exit()
    else:
        if dist % 2 == 1:
            print("No")
            exit()
    x, y, t = dx, dy, dt
print("Yes")

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N = int(input())
x0,y0,t0 = 0,0,0
ans = True
for _ in range(N):
    t,x,y = mint()
    tmp = (t-t0)-(abs(x-x0)+abs(y-y0))
    if not (tmp>=0 and tmp%2==0):
        ans = False
        break
    x0,y0,t0 = x,y,t
judge(ans)

Submission status: Accepted

Solution code:
N = int(input())
t_x_y = [list(map(int, input().split())) for _ in range(N)]
t_x_y.insert(0, [0, 0, 0])
 
ans = 'Yes'
for i in range(N):
  dt = t_x_y[i+1][0] - t_x_y[i][0]
  dist = abs(t_x_y[i+1][1] - t_x_y[i][1]) + abs(t_x_y[i+1][2] - t_x_y[i][2])
  
  # dt < dist が必要
  if dt < dist:
    ans = 'No'
    break
  else:
    # dt >= dist の上で、dtとdistの偶奇が一致すればよい
    if (dt - dist) % 2 != 0:
      ans = 'No'
      break
  
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num>=su and num%2 == su%2:
    ans="Yes"
  else:
    ans="No"
    break
      
print(ans)

Submission status: Accepted

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

ans = 'Yes'
for i in range(N):
  dt = t_x_y[i+1][0] - t_x_y[i][0]
  dist = abs(t_x_y[i+1][1] - t_x_y[i][1]) + abs(t_x_y[i+1][2] - t_x_y[i][2])
  
  if dt < dist:
    ans = 'No'
    break
  else:
    # dt >= dist
    if (dt - dist) % 2 != 0:
      ans = 'No'
      break
  
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
rx = 0
ry = 0
rt = 0
ok = True
for _ in range(n):
    t, x, y = map(int, input().split())
    dist = abs(x-rx) + abs(y-ry)
    #print(dist)
    if dist <= abs(t-rt) and (abs(t-rt)-dist)%2 == 0:
        rx = x
        ry = y
        rt = t
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
rx = 0
ry = 0
rt = 0
ok = True
for _ in range(n):
    t, x, y = map(int, input().split())
    dist = abs(x-rx) + abs(y-ry)
    #print(dist)
    if dist <= abs(t-rt) and (abs(t-rt)-dist)%2 == 0:
        rx = x
        ry = y
        rt = t
    else: ok = False

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

Submission status: Accepted

Solution code:

N = int(input())

res = True
pre_t, pre_x, pre_y = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    tmp = (t - pre_t) - abs(x - pre_x) - abs(y - pre_y)
    if tmp < 0 or tmp % 2 == 1:
        res = False
        break
    pre_t = t
    pre_x = x
    pre_y = y
    
print('Yes' if res else 'No')

Submission status: Accepted

Solution code:
import sys
from typing import NamedTuple, List


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


class Position(NamedTuple):
    t: int
    x: int
    y: int

    def _calc_diff_move(self, position) -> int:
        diff_x = self.x - position.x
        diff_y = self.y - position.y
        return abs(diff_x) + abs(diff_y)

    def can_move_from(self, prev) -> bool:
        diff_t = self.t - prev.t
        diff_move = self._calc_diff_move(prev)
        if not diff_t % 2 == diff_move % 2:
            return False
        return diff_t >= diff_move


def result_format(b: bool) -> str:
    return "Yes" if b else "No"


def solve(positions: List[Position]) -> bool:
    positions = [Position(t=0, x=0, y=0)] + positions
    for p_ind in range(len(positions) - 1):
        p_curr = positions[p_ind]
        p_next = positions[p_ind + 1]
        if not p_next.can_move_from(p_curr):
            return False
    return True


def main():
    n = int(fast_input())
    positions = []
    for _ in range(n):
        t, x, y = list(map(int, fast_input().split()))
        positions.append(Position(t=t, x=x, y=y))
    result = solve(positions)
    print(result_format(result))


main()

Submission status: Accepted

Solution code:
#!/user/bin/env pypy3
import sys
from typing import NamedTuple, List


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


class Position(NamedTuple):
    t: int
    x: int
    y: int

    def _calc_diff_move(self, position) -> int:
        diff_x = self.x - position.x
        diff_y = self.y - position.y
        return abs(diff_x) + abs(diff_y)

    def can_move_from(self, prev) -> bool:
        diff_t = self.t - prev.t
        diff_move = self._calc_diff_move(prev)
        if not diff_t % 2 == diff_move % 2:
            return False
        return diff_t >= diff_move


def result_format(b: bool) -> str:
    return "Yes" if b else "No"


def solve(positions: List[Position]) -> bool:
    positions = [Position(t=0, x=0, y=0)] + positions
    for p_ind in range(len(positions) - 1):
        p_curr = positions[p_ind]
        p_next = positions[p_ind + 1]
        if not p_next.can_move_from(p_curr):
            return False
    return True


def main():
    n = int(fast_input())
    positions = []
    for _ in range(n):
        t, x, y = list(map(int, fast_input().split()))
        positions.append(Position(t=t, x=x, y=y))
    result = solve(positions)
    print(result_format(result))


main()

Submission status: Accepted

Solution code:
#!/user/bin/env pypy3
import sys
from typing import NamedTuple, List


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


class Position(NamedTuple):
    t: int
    x: int
    y: int

    def _calc_diff_move(self, position) -> int:
        diff_x = self.x - position.x
        diff_y = self.y - position.y
        return abs(diff_x) + abs(diff_y)

    def can_move_from(self, prev) -> bool:
        diff_t = self.t - prev.t
        diff_move = self._calc_diff_move(prev)
        # 奇数のときはその場禁止
        if not diff_t % 2 == diff_move % 2:
            return False
        return diff_t >= diff_move


def result_format(b: bool) -> str:
    return "Yes" if b else "No"


def solve(positions: List[Position]) -> bool:
    positions = [Position(t=0, x=0, y=0)] + positions
    for p_ind in range(len(positions) - 1):
        p_curr = positions[p_ind]
        p_next = positions[p_ind + 1]
        if not p_next.can_move_from(p_curr):
            return False
    return True


def main():
    n = int(fast_input())
    positions = []
    for _ in range(n):
        t, x, y = list(map(int, fast_input().split()))
        positions.append(Position(t=t, x=x, y=y))
    result = solve(positions)
    print(result_format(result))


main()