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())
dt, dx, dy = 0, 0, 0
avilable = True
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-dx)+abs(y-dy) > t-dt or (abs(x-dx)+abs(y-dy)) % 2 != (t-dt) % 2:
        avilable = False
    dt = t
    dx = x
    dy = y
if avilable:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
can = True
t,x,y = 0,0,0

for i in range(n):
    t_,x_,y_ = map(int,input().split())
    dt = t_ - t
    dist = abs(x-x_) + abs(y-y_)
    if dt < dist:
        can = False
    else:
        if (dist-dt) % 2 != 0:
            can = False
    t,x,y = t_,x_,y_

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

Submission status: Accepted

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

for n in range(N):
  D = abs(X[n+1]+Y[n+1]-X[n]-Y[n])
  if T[n+1]-T[n] == D:
    pass
  elif T[n+1]-T[n]>D and (T[n+1]-T[n]-D)%2==0:
    pass
  else:
    print("No")
    exit()
    
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())

a,b,c=0,0,0

for i in range(n):
  x,y,z=map(int,input().split())
  dist=abs(b-y)+abs(c-z)
  if dist>x-a or (dist-(x-a))%2==1:
    print('No')
    exit()
    
  else:
    a,b,c=x,y,z
    continue
    
print('Yes')

Submission status: Accepted

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

current = (0, 0, 0)
for next_ in states:
  diff_time = next_[0] - current[0]
  diff_dist = abs(next_[1] - current[1]) + abs(next_[2] - current[2])
  if diff_dist > diff_time:
    print("No")
    break
  elif diff_time % 2 == diff_dist % 2:
    current = next_
  else:
    print("No")
    break

if current == states[-1]:
	print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

now, now_x, now_y = 0, 0, 0

for t, x, y in plan:
    if abs(x - now_x) + abs(y - now_y) > t - now:
        print('No')
        exit()
    elif ((t - now) - abs(x - now_x) - abs(y - now_y)) % 2 == 1:
        print('No')
        exit()
    now = t
    now_x = x
    now_y = y
print('Yes')

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    t_lst = [0] * (N + 1)
    x_lst = [0] * (N + 1)
    y_lst = [0] * (N + 1)

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

    ans = "Yes"
    for i in range(N):
        dt = t_lst[i + 1] - t_lst[i]
        dist = abs(x_lst[i + 1] - x_lst[i]) + abs(y_lst[i + 1] - y_lst[i])
        if dt < dist:
            ans = "No"
            break
        elif dt % 2 != dist % 2:
            ans = "No"
            break

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

from typing import Tuple
from typing import List


Coordinate = Tuple[int, int, int]


def main():
    N = int(input())
    codList: List[Coordinate] = [(0, 0, 0)]
    for i in range(0, N):
        args = list(map(lambda x: int(x), input().split()))
        codList.append((args[0], args[1], args[2]))

    for i in range(1, N + 1):
        start = codList[i - 1]
        end = codList[i]
        dis = distance(start, end)
        duration = end[0] - start[0]

        if (duration - dis >= 0) and ((duration - dis) % 2 == 0):
            continue
        else:
            print("No")
            return

    print("Yes")


def distance(cod1: Coordinate, cod2: Coordinate):
    return abs(cod1[1] - cod2[1]) + abs(cod1[2] - cod2[2])


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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())
  dt = T - t
  dist = abs(X-x) + abs(Y - y)
  if dist > dt:
    print("No")
    break
  if dist%2 != dt%2:
    print("No")
    break
  t = T
  x = X
  y = Y
  if i == N - 1:
    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])
x = [t[i][1] for i in range(N+1)]
y = [t[i][2] for i in range(N+1)]
t = [t[i][0] for i in range(N+1)]
for i in range(1, N+1):
    if abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) > t[i] - t[i-1] or (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) %2 != (t[i] - t[i-1]) % 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def move_time(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)

n = int(input())
t1 = 0
x1 = 0
y1 = 0
isYes = True
for i in range(n):
    t2,x2,y2 = map(int,input().split())
    tm = move_time(x1,y1,x2,y2)
    #print(tm,t2,x2,y2)
    if tm>(t2-t1):
        isYes = False
    elif ((t2-t1)-tm)%2==1:
        isYes = False
    t1 = t2
    x1 = x2
    y1 = y2

if isYes:
    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_)

for j in range(n):
  dt = t[j+1] - t[j]
  dx = abs(x[j+1] - x[j])
  dy = abs(y[j+1] - y[j])
  if dx+dy>dt or dt%2!=(dx+dy)%2:
    print('No')
    exit()
    
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t_ = 0
xy_ = [0,0]
for _ in range(n):
    t, *xy = map(int, input().split())
    ta = t - t_
    xya = [abs(xy[0]-xy_[0]), abs(xy[1]-xy_[1])]
    if sum(xya) > ta or (ta - sum(xya))%2 != 0:
        print("No")
        break
    t_ = t
    xy_ = xy
else:
    print("Yes")

Submission status: Accepted

Solution code:
ans = "Yes"
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
  tmp = input().split(" ")
  t.append(int(tmp[0]))
  x.append(int(tmp[1]))
  y.append(int(tmp[2]))

for j in range(N):
  dt = t[j+1] - t[j]
  dx = abs(x[j+1] - x[j])
  dy = abs(y[j+1] - y[j])
  if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
    continue
  else:
    ans = "No"
    break

print(ans)

Submission status: Accepted

Solution code:
n=int(input());t,x,y=[],[],[]
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):
  m,k=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (m>=k and m%2==k%2): print('No');break
else:
  print('Yes')

Submission status: Accepted

Solution code:
n=int(input());t,x,y=[],[],[]
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):
  r1,r2=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (r1>=r2 and r1%2==r2%2): print('No');break
else:
  print('Yes')

Submission status: Accepted

Solution code:
n=int(input());t,x,y,r1,r2=[],[],[],0,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):
  r1,r2=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (r1>=r2 and r1%2==r2%2): print('No');break
else:
  print('Yes')

Submission status: Accepted

Solution code:
n=int(input());t,x,y=[],[],[]
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):
  if i==0:
    r1,r2=t[i],x[i]+y[i]
  else:
    r1,r2=t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if not (r1>=r2 and r1%2==r2%2):
    print('No');break
else:
  print('Yes')

Submission status: Accepted

Solution code:
t,x,y=[],[],[];n=int(input())
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):
  if i==0:
    r1=t[i]
    r2=x[i]+y[i]
  else:
    r1=t[i]-t[i-1]
    r2=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if not (r1>=r2 and r1%2==r2%2):
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

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

ans = True

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

    else:
        t = TXY[i][0] - TXY[i - 1][0]
        x = abs(TXY[i][1] - TXY[i - 1][1])
        y = abs(TXY[i][2] - TXY[i - 1][2])

    xy = x + y
    if t == xy or (t > xy and (t - xy) % 2 == 0):
        pass
    else:
        ans = False
        break

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

Submission status: Accepted

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

def helper():
  curt = 0
  curx = 0
  cury = 0
  for i in range(N):
    dt = t[i] - curt
    curt = t[i]

    dx = abs(x[i] - curx)
    curx = x[i]

    dy = abs(y[i] - cury)
    cury = y[i]

    if dt < (dx+dy) or dt%2 != (dx+dy)%2:
      return False
  return True

a = helper()  
print('Yes') if a else print('No')

Submission status: Accepted

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

def helper():
  for i in range(N):
    dt = t[i+1] -t[i] 
    dx = abs(x[i+1] - x[i])
    dy = abs(y[i+1] - y[i])

    if dt < (dx+dy) or dt%2 != (dx+dy)%2:

      return False
  return True

a = helper()  
print('Yes') if a else print('No')

Submission status: Accepted

Solution code:
N=int(input())
P=[(0,0,0)]*(N+1)

D=[0]*(N+1)

P[0]=(0,0,0)
D[0]=1
for i in range(1,N+1):
    t,x,y=map(int,input().split())
    dt=t-P[i-1][0]
    dx=abs(x-P[i-1][1])
    dy=abs(y-P[i-1][2])
    if dt < (dx+dy): #時間<移動距離
        print('No')
        break
    if ((dx+dy)==0 and dt%2!=0): #移動しない場合には時間はmod2==0
        print('No')
        break
    #if (dt-(dx+dy))%2==0 or dt%(dx+dy)==0:
    if (dt-(dx+dy))%2!=0:
        print('No')
        break
    
    P[i]=(t,x,y)
else:
    print('Yes')

Submission status: Accepted

Solution code:
def end():
    print('No')
    exit()

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

temp = abs(x[0]) + abs(y[0])
if t[0] % 2 == temp % 2:
    if t[0] < temp:
        end()
else:
    end()

for i in range(1, n):
    temp = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    if (t[i]-t[i-1]) % 2 == temp % 2:
        if t[i]-t[i-1] < temp:
            end()
    else:
        end()

print('Yes')

Submission status: Accepted

Solution code:
import sys
readline=sys.stdin.readline
read=sys.stdin.read
n,*abc=map(int,read().split())

abc=[(t,x,y) for t,x,y in zip(*[iter(abc)]*3)]
abc=[(0,0,0)]+abc
diff=[abs(nxt[2]-cur[2])+abs(nxt[1]-cur[1])-nxt[0]+cur[0] for cur,nxt in zip(abc,abc[1:])]
for d in diff:
  if d>0 or d%2==1:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
#  ABC 086 C - Traveling
N = int(input())

t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)

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

boolian = True    
        
for i in range(N):
    delta_t = t[i+1] - t[i]
    delta_x = x[i+1] - x[i]
    delta_y = y[i+1] - y[i]
    
    delta_x = abs(delta_x)
    delta_y = abs(delta_y)
    
    delta_sum = delta_x + delta_y
    
    k = delta_sum % 2 
    j = delta_t % 2

    if -delta_t <= delta_sum and delta_sum <= delta_t:
        if k == 0 and j == 0:
            boolian = True
            continue
        if k == 1 and j == 1:
            boolian = True
            continue
        else:
            boolian = False
            print('No')
            break
    else:
        boolian = False
        print('No')
        break

if boolian == True:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t_before = 0
x_before = 0
y_before = 0

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

def judge(t_plus, x_diff, y_diff):
    distance = abs(x_diff) + abs(y_diff)
    if (t_plus % 2) != (distance % 2):
        return False
    if distance > t_plus:
        return False 
    return True

is_found = False

for i in range(N):
    t, x, y = travel_list[i]
    result = judge(t_plus=t-t_before, x_diff=x-x_before, y_diff=y-y_before)
    if result:
        t_before = t
        x_before = x
        y_before = y
    else:
        break
else:
    is_found = True
if is_found:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
dx,dy,dt=0,0,0
count=0
for i in range(N):
    t,x,y=map(int,input().split())
    if (x+y+t)%2 == 0 and abs(x-dx) + abs(y-dy) <= abs(t-dt):
        count+=1
    dx,dy,dt=x,y,t

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

Submission status: Accepted

Solution code:
n=int(input())
plan=[[int(s) for s in input().split()] for j in range(n)]
now =[0 for j in range(3)]
plan.insert(0,now)
ans=0
for i in range(n):
    dt=abs(plan[i+1][0]-plan[i][0])
    dx=abs(plan[i+1][1]-plan[i][1])
    dy=abs(plan[i+1][2]-plan[i][2])
    if dt>=dx+dy:
        if dt%2 == (dx+dy)%2:
            ans+=1
print("Yes" if ans==n else "No")

Submission status: Accepted

Solution code:
n = int(input())

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

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

for i in range(n):
    if i>0:
        t = list[i][0] - list[i-1][0]
        d = abs(list[i][1] - list[i-1][1] + list[i][2] - list[i-1][2])
    else:
        t = list[i][0]
        d = abs(list[i][1] + list[i][2])
    if (t-d) >= 0 and (d-t)%2 == 0:
        continue
    else:
        flag = 1
        print('No')
        break
if flag ==0:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
sy,sx=[0,0]
t1=0
ch=0

for _ in range(n):
  t,x,y=map(int,input().split())
  if (abs(sy-y)+abs(sx-x)-abs(t-t1))%2!=0 or abs(sy-y)+abs(sx-x)>abs(t-t1):
    ch+=1
  t1=t
  sy,sx=[y,x]
  
if  ch==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
t, x, y = 0, 0, 0
for _ in range(int(input())):
    t1, x1, y1 = map(int, input().split())
    a = abs(x1 - x) + abs(y1 - y)
    b = t1 - t
    if a <= b and a % 2 == b % 2:
        t, x, y = t1, x1, y1
    else:
        print("No")
        break
else:
    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())
    if tt-t>=abs(xx-x)+abs(yy-y) and ((tt-t)-(abs(xx-x)+abs(yy-y)))%2==0:
        t = tt
        x = xx
        y = yy
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

for i in range(n):
    T,X,Y = map(int,input().split())
    dt,dx,dy = T-t,abs(X-x),abs(Y-y)
    if dt - (dx + dy) < 0 or (dt - (dx + dy))%2 == 1:
        print("No")
        exit()
    t,x,y = T,X,Y

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
 
pre_t, pre_x, pre_y = 0, 0, 0
for t, x, y in TXY:
  diff_t = t - pre_t
  diff_pos = abs(x-pre_x) + abs(y-pre_y)
  if diff_t < diff_pos or (diff_t-diff_pos) % 2 == 1:
    print('No')
    exit()
  else:
    pre_t, pre_x, pre_y = t, x, y
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(n):
  t[i+1],x[i+1],y[i+1]=map(int,input().split())
  
  lim_t=t[i+1]-t[i]
  lim_x=x[i+1]-x[i]
  lim_y=y[i+1]-y[i]
  
  if abs(lim_x)+abs(lim_y)>lim_t or (lim_t-lim_x-lim_y)%2==1:
    print('No')
    exit()
    
print('Yes')

Submission status: Accepted

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

for _ in range(N):
    t, x, y = input().split()
    p = [int(t), int(x), int(y)]
    P.append(p)

t_before = 0
x_before = 0
y_before = 0
f_enable = True
for p in P:
    t, x, y = p

    t_distance = abs(t_before - t)
    p_distance = abs(x_before - x) + abs(y_before - y)

    distance = t_distance - p_distance

    if distance < 0:
        f_enable = False
        break
    elif distance % 2 != 0:
        f_enable = False
        break

    t_before = t
    x_before = x
    y_before = y

if f_enable:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
now_x, now_y = 0, 0
time = 0
for i in range(N):
  t, x, y = map(int, input().split())
  board = abs(x - now_x) + abs(y - now_y)
  if board > t - time:
    print("No")
    quit()
  elif ((t - time) - board) % 2 == 1:
    print("No")
    quit()
  else:
    now_x, now_y, time = x, y, t
    
print("Yes")

Submission status: Accepted

Solution code:
def dist(s1,s2):
  return abs(s1[1]-s2[1]) + abs(s1[2]-s2[2])

N=int(input())
now = (0,0,0)
for i in range(N):
  next_ = list(map(int,input().split()))
  if dist(now,next_)<=next_[0]-now[0] and dist(now,next_) % 2 == (next_[0]-now[0])%2:
    now = next_
    continue
  else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 086
# C - Traveling

N=int(input())

T=0
X,Y=0,0

for i in range (N):
    t, x, y =map(int,input().split())
    time =t-T
    distance=abs((x+y)-(X+Y))
    if time >= distance and time%2==distance%2:
        T=t
        X,Y=x,y
    else :
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
class Coodinate (object):
    """Coodinate object
    This class contains infomation about the coodinates.
    Each instance can have up to 3-dimensional(x,y,z) space coodinates.
    
    params
    ------------------------------
    x : int or floot ,default 0
    y : int or floot ,default 0
    z : int or floot ,default 0


    This class have following methods.
    ------------------------------
    distance : Calculate the straight-line distance between 2 points in Euclidean space.
    midpoint : Calculate the midpoint(halfway) between 2 points.
    manhattan_distance : Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.
    """

    def __init__(self,x=0,y=0,z=0):
        self.x=x
        self.y=y
        self.z=z


    def __str__(self):
        if self.z==0:
            if self.y==0:
                return "( {} )".format(self.x)
            else :
                return "( {} , {} )".format(self.x,self.y)
        else:
            return "( {} , {} , {} )".format(self.x,self.y,self.z)    


    def distance(self,other):
        """Calculate the straight-line distance between 2 points in Euclidean space.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        distance : floot

        """
        x_diff_sq=(self.x-other.x)**2
        y_diff_sq=(self.y-other.y)**2
        z_diff_sq=(self.z-other.z)**2
        return (x_diff_sq + y_diff_sq +z_diff_sq)**0.5
    

    def midpoint(self,other):
        """Calculate the midpoint(halfway) between 2 points.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        midpoint : tupul
        
        """
        x_midpoint=(self.x+other.x)/2
        y_midpoint=(self.y+other.y)/2
        z_midpoint=(self.z+other.z)/2
        if self.z == other.z ==0 :
            if self.y == other.y==0:
                return(x_midpoint)
            else:
                return(x_midpoint,y_midpoint) 
        return(x_midpoint,y_midpoint,z_midpoint)

    def manhattan_distance(self,other):
        """Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        manhattan_distance : floot

        """

        x_diff_abs=abs(self.x - other.x)
        y_diff_abs=abs(self.y - other.y)
        z_diff_abs=abs(self.z - other.z)
        return(x_diff_abs + y_diff_abs + z_diff_abs)

# AtCoder Beginner Contest 086
# C - Traveling

N=int(input())

T=0
now=Coodinate()

for i in range (N):
    t, x, y =map(int,input().split())
    time =t-T
    location = Coodinate(x,y)
    destination = Coodinate.manhattan_distance(location,now)
    if time >= destination and time%2==destination%2:
        T=t
        now=location
    else :
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
N=int(input())
 
t0=0
x0=0
y0=0
 
for i in range(N):
    t,x,y=map(int,input().split())
    l=(t-t0)-abs(x+y-x0-y0)
    t0=t
    x0=x
    y0=y
    if l%2==0 and l>=0:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    P = [0] * (N + 1)
    P[0] = (0, 0, 0)
    for i in range(1, N + 1):
        P[i] = tuple(map(int, readline().split()))

    ok = True
    for i in range(N):
        dt = P[i + 1][0] - P[i][0]
        dx = P[i + 1][1] - P[i][1]
        dy = P[i + 1][2] - P[i][2]
        if dt < abs(dx) + abs(dy) or (dt - abs(dx) - abs(dy)) % 2 == 1:
            ok = False
            break

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
px, py, pt = 0, 0, 0
ok = True
for i in range(N):
    t, x, y = map(int, input().split())
    diff = abs((x + y) - (px + py)) 
    if diff > t - pt:
        ok = False
    if diff % 2 != (t - pt) % 2:
        ok = False
    px = x
    py = y
    pt = t

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

Submission status: Accepted

Solution code:
N = int(input())
ex_t, ex_x, ex_y = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-ex_x) + abs(y-ex_y) <= abs(t-ex_t) and t%2 == (x+y)%2:
        count += 1
    ex_t, ex_x, ex_y = t, x, y
print('Yes' if count == N else 'No')

Submission status: Accepted

Solution code:
N = int(input())
ex_t, ex_x, ex_y = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-ex_x) + abs(y-ex_y) <= abs(t-ex_t) and t%2 == (x+y)%2:
        count += 1
    ex_t, ex_x, ex_y = t, x, y
print("Yes" if count == N else "No")

Submission status: Accepted

Solution code:
N=int(input())
t,x,y=0,0,0
ans="Yes"
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:
    ans="No"
    break
  t=T
  x=X
  y=Y
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

status = True
t = x = y = 0

for i in range(n):
    ti, xi, yi = list(map(int, input().split()))
    dist = abs(xi-x)+abs(yi-y)
    time = ti-t
    if (dist > time):
        status = False
    elif (time - dist) % 2 == 1:
        status = False

    t, x, y = [ti, xi, yi]

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

Submission status: Accepted

Solution code:
# coding: utf-8
import math
n = int(input())
t = 0
x = 0
y = 0
# txy = []
# for i in range(n):
#     ti, xi, yi = list(map(int, input().split()))
#     txy.append((ti, xi, yi))
for i in range(n):
    ti, xi, yi = map(int, input().split())
    if abs(xi - x) + abs(yi - y) > abs(ti - t):
        print("No")
        exit()
    elif (abs(xi - x) + abs(yi - y) - abs(ti - t)) % 2 != 0:
        print("No")
        exit()
    else:
        t = ti
        x = xi
        y = yi
print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
import math
n = int(input())
t = 0
x = 0
y = 0
txy = []
for i in range(n):
    ti, xi, yi = list(map(int, input().split()))
    txy.append((ti, xi, yi))

for ti, xi, yi in txy:
    if abs(xi - x) + abs(yi - y) > abs(ti - t):
        print("No")
        exit()
    elif (abs(xi - x) + abs(yi - y) - abs(ti - t)) % 2 != 0:
        print("No")
        exit()
    else:
        t = ti
        x = xi
        y = yi
print("Yes")

Submission status: Accepted

Solution code:
result = 'Yes'

# 回数の取得
N = int(input())
data = [[0, 0, 0]]
# 目的地の取得
for i in range(N):
	data.append(list(map(int, input().split())))

# 目的地間の最短距離での必要移動回数が(実移動回数 + 2x)であれば、移動可能
for move_index in range(N):
  start = data[move_index]
  end   = data[move_index + 1]
  
  # 移動回数
  move_count = end[0] - start[0]
  # 最短移動回数
  min_move = abs(end[1] - start[1]) + abs(end[2] - start[2])
  # 移動可能かを判断
  if min_move > move_count:     # 最短経路で進んでも到達できない場合
    result = 'No'
    break
  elif min_move == move_count:	# 最短経路で進めば到達できる場合
    pass
  else:							# 寄り道をする場合
    exceed_count = move_count - min_move
    if exceed_count % 2 == 0:
      pass
    else:
      result = 'No'
      break
      
# 結果の表示
print(result)

Submission status: Accepted

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

flag=0
flag2=0
for i in range(N):
    flag=0
    time=t[i+1][0]-t[i][0]
    x=t[i+1][1]-t[i][1]
    y=t[i+1][2]-t[i][2]
    time=abs(time)
    x=abs(x)
    y=abs(y)
    
    if (time-(x+y))%2==0 and time>=(x+y):
        flag=1
    if flag!=1:
        flag2=1    

if flag2==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# ABC_086_C_Traveling
N = int(input())
txy = [map(int, input().split()) for _ in range(N)]
t, x, y = [list(i) for i in zip(*txy)]
t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)
can = True
distX = [0]*(N)
distY = [0]*(N)
dist = [0]*(N)
time = [0]*(N)

# distance
for i in range(N):
	distX[i] = abs(x[i]-x[i+1])
	distY[i] = abs(y[i]-y[i+1])
	dist[i] = distX[i]+distY[i]
	time[i] = t[i+1]-t[i]
	if dist[i] > time[i]:
		can = False
		break

# parity
for i in range(N):
	if (dist[i]-time[i]) % 2 == 1:
		can = False
		break

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

Submission status: Accepted

Solution code:
n=int(input())
old=[0,0,0]
for i in range(n):
  t,x,y=map(int,input().split())
  tt=t-old[0]
  xx=x-old[1]
  yy=y-old[2]
  dist=abs(xx)+abs(yy)
  if tt%2 != (xx+yy)%2 or dist>tt:
    print("No")
    exit()
  old=[t,x,y]
  
print("Yes")

Submission status: Accepted

Solution code:
prev,pt = (0,0),0
b = True
def f(a,b): return abs(b[0]- a[0]) + abs(b[1] - a[1])
for _ in range(int(raw_input())):
	t,x,y  = map(int, raw_input().split())
	if (t - pt) < f((x,y), prev) :
		b = False
		break 

	if ((t - pt) - f((x,y), prev)) % 2:
		b = False
		break
	prev,pt = (x,y),t

print 'Yes' if b else 'No'

Submission status: Accepted

Solution code:
N = int(input().strip())
gridi = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    gridi.append(array)
f="Yes"
grid=[]
for i in range(N+1):
    grid.append([0,0,0])
for i in range(1,N+1):
    grid[i][0]=gridi[i-1][0]
    grid[i][1]=gridi[i-1][1]
    grid[i][2]=gridi[i-1][2]
for i in range(N):
    dt=int(grid[i+1][0])-int(grid[i][0])
    dist=abs(grid[i+1][1]-grid[i][1])+abs(grid[i+1][2]-grid[i][2])
    if dist>dt:
        f="No"
    elif dist%2!=dt%2:
        f="No"
print(f)

Submission status: Accepted

Solution code:
N = int(input())
PX = PY = PT = 0

for _ in range(N):
  T,X,Y = map(int,input().split())
  if abs(X-PX)+abs(Y-PY)>T-PT or (X+Y-PX-PY)%2 != (T-PT)%2:
    print("No")
    exit()
  else:
    PX = X
    PY = Y
    PT = T
    
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:
n = int(input())

st_t = 0
st_x = 0
st_y = 0
li_in = list()
for i in range(n):
    li_in.append(list(map(int, input().split())))


for t, x, y in li_in:
    time = t - st_t
    diff_x = abs(x - st_x)
    diff_y = abs(y - st_y)

    if diff_x + diff_y > time:
        print('No')
        exit(0)
    elif diff_x + diff_y == time:
        st_t = t
        st_x = x
        st_y = y
        continue
    # elif diff_x + diff_y < t:
    else:
        if (time - (diff_x + diff_y)) % 2 == 0:
            st_t = t
            st_x = x
            st_y = y
            continue
        else:
            print('No')
            exit(0)
else:
    print('Yes')