Problem:


Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.

If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

1 ≤ N ≤ 10^5

0 ≤ x_i ≤ 10^5

0 ≤ y_i ≤ 10^5

1 ≤ t_i ≤ 10^5

t_i < t_{i+1} (1 ≤ i ≤ N-1)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
t_1 x_1 y_1
t_2 x_2 y_2
:
t_N x_N y_N

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at (100,100) two seconds after being at (0,0).

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No



Sample input:
2
3 1 2
6 1 1


Sample output:
Yes

Submission status: Accepted

Solution code:
n = int(input())
t_l = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
t_t = [[abs(t_l[i][0]-t_l[i-1][0]), abs(t_l[i][1]-t_l[i-1][1]), abs(t_l[i][2]-t_l[i-1][2])] for i in range(1,n+1)]
ans = "Yes"

for j in t_t:
    t, x, y = j
    if t < x + y:
        ans = "No"
        break
    elif t % 2 != (x + y) % 2:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
x=[list(map(int, input().split())) for _ in range(n)]

now=0
nplace=[0,0]
noflag=False
for y in x:
    dis=sum(map(abs, (np.array(y[1:]) - np.array(nplace))))
    # print(dis)
    if not ((dis<=(y[0]-now)) & ((y[0]-now-dis)%2==0)):
        noflag=True

    now=y[0]
    nplace=y[1:]
print('Yes') if noflag==False else print('No')

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())
    r=abs(X-x)+abs(Y-y)
    t=T-t
    if r%2!=t%2 or t<r:
        print('No')
        exit()
    t=T;x=X;y=Y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
TB,XB,YB = 0,0,0
Flag = True
for Z in range(0,N):
    TA,XA,YA = (int(A) for A in input().split())
    RestT = (TA-TB)-(abs(XA-XB)+abs(YA-YB))
    if RestT<0 or RestT%2!=0:
        Flag = False
        break
    else:
        TB,XB,YB = TA,XA,YA
if Flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
pos = [0,0]
time = 0
for _ in range(N):
    t,x,y = [int(i) for i in input().split()]
    d = abs(pos[0] - x) + abs(pos[1] - y)
    if d > t - time:
        print("No")
        break
    elif (t - time - d)%2 != 0:
        print("No")
        break
    pos = [x,y]
    time = t
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n):
    t = infos[i+1][0]-infos[i][0]
    abs_x = abs(infos[i][1]-infos[i+1][1])
    abs_y = abs(infos[i][2]-infos[i+1][2])
    d = abs_x + abs_y
    if t < d or t%2!=d%2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t, x, y = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    tn, xn, yn = map(int, input().split())
    d = abs(xn - x) + abs(yn - y)
    td = tn - t
    if d > td or (d - td)%2 != 0:
        ans = 'No'
    t, x, y = tn, xn, yn
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = True
preT,preX,preY = 0,0,0
for i in range(N):
    t,x,y = map(int,input().split())

    if abs(x-preX)+abs(y-preY) > t - preT:
        ans=False
    if (-abs(x-preX)-abs(y-preY) + t - preT)%2==1:
        ans=False
    
    preX = x
    preY = y
    preT = t

print("Yes" if ans else "No")

Submission status: Accepted

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

flag = 0
for i in range(n):
  delta = a[i+1][0]-a[i][0]
  distance = abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2])
  if delta < distance or delta%2 != distance%2:
    flag = 1
    break
    
if flag == 1:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
points = []
points.append([0, 0, 0])
can = True
for i in range(n):
    points.append([i for i in map(int, input().split())])
    move_n = points[i+1][0] - points[i][0]
    dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
    if move_n < dist or dist % 2 != move_n % 2:
        can = False 
        break
# print(points)
# can = True
# for i in range(len(points)-1):
#     move_n = points[i+1][0] - points[i][0]
#     dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
#     if move_n < dist or dist % 2 != move_n % 2:
#         can = False 
#         break

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

Submission status: Accepted

Solution code:
n = int(input())
points = []
points.append([0, 0, 0])
for i in range(n):
    points.append([i for i in map(int, input().split())])
# print(points)
can = True
for i in range(len(points)-1):
    move_n = points[i+1][0] - points[i][0]
    dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
    if move_n < dist or dist % 2 != move_n % 2:
        can = False 
        break

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

Submission status: Accepted

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

can = True

t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)

for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dt < dist:
        can = False
        break
    if dt%2 == 0 and dist%2 == 0:
        continue
    elif dt%2 == 1 and dist%2 == 1:
        continue
    else:
        can = False
        break

if can == True:
    print('Yes')
elif can == False:
    print('No')

Submission status: Accepted

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for txyi, txyip in zip([[0, 0, 0]] + txy[:-1], txy):
    ti, xi, yi = txyi
    tip, xip, yip = txyip
    dift = tip - ti
    difd = abs(xip-xi) + abs(yip-yi)
    if difd%2 != dift%2:
        print('No')
        exit()
    if dift < difd:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())

bt, bx, by = 0, 0, 0
cond = True
for i in range(n):
    t, x, y = [int(w) for w in input().split()]
    dt = t-bt
    dist = abs(bx-x)+abs(by-y)
    if dt >= dist and (dt-dist) % 2 == 0:
        bt, bx, by = t, x, y
        continue
    cond = False


print("Yes" if cond else "No")

Submission status: Accepted

Solution code:
N = int(input())

t=x=y=0

for _ in range(N):
    ti,xi,yi = map(int,input().split())
    T = ti-t
    X = xi-x
    Y = yi-y
    if ((T%2==0 and (X+Y)%2==0) or (T%2==1 and (X+Y)%2==1)) and T >= abs(X+Y):
        t=ti
        x=xi
        y=yi
    else:
        print('No')
        break
else:print('Yes')

Submission status: Accepted

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

now = [0,0]
time = 0

for i in range(n):
    t,x,y = lst[i][0], lst[i][1], lst[i][2]
    distance = abs(now[0]-x) + abs(now[1]-y)
    if (t - time) % 2 == 0 and distance % 2 == 0 and (t - time) >= distance:
        now = [x,y]
        time = t
    elif (t - time) % 2 != 0 and distance % 2 != 0 and (t - time) >= distance:
        now = [x,y]
        time = t
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

lastT, lastX, lastY = 0, 0, 0
flag = "Yes"

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

    # print( math.fabs(t - lastT) + math.fabs(t - lastT) )

    if ( t - lastT < math.fabs(x - lastX) + math.fabs(y - lastY)
        or ( (t - lastT) - math.fabs(x - lastX) - math.fabs(y - lastY) ) % 2 == 1 ):
        flag = "No"

    lastT = t
    lastX = x
    lastY = y

print(flag)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys

n = int(stdin.readline().rstrip())

A = [0, 0, 0]
for i in range(n):
    B = [int(j) for j in stdin.readline().rstrip().split()]

    t = B[0]-A[0]
    x = abs(B[1]-A[1])
    y = abs(B[2]-A[2])

    z = x+y

    if t % 2 == 1:
        if not(z % 2 == 1 and z <= t):
            print("No")
            sys.exit()

    else:
        if not(z % 2 == 0 and z <= t):
            print("No")
            sys.exit()

    A = B

print ("Yes")

Submission status: Accepted

Solution code:
def main(points):
    points.insert(0, [0, 0, 0])
    for i in range(len(points) - 1):
        p1 = points[i]
        p2 = points[i + 1]
        t = p2[0] - p1[0]
        if not can_reach(p1[1:], p2[1:], t):
            print('No')
            return
    print('Yes')


def can_reach(p1, p2, t):
    length = abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
    return length <= t and (length - t) % 2 == 0


if __name__ == "__main__":
    points = []
    n = int(input())
    for i in range(n):
        points.append([int(x) for x in input().split(' ')])
    main(points)

Submission status: Accepted

Solution code:
n = int(input())

now_time = 0
now_x = 0
now_y = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    xy_diff = abs(x - now_x) + abs(y - now_y)

    if t - now_time < xy_diff:
        print("No")
        exit()
    if (t - now_time) % 2 == 0:
        if xy_diff % 2 != 0:
            print("No")
            exit()
        else:
            now_time = t
            now_x = x
            now_y = y
    else:
        if xy_diff % 2 != 1:
            print("No")
            exit()
        else:
            now_time = t
            now_x = x
            now_y = y

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
P = [[0,0,0]]+[list(map(int,input().split())) for n in range(N)]
ans = "Yes"

for n in range(N):
  dt = P[n+1][0]-P[n][0]
  dx = abs(P[n+1][1]-P[n][1])
  dy = abs(P[n+1][2]-P[n][2]) 
  if dt<dx+dy or dt%2!=(dx+dy)%2:
    ans = "No"

print(ans)

Submission status: Accepted

Solution code:
from collections import deque
n = int(input())

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

tn, xn, yn = 0, 0, 0
while txy:
    t, x, y = txy.popleft()
    if (abs(xn-x)+abs(yn-y)<=(t-tn)) and (abs(xn-x)+abs(yn-y))%2==(t-tn)%2:
        tn, xn, yn = t, x, y
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

# 現時点でのパラメータ
pt = 0
px = 0
py = 0

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

    time = abs(t - pt)
    # いわゆるマンハッタン距離
    dist = abs(x - px) + abs(y - py)

    if dist > time:
        print("No")
        exit()

    # x+yの偶奇は毎秒変わる
    # timeとdistの偶奇は一致する
    if time % 2 != dist % 2:
        print("No")
        exit()

    pt, px, py = t, x, y

print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(n, ), *p = [[*map(int, i.split())] for i in open(0)]
t, x, y = 0, 0, 0
for a, b, c in p:
    d = abs(x - b) + abs(y - c) - a + t
    if d <= 0 and d % 2 < 1:
        t, x, y = a, b, c
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
t,x,y = [list(i) for i in zip(*l)]
p = 0
q = 0

for i in range(n):
    z = abs(p - (x[i] + y[i]))
    if ((t[i] - q) - z) % 2 == 0 and (t[i] - q) - z >= 0:
        p = x[i] + y[i]
        q = t[i]
    else:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    pre_t = 0
    pre_x = 0
    pre_y = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        d_dis = abs(x - pre_x) + abs(y - pre_y)
        d_t = abs(t - pre_t)
        if d_dis > d_t:
            print('No')
            sys.exit()
        elif (d_t - d_dis) % 2 == 1:
            print('No')
            sys.exit()
        else:
            pre_t = t
            pre_x = x
            pre_y = y
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

#--------------------------------------------
now = [0,0]
now_time = 0
for i in range(N):
  left_time = T[i][0] - now_time
  target = [T[i][1],T[i][2]]
  distance = abs(T[i][1]-now[0]) + abs(T[i][2]-now[1])
  if distance <= left_time and distance % 2 == left_time % 2:
    now_time = T[i][0]
    now = target
    
  else:
    print("No")
    sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
I = int(input())

pt = px = py = 0
for i in range(I):
    t, x, y = map(int, input().split())

    costtime = abs(t - pt)
    distance = abs(x - px) + abs(y - py)

    if costtime%2 != distance%2:
        print("No")
        exit()

    if costtime < distance:
        print("No")
        exit()

    pt,px,py = t,x,y

print("Yes")

Submission status: Accepted

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

ans = "Yes"
for i in range(n):
    dt = t[i+1] - t[i]
    ddis = abs(x[i + 1] + y[i + 1] - (x[i] + y[i]))
    if not (ddis <= dt and ((dt % 2 == 0 and ddis % 2 == 0) or (dt % 2 == 1 and ddis % 2 == 1))):
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
import sys
from math import sqrt
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    possible = True
    pre_t, pre_x, pre_y = 0, 0, 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        dist = abs(x - pre_x) + abs(y - pre_y)
        time = t - pre_t
        #print("dist={}".format(dist))
        if dist <= time and (time - dist) % 2 == 0:
            pre_t, pre_x, pre_y = t, x, y
        else:
            possible = False
            break
    if possible:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
kot="Yes"
at,a1,a2=0,0,0
for i in range(n):
  a=list(map(int,input().split()))
  a[0]=a[0]-at
  a[1]=a[1]-a1
  a[2]=a[2]-a2
  gou=max(a[1]+a[2],(-1*a[1])+a[2],a[1]+(-1*a[2]),(-1*a[1])+(-1*a[2]))
  if a[0]%2!=(gou)%2:
    kot="No"
    break
  if a[0] < gou:
    kot="No"
    break
  at,a1,a2=a
print(kot)

Submission status: Accepted

Solution code:
N = int(input())
now_t, now_x, now_y = 0, 0, 0

for _ in range(N):
  t, x, y = list(map(int, input().split()))
  distance = abs(now_x - x) + abs(now_y - y)
  has_time = t - now_t
  if (distance - has_time) > 0 or (distance - has_time) % 2:
    print("No")
    break
  now_t, now_x, now_y = t, x, y
else:
  print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
t_now = 0
pos = [0,0]
l = [list(map(int, input().split())) for _ in range(n)]

for t, x, y in l:
    t_d = t - t_now
    range_move = list(range(-t_d, t_d+1, 2))

    pos_d = (x-pos[0]) + (y-pos[1])

    if pos_d in range_move:
        t_now = t
        pos = [x, y]
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
N=int(input())

t,x,y=0,0,0
F=True
for _ in range(N):
    s,a,b=t,x,y
    t,x,y=map(int,input().split())

    m=abs(x-a)+abs(y-b)
    if not(m<=t-s and (t-s-m)%2==0):
        F=False

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

Submission status: Accepted

Solution code:
N = int(input())
_t, _x, _y = 0, 0, 0
flg = True
for i in range(N):
    t, x, y = list(map(int, input().split()))
    dt = t - _t
    dd = abs(x - _x) + abs(y - _y)
    if not (dd <= dt and dt % 2 == dd % 2):
        flg = False
    _t, _x, _y = t, x, y
if flg:
    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())

x_defo = 0
y_defo = 0
t_defo = 0
result = 0

for i in range(n):
    dt = t[i] - t_defo
    it = abs(x[i]-x_defo) + abs(y[i]-y_defo)
    if it > dt:
        result = 1
        break
    if it %2 != dt %2:
        result = 1
        break
    else:
        x_defo = x[i]
        y_defo = y[i]
        t_defo = t[i]

if result ==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

f = True
for i in range(N):
    dt = t[i+1] - t[i]
    dictlist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    
    if dt < dictlist:
        f = False
    if dictlist % 2 != dt % 2:
        f = False

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

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ct,cx,cy=0,0,0
for t,x,y in l:
    dt=t-ct
    d=abs(cx-x)+abs(cy-y)
    if dt-d<0 or (dt-d)%2==1:
        print('No')
        exit()
    ct,cx,cy=t,x,y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
pt, px, py = 0, 0, 0
flag = True
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(px - x) + abs(py - y)
    dt = t - pt
    if d <= dt and dt % 2 == d % 2:
        pt, px, py = t, x, y
        continue
    flag = False
    break

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

Submission status: Accepted

Solution code:
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)

flag = True
for i in range(N):
    time = T[i+1]-T[i]
    dist = abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])
    if time < dist or (dist%2!=time%2):
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(n):
    dt=t[i+1]-t[i]
    dx=x[i+1]-x[i]
    dy=y[i+1]-y[i]
    dl=abs(dx)+abs(dy)
    if dl<=dt and dt%2==dl%2:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import math
n = int(input())
txy = [map(int, input().split()) for _ in range(n)]
t, x, y = [list(i) for i in zip(*txy)]

gt = 0
gx = 0
gy = 0

for i in range(n):
    wt = t[i] -gt
    ww = abs(x[i] - gx) + abs(y[i] - gy)
    if (wt < ww) or ((wt - ww) % 2 == 1):
        print("No")
        break

    gt = t[i]
    gx = x[i]
    gy = y[i]

else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

tn = 0
xn = 0
yn = 0
j = True
for i in range(n):
    td, xd, yd = map(int, input().split())
    t = td - tn
    x = abs(xd - xn)
    y = abs(yd - yn)
    xn = xd
    yn = yd
    tn = td
    if t%2 == (x + y)%2 and (x + y) <= t:
        continue
    j = False
if j:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())

t_,x_,y_=(0,0,0)

ans = 'Yes'
for n in range(N):
    t,x,y = list(map(int,input().split()))
    T = t-t_
    manhattan_dist = abs(x-x_)+abs(y-y_)
#     print(T,manhattan_dist)
    if T >= manhattan_dist and manhattan_dist%2 == T%2:
        pass
    else:
        ans='No'
        
    t_,x_,y_ = t,x,y

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    t,x,y = map(int,input().split())
    l.append([t,x,y])
for i in range(n):
    t,x,y = l[i][0],l[i][1],l[i][2]
    if x+y > t or (t-(x+y))%2 != 0:
          print('No')
          exit()
l.sort()
for i in range(n-1):
    t,x,y = l[i][0],l[i][1],l[i][2]
    t_,x_,y_ = l[i+1][0],l[i+1][1],l[i+1][2]
    if t_ - t < (abs(x-x_)+abs(y-y_)):
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t = [list(map(int,input().split())) for _ in range(n)]
t.insert(0,[0,0,0])
for i in range(1,n+1):
    d_sec = t[i][0] - t[i-1][0]
    d_x = abs(t[i][1]- t[i-1][1])
    d_y = abs(t[i][2]- t[i-1][2])
    d_xy = d_x + d_y
    if (d_sec < d_xy) | (d_sec%2 != d_xy%2):
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

t_0 = 0
x_0 = 0
y_0 = 0

can = True

dt = t[0] - t_0
dx = x[0] - x_0
dy = y[0] - y_0
dist = abs(dx) + abs(dy)

if dt >= dist and dt % 2 == dist % 2:
    can = True
else:
    can = False

for i in range(1, n):
    dt = t[i] - t[i - 1]
    dx = x[i] - x[i - 1]
    dy = y[i] - y[i - 1]
    dist = abs(dx) + abs(dy)
    if dt >= dist and dt % 2 == dist % 2:
        can = True
    else:
        can = False
        break

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

pass

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N=int(input())

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

dtxy = []
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]
    ds = dt-abs(dx)-abs(dy)
    if ds<0 or ds%2 !=0:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline #inputに置き換え可能

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

flg = True
for i in range(1, n+1):
    dt = txy[i][0] - txy[i-1][0] 
    dx = abs(txy[i][1] - txy[i-1][1])
    dy = abs(txy[i][2] - txy[i-1][2])
    dxdy = dx + dy
    if dt % 2 != dxdy % 2 or dt < dxdy:
        flg = False
        break
print('Yes') if flg else print('No')

Submission status: Accepted

Solution code:
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
t_bef=0
x_bef=0
y_bef=0
flag='Yes'

for i in range(1,n+1):
    t,x,y=map(int,input().split())
    dt=t-t_bef
    dist=abs(x-x_bef)+abs(y-y_bef)
    if (dt%2 != dist%2) or dist>dt:
        flag='No'
        break
    t_bef,x_bef,y_bef=t,x,y

print(flag)

Submission status: Accepted

Solution code:
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
t_bef=0
x_bef=0
y_bef=0
flag='Yes'

for i in range(1,n+1):
    t,x,y=map(int,input().split())
    dt=t-t_bef
    dist=abs(x-x_bef)+abs(y-y_bef)
    if (dt%2 != dist%2) or dist>dt:
        flag='No'
        #break
    t_bef,x_bef,y_bef=t,x,y

print(flag)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for _ in range(n):
  a.append([int(i) for i in input().split()])
b=[0,0,0]
for i in range(n):
  minC=abs(a[i][1]-b[1])+abs(a[i][2]-b[2])
  if a[i][0]-b[0]<minC or (a[i][0]-b[0]-minC)%2==1:
    print("No")
    break
  b=a[i]
else:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

pos_x=0
pos_y=0
t_now=0
flg = True
for i in range(N):
    t,x,y = map(int,input().split())
    t_del = t-t_now
    res = (t_del-abs(pos_x-x)-abs(pos_y-y))
    if (res>=0) & (res%2==0):
        t_now = t
        pos_x = x
        pos_y=y
        pass
    else:
        flg = False
        break

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    txys = [list(map(int, input().split())) for _ in range(n)]
    txys.insert(0, [0, 0, 0])
    ans = 'Yes'
    for i in range(n):
        time_diff = txys[i+1][0] - txys[i][0]
        manhattan_dis = abs(txys[i][1] - txys[i+1][1]) + abs(txys[i][2] - txys[i+1][2])
        if time_diff < manhattan_dis:
            ans = 'No'
            break
        elif time_diff == manhattan_dis:
            continue
        else:
            if (time_diff - manhattan_dis) % 2 == 0:
                continue
            else:
                ans = 'No'
                break
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

now_t = 0
now_xy = 0
for i in range(n):
    t, x, y = map(int, input().split())
    baf = 0
    if not abs((x+y) - now_xy) == t - baf*2 - now_t:
        while t-baf*2-now_t >= 2:
            baf += 1
            if abs((x+y) - now_xy) == t - baf*2 - now_t:
                break
        else:
            print("No")
            exit()
    now_t = t
    now_xy = x + y
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = 0
x = 0
y = 0
for ti, xi, yi in [map(int, input().split(' ')) for n in range(N)]:
    if not (abs(xi-x)+abs(yi-y) <= ti-t and ti%2 == (xi+yi)%2):
        print('No')
        exit()
    else:
        t = ti
        x = xi
        y = yi
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
ans = "Yes"
for _ in range(N):
    t, x, y = map(int, input().split())
    if t - prev_t < abs(prev_x - x) + abs(prev_y - y):
        ans = "No"
    if (abs(prev_x - x) + abs(prev_y - y)) % 2 != (t - prev_t) % 2:
        ans = "No"
    prev_t, prev_x, prev_y = t, x, y
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
st, stx, sty = 0, 0, 0
ans = "Yes"
for t, x, y in txy:
    ta, xa, ya = abs(t - st), abs(x - stx), abs(y - sty)
    if ta >= xa + ya and (
        (ta % 2 == 1 and (xa + ya) % 2 == 1) or (ta % 2 == 0 and (xa + ya) % 2 == 0)
    ):
        st, stx, sty = t, x, y
    else:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
#Coding by Rute
#ABC086 C - Travelingの解説を始めます。この問題ですが条件分岐によりO(N)で解くことが出来ました。
N = int(input())
now_t = 0 #現在のtとします。
now_x = 0 #現在のxとします。
now_y = 0 #現在のyとします。
flag = 0 #フラグ関数です。flag = 1のときNo, 0のときYesを出力します。
for i in range(N):
    t,x,y = map(int,input().split())
    #条件判定としては、|x-now_x|+|y-now_y| ≦ |t-now_t| かつ |x-now_x|+|y-now_y|の偶奇が|t-now-t|と一致するかどうかを判断すれば良いです。
    #なお、after contestがないケースは、|x-now_x|+|y-now_y| ≦ t で全て通っていました。
    if abs(x-now_x)+abs(y-now_y)<= abs(t-now_t) and (abs(x-now_x)+abs(y-now_y))%2 == abs(t-now_t)%2:
        now_t = t
        now_x = x
        now_y = y
    else:
        flag += 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
can = True
time = 0
x = 0
y = 0
for _ in range(n):
    t, xx, yy = map(int,input().split())
    distance = abs(x-xx) + abs(y - yy)
    difft = t - time
    if difft < distance:
        can = False
        break
    if (distance - difft) % 2 == 1:
        can = False
        break


    x = xx
    y = yy
    time = t
print("Yes" if can else "No")

Submission status: Accepted

Solution code:
n = int(input())
t = 0
x = 0
y = 0
for _ in range(n):
	nt, nx, ny = map(int,input().split())
	sa = nt-t
	t = nt
	kyori = abs(nx-x) + abs(ny-y)
	x = nx
	y = ny
	if kyori > sa or (sa-kyori) % 2 == 1:
		print("No")
		exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

def f(x1,y1,x2,y2,t):
    l = abs(x1-x2)+abs(y1-y2)
    if l <= t:
        if l%2 == t%2:
            return True
    return False

if __name__ == "__main__":
    n = I()
    t = [0]
    x = [0]
    y = [0]
    for i in range(n):
        a,b,c = I2()
        t.append(a)
        x.append(b)
        y.append(c)
    for i in range(n):
        #print(x[i],y[i],x[i+1],y[i+1],t[i+1]-t[i])
        if not f(x[i],y[i],x[i+1],y[i+1],t[i+1]-t[i]):
            print("No")
            exit()
    print("Yes")

Submission status: Accepted

Solution code:
N = int (input ())
t2 = 0
x2 = 0
y2 = 0
ans = 'Yes'
for i in range (N):
    t,x,y = map(int, input().split())
    if abs(x+y-x2-y2) <= t-t2:
        if ((abs(x2+y2-x-y))-(t-t2)) % 2 == 1:
            ans = 'No'
            break
    else:
        ans = 'No'
        break
    t2 = t
    x2 = x
    y2 = y
print (ans)

Submission status: Accepted

Solution code:
n = int(input())
curt, curx, cury = 0, 0, 0
ans = 'Yes'
for _ in range(n):
   t, x, y = map(int, input().split())
   d = abs(x - curx) + abs(y - cury)
   if d > (t - curt) or (t - curt) % 2 != d % 2:
      ans = 'No'
      break
   curt, curx, cury = t, x, y

print(ans)