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 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    def d(C0,C1):
        return abs(C0[0]-C1[0])+abs(C0[1]-C1[1])
    N=int(input())
    t=[0]*(N+1)
    C=[[0,0] for _ in range(N+1)]
    for i in range(1,N+1):
        t[i],C[i][0],C[i][1]=map(int,input().split())
    for i in range(N):
        a=d(C[i],C[i+1])
        if a<=t[i+1]-t[i] and a%2==(t[i+1]-t[i])%2:
            continue
        else:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

s=0
for i in range(1,N+1):
  x=abs(L[i][1]-L[i-1][1])
  y=abs(L[i][2]-L[i-1][2])
  t=L[i][0]-L[i-1][0]
  if x+y>t or (t-x-y)%2==1:
    s=1
    break

print("Yes" if s==0 else "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]=(int(z) for z in input().split())

for i in range(N): #i番目の目的に到達まで
    if i ==0:
        t0,x0,y0=0,0,0
        t1,x1,y1=t[0],x[0],y[0]
    else:
        t0,x0,y0=t[i-1],x[i-1],y[i-1]
        t1,x1,y1=t[i],x[i],y[i]
    dt=t1-t0
    dx=x1-x0
    dy=y1-y0
    if (dx+dy)%2==0 and (dt%2)==0 and (dx+dy)<=dt:
        # print("dx,dy,dt=",dx,dy,dt)
        continue
    elif (dx+dy)%2==1 and (dt%2)==1 and (dx+dy)<=dt:
        # print("dx,dy,dt=",dx,dy,dt)
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

t,x,y =[[],[],[]]

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

output = 'Yes'

p_t, p_x, p_y = [0,0,0]

for i in range(N) :
	time = t[i] - p_t
	dis_x = x[i] - p_x
	dis_y = y[i] - p_y
	time -= ( abs(dis_x) + abs(dis_y) )
	if ( time < 0 ) or ( time % 2 != 0 ) :
		output = 'No'
		break
	p_t = t[i]
	p_x = x[i]
	p_y = y[i]

print(output)

Submission status: Accepted

Solution code:
N=int(input())

txylist=[]
old_t,old_x,old_y=0,0,0
for i in range(N):
  t,x,y=map(int,input().split())
  txylist.append((t-old_t,abs(x-old_x),abs(y-old_y)))
  old_t,old_x,old_y=t,x,y
#print(txylist)

for t,x,y in txylist:
  if t%2!=(x+y)%2:
    print("No")
    break
  elif t<x+y:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
Inf = [[0,0,0]]

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

for i in range(N):
    dist = abs(Inf[i][1]-Inf[i+1][1]) + abs(Inf[i][2]-Inf[i+1][2])
    dt = Inf[i+1][0] - Inf[i][0]
    if dt < dist:
        print("No")
        break
    else:
        if (dt % 2) == (dist % 2):
            continue
        else:
            print("No")
            break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = [list(map(int, input().split())) for i in range(N)] #[t,x,y]
t.insert(0, [0,0,0]) #リストに場所指定して要素追加：（リスト名）.insert(インデックス番号, 要素)
flag = True
for i in range(N):
    dt = t[i+1][0] - t[i][0]
    dist = abs(t[i+1][1]-t[i][1]) + abs(t[i+1][2]-t[i][2])
    if dt < dist:
        flag = False
    if dt%2!=dist%2:
        flag = False
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
n = int(input())
a,b,c = 0,0,0
for i in range(n):
  d,e,f = map(int,input().split())
  time = d-a
  kyori = (e-b)+(f-c)
  if time>=kyori and (time-kyori)%2==0:
     a,b,c = d,e,f
  else:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc086/tasks/arc089_a
n = int(input())

pre_x, pre_y = 0, 0
pre = 0
trip = []
for _ in range(n):
    t, x, y = map(int, input().split())
    trip.append((t, x, y))
for t, x, y in trip:
    d = abs(x - pre_x) + abs(y - pre_y)
    if d <= (t - pre) and d % 2 == (t - pre) % 2:
        pre, pre_x, pre_y = t, x, y
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

now_t = now_x = now_y = 0

can = True
for i in range(N):
    t, x, y = map(int, input().split())
    time = t - now_t
    dist = abs(now_x - x) + abs(now_y - y)
    if dist > time:
        can = False
    if not dist % 2 == time % 2:
        can = False
    now_t = t
    now_x = x
    now_y = y

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

Submission status: Accepted

Solution code:
# solution

import io

array = [1]

def tommy(numbers):
  t, x, y = map(int, numbers.split())
  time_x = t - x
  time_y = time_x - y
  if time_y%2 == 0 and time_y >=0:
    array.append(1)
  else:
    array.append(-1)

data = int(input())

counter = 0

while counter < data:
  tommy(input())
  counter += 1

if array.count(1) == data+1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from sys import stdin
import sys

data = []

N = int(stdin.readline().rstrip())
for i in range(0, N):
    data.append(stdin.readline().rstrip().split())

cur_t = 0
cur_x = 0
cur_y = 0

for i in range(0, len(data)):
    (next_t, next_x, next_y) = data[i]
    next_t = int(next_t)
    next_x = int(next_x)
    next_y = int(next_y)

    sub_t = next_t - cur_t
    sub_x = abs(next_x - cur_x)
    sub_y = abs(next_y - cur_y)

    if sub_t < sub_x + sub_y:
        print('No')
        sys.exit()

    if sub_t % 2 != (sub_x + sub_y)%2:
        print('No')
        sys.exit()

    cur_t = next_t
    cur_x = next_x
    cur_y = next_y

print('Yes')

Submission status: Accepted

Solution code:
from sys import stdin
import sys

data = []

N = int(stdin.readline().rstrip())
for i in range(0, N):
    data.append(stdin.readline().rstrip().split())

cur_t = 0
cur_x = 0
cur_y = 0

for i in range(0, len(data)):
    (next_t, next_x, next_y) = data[i]
    next_t = int(next_t)
    next_x = int(next_x)
    next_y = int(next_y)

    sub_t = next_t - cur_t
    sub_x = abs(next_x - cur_x)
    sub_y = abs(next_y - cur_y)
    #print(sub_t)
    #print(sub_x)
    #print(sub_y)
    

    ## do something
    # sub_t > sub_x + sub_y
    if sub_t < sub_x + sub_y:
        print('No')
        sys.exit()

    if sub_t % 2 != (sub_x + sub_y)%2:
        print('No')
        sys.exit()



    cur_t = next_t
    cur_x = next_x
    cur_y = next_y

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t = 0
x = 0
y = 0
flag = True
for i in range(n):
    ti, xi, yi = map(int, input().split())
    if ti % 2 != (xi + yi) % 2:
        flag = False
    elif abs(xi - x) + abs(yi - y) > ti - t:
        flag = False
    t, x, y = ti, xi, yi
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
schedule=[list(map(int,input().split()))for i in range(N)]
move_time =0
dist=0
res=0
move_time = schedule[0][0]
dist= schedule[0][1]+schedule[0][2]
if move_time<dist:
	res=1
for time in range(N-1):
	move_time=schedule[time+1][0]-schedule[time][0]
	dist = abs((schedule[time+1][1]-schedule[time][1]))+abs((schedule[time+1][2]-schedule[time][2]))
	if dist>move_time:
		res=1
		break
	if schedule[time][0]%2==0 and (schedule[time][1]+schedule[time][2])%2!=0:
		res=1
	elif schedule[time][0]%2==1 and (schedule[time][1]+schedule[time][2])%2!=1:
		res=1
if res ==1:
	print('No')
else:
	print('Yes')

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    mat = [list(map(int, readline().split())) for _ in range(n)]
    ct, cx, cy = 0, 0, 0

    for nt, nx, ny in mat:
        dist = abs(nx - cx) + abs(ny - cy)
        interval = nt - ct

        if dist > (nt - ct) or (dist - interval) % 2 == 1:
            print('No')
            sys.exit()
        ct, cx, cy = nt, nx, ny

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
p_t, p_x, p_y = 0, 0, 0

available = True

for i in range(n) :
	t, x, y = map(int, input().split())
	judge = (t - p_t) - ( abs(x - p_x) + abs(y - p_y) )
	if judge < 0 or judge % 2 != 0 :
		available = False
		break
	p_t, p_x, p_y = t, x, y

if available :
	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(0,N):
    t[i],x[i],y[i] =map(int,input().split())
check=0
d=0
if abs(x[0])+abs(y[0])>t[0] or (abs(x[0])+abs(y[0]))%2!=(t[0])%2:
    check=1
if check==1:
    print('No')
    d=1
for i in range(1,N):
    if d==1:
        break
    check=0
    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:
        check=1
    if check==1:
        print('No')
        d=1
        break
if d!=1:
    print('Yes')

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  A = [[int(_) for _ in input().split()] for __ in range(N)]
  t0 = x0 = y0 = 0
  for a in A:
    t, x, y = a
    if (t - t0 < abs(x - x0) + abs(y - y0)) or (t%2 == 0 and (x + y)%2 == 1) or (t%2 == 1 and (x + y)%2 == 0):
      print('No')
      break
    t0, x0, y0 = t, x, y
  else:
    print('Yes')
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

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

    for i in range(n):
        if i == 0:
            b_t = 0
            b_x = 0
            b_y = 0
        dist = abs(X[i] - b_x) + abs(Y[i] - b_y)
        time = T[i] - b_t

        if time < dist:
            print('No')
            return
        m = time % dist
        if m % 2 != 0:
            print('No')
            return
        b_t = T[i]
        b_x = X[i]
        b_y = Y[i]
    print('Yes')
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N=int(input())
C=[0,0,0]
for i in range(N):
  B=C
  C=list(map(int,input().split()))
  x=abs(B[1]-C[1])
  y=abs(B[2]-C[2])
  t=abs(B[0]-C[0])
  if x+y>t or (t-x-y) % 2 != 0:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
txy = [list(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
j = 0
for i in range(N):
    a = abs(txy[i][1]-x) + abs(txy[i][2]-y)
    b = txy[i][0]-t
    x = txy[i][1]
    y = txy[i][2]
    t = txy[i][0]
    if b >= a and (b-a) % 2 == 0:
        continue
    else:
        j = 1
        break
if j == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

def main():
    N = int(input())
    t, x, y = 0, 0, 0

    for _ in range(N):
        next_t, next_x, next_y = [int(__) for __ in input().split()]

        delta_t = next_t - t
        distance = abs(next_x - x) + abs(next_y - y)

        if distance > delta_t:
            print("No")
            sys.exit()

        if (delta_t - distance) % 2 != 0:
            print("No")
            sys.exit()

        t, x, y = next_t, next_x, next_y

    print("Yes")

main()

Submission status: Accepted

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

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
ti,xi,yi = [0],[0],[0]
ans = 'No'

for ni in range(n):
 t,x,y = [int(x) for x in input().split()]
 ti.append(t)
 xi.append(x)
 yi.append(y)

for i in range(n):
  dt = ti[i+1] - ti[i]
  dx = xi[i+1] - xi[i]
  dy = yi[i+1] - yi[i]

  if dt < abs(dx)+abs(dy):
    break

  odev1 = (xi[i]+yi[i])%2
  odev2 = (xi[i+1]+yi[i+1])%2

  if dt%2 == 0:
    if odev1 != odev2:
      break
  else:
    if odev1 == odev2:
      break
  if i == n-1:
    ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
pre_t, pre_x, pre_y = 0, 0, 0
for _ in range(N):
    tmp_t, tmp_x, tmp_y = map(int,input().split())
    t, x, y = tmp_t - pre_t, tmp_x - pre_x, tmp_y - pre_y
    pre_t, pre_x, pre_y = tmp_t, tmp_x, tmp_y
    if x >= 0:
        if y >= 0 and not (x + y <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
        elif y < 0 and not (x - y <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
    else:
        if y >= 0 and not (y - x <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
        elif y < 0 and not (- x - y <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
print('Yes')

Submission status: Accepted

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

flag = True
px, py = 0, 0
for i in range(n):
    t, x, y = txy[i]
    d = abs(x-px) + abs(y-py)
    if d <= t:
        if d % 2 != t % 2:
            flag = False
    else:
        flag = False

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    if abs(a[i][1] - x) + abs(a[i][2] - y) > abs(a[i][0] - t) or (a[i][1] - x + a[i][2] - y) % 2 != (a[i][0] - t) % 2:
        print('No')
        sys.exit()
    else:
        x = a[i][1]
        y = a[i][2]
        t = a[i][0]
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())

ans = "Yes"
for i in range(N):
  dd = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  dt = t[i+1] - t[i]
  if dt < dd:
    ans = "No"
  elif (dd - dt) % 2 != 0:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
travels = [[0, 0, 0]]
travels += [list(map(int, input().split())) for _ in range(N)]
flag = True
for i in range(N):
    cnt = 0
    cnt += abs(travels[i+1][1] - travels[i][1])
    cnt += abs(travels[i+1][2] - travels[i][2])
    time = travels[i+1][0] - travels[i][0]
    if time < cnt or (time-cnt) % 2 == 1:
        flag = False
        break
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (abs(prev_dst[1]-x) + abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

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


def judge(b_point, a_point):
    b_point = list(map(int, b_point.split()))
    a_point = list(map(int, a_point.split()))

    t = a_point[0] - b_point[0]
    x_b = b_point[1]
    x_a = a_point[1]
    y_b = b_point[2]
    y_a = a_point[2]

    distance = abs(x_a - x_b) + abs(y_a - y_b)
    if distance > t:
        return 0
    elif (t -distance) % 2 == 0:
        return 1
    else:
        return 0


def main():
    N = int(input())
    points = ["0 0 0"]
    points.extend([input() for i in range(N)])
    for i, point in enumerate(points):
        if i+1 == len(points):
            break
        else:
            if judge(points[i],points[i+1]):
                continue
            else:
                print("No")
                return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

def check_distance(move_distance, move_time):
  buf_result = False

  if move_time >= move_distance:
    buf_val = move_time - move_distance

    if buf_val % 2 == 0:
      buf_result = True

  return buf_result

current_posi = [0, 0]
next_posi = []

current_time = 0
next_time = 0

result = False

for i in range(n):
  input_i = list(map(int, input().split()))
  next_time = input_i[0]
  next_posi = [input_i[1], input_i[2]]

  move_distance = abs(current_posi[0] - next_posi[0]) + abs(current_posi[1] - next_posi[1])

  move_time = next_time - current_time

  result = check_distance(move_distance, move_time)

  if result == False:
    break
  else:
    current_time = input_i[0]
    current_posi = [input_i[1], input_i[2]]


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

Submission status: Accepted

Solution code:
def is_ok(a, b):
    d = abs(b[1]- a[1]) + abs(b[2] - a[2]) - (b[0] - a[0])
    if d <= 0 and d % 2 == 0:
        return True
    else:
        return False

N = int(input())
L = [[] for i in range(N + 1)]

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

ans = 'Yes'
for i in range(N):
    if not is_ok(L[i], L[i + 1]):
        ans = 'No'
        # print(i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
T,X,Y=0,0,0

a='Yes'
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(x-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        a='No'
        break
    T,X,Y=t,x,y
print('{}'.format(a))

Submission status: Accepted

Solution code:
n=int(input())
T,X,Y=0,0,0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
last_t,last_x,last_y=0,0,0
for _ in range(N):
    t,x,y = map(int,input().split())
    move = abs(x-last_x)+abs(y-last_y)
    time = t - last_t
    if (time >= move) and (time - move) % 2 == 0:
        last_t,last_x,last_y=t,x,y
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input().strip())
t = 0
x = 0
y = 0
ans = "Yes"
for _ in range(n):
  tn,xn,yn = map(int,input().split())
  if tn%2 != (xn+yn)%2 or abs(xn-x)+abs(yn-y) > (tn - t):
    ans = "No"
    break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    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())
    if (t - T) < abs(x-X) + abs(y-Y) or ((t - T) + abs(x-X) + abs(y-Y))%2 == 1:
        print("No")
        break
    T = t
    X = x
    Y = y
else:
    print("Yes")

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())
    if ((t - T) + abs(x-X) + abs(y-Y))%2 == 1 or (t - T) < abs(x-X) + abs(y-Y):
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
d = dict()
d[0] = [0,0,0]
can = True
for i in range(n):
    l = list(map(int, input().split()))
    d[i+1] = l
# print(d[2])
for j in range(n):
    # print(d[j][2])
    t = d[j+1][0]-d[j][0]
    x = d[j+1][1]-d[j][1]
    y = d[j+1][2]-d[j][2]
    # print(t,x,y)
    c = t - (abs(x) + abs(y))
    # print(c)
    if c < 0 or c%2 == 1:
        can = False
        break
        
if can:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

xnow, ynow = 0, 0
tnow = 0
ans = "Yes"
for m in M:
    t, x, y = m
    min_len = abs(x - xnow) + abs(y - ynow)
    time_len = t - tnow
    if time_len >= min_len:
        if (time_len - min_len) % 2 == 0:
            xnow, ynow = x, y
            tnow = t
            continue
        else:
            ans = "No"
            break
    else:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

P = [[0, 0, 0]]

ans = 'Yes'

for i in range(N):
    l = list(map(int, input().split()))
    P.append(l)

for i in range(N):
    c = P[i+1][0] - P[i][0]
    d = abs(P[i+1][1] - P[i][1]) + abs(P[i+1][2] - P[i][2])

    if c % d != 0:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np

def main():
    N = int(input())
    for i in range(N):
        t, x, y = map(int,input().split())
        if x + y > t or (x + y - t) % 2:
            print("No")
            exit()

    print("Yes")
    

        


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N = I()
prev_t = 0
prev_x = 0
prev_y = 0
flag = True
for i in range(N):
    t,x,y = map(int,input().split())
    t = t-prev_t
    if abs(x-prev_x)+abs(y-prev_y) > t:
        flag = False
        break
    elif (abs(x-prev_x)+abs(y-prev_y)) %2 != t%2:
        flag = False
        break
    prev_t = t+prev_t
    prev_x = x
    prev_y = y
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
N = int(input())
l = [[] for _ in range(N)]
for i in range(N):
    l[i] = list(map(int,(input().split())))
l.append([0,0,0])
for i in range(N):
    dt = l[i][0] - l[i-1][0] 
    dx = abs(l[i][1] - l[i-1][1])
    dy = abs(l[i][2] - l[i-1][2])
    d = dx + dy
    if d > dt:
        print("No")
        break
    else:
        if (d-dt)%2 == 1:
            print("No")
            break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,len(s)):
    dt=int(s[i][0])-int(s[i-1][0])
    dx=int(s[i][1])-int(s[i-1][1])
    dy=int(s[i][2])-int(s[i-1][2])

    if dt<abs(dx)+abs(dy):
        print("No")
        exit()

    if (dx+dy)%2!=dt%2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
txy=[]
txy.append([0,0,0])
for _ in range(n):
    txy.append(list(map(int,input().split())))
ans = 'Yes'
for i in range(1,len(txy)):
    t_=txy[i][0]-txy[i-1][0]
    d_=abs(txy[i][1]-txy[i-1][1])+abs(txy[i][2]-txy[i-1][2])
    if t_ >= d_ and (t_ - d_) % 2 == 0:
        pass
    else:
        ans='No'
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
point = [0, 0]
t_list = []
ans = "Yes"
t = list(map(int, input().split()))
dis = abs(point[0]-t[1])+abs(point[1]-t[2])
t_list.append(t)
if t[0] < dis or t[0]%2!=dis%2:
    ans = "No"
point = [t[1], t[2]]
for i in range(N-1):
    t = list(map(int, input().split()))
    dis = abs(point[0]-t[1])+abs(point[1]-t[2])
    if t[0]-t_list[-1][0] < dis or (t[0]-t_list[-1][0])%2!=dis%2:
        ans = "No"
    point = [t[1], t[2]]
    t_list.append(t)
print(ans)

Submission status: Accepted

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

for i in range(1, len(s)):
    dt = int(s[i][0])-int(s[i-1][0])
    dx = abs(int(s[i][1])-int(s[i-1][1]))
    dy = abs(int(s[i][2])-int(s[i-1][2]))

    if dx+dy > dt:
        print("No")
        exit()
    elif (dx+dy) % 2 != dt % 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

ans = True
cx = 0
cy = 0
ct = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    d = abs(cx - x) + abs(cy - y)
    dt = t - (ct + d)
    if dt % 2 == 0 and dt >= 0:
        cx = x
        cy = y
        ct = t
    else:
        ans = False
        break

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
li = [[0,0,0]]
for _ in range(n):
    li.append(list(map(int,input().split())))
# print(li) [[3, 1, 2], [6, 1, 1]]
for i,l in enumerate(li):
    if i == 0:
        continue
    bef = li[i-1]
    diff = l[1]+l[2]-bef[1]-bef[2]
    if diff <= l[0]-bef[0] and  (diff - (l[0]-bef[0]))%2 == 0:
        continue
    else:
        print('No')
        sys.exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
t, x, y = np.concatenate((np.array([[0, 0, 0]]), I[1:].reshape(-1, 3)), axis=0).T

def main():
    dt = t[1:] - t[:-1]
    dd = np.absolute(x[1:] - x[:-1]) + np.absolute(y[1:] - y[:-1])
    ans = 'Yes' if np.all((dt >= dd) & (dt & 1 == dd & 1)) else 'No'
    print(ans) 

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
txy = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(n, 3)
t, x, y = np.concatenate((np.array([[0, 0, 0]]), txy), axis=0).T

def main():
    dt = t[1:] - t[:-1]
    dd = np.absolute(x[1:] - x[:-1]) + np.absolute(y[1:] - y[:-1])
    ans = 'Yes' if np.all((dt >= dd) & (dt & 1 == dd & 1)) else 'No'
    print(ans) 

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
# C - Traveling
def can_travel(N):

	last_t, last_x, last_y = 0, 0, 0
	
	for i in range(N):
		t, x, y = map(int, input().split())
		distnace = abs(x - last_x) + abs(y - last_y)
		time = t - last_t
		
		if distnace > time:
			return False
		elif (time - distnace) % 2 == 1:
			return False
	
	return  True
		

N = int(input())

if can_travel(N):
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(10000)
def resolve():
    N = int(input())
    TXY = [list(map(int, input().split(" "))) for i in range(N)]
    current = [0, 0, 0]
    for txy in TXY:
        tdiff = txy[0] - current[0]
        xdiff = abs(txy[1] - current[1])
        ydiff = abs(txy[2] - current[2])
        if tdiff < (xdiff + ydiff) or (tdiff % 2) != ((xdiff+ydiff) % 2):
            print("No")
            return
        current[0], current[1], current[2] = txy[0], txy[1], txy[2]
    print("Yes")
    


if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N = int(input())

t = [0]
x = [0]
y = [0]

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

# print(f"t:{t}\nx:{x}\ny:{y}")

for index in range(1, N + 1):
    distance = (x[index] - x[index - 1]) + (y[index] - y[index - 1])
    duration = t[index] - t[index - 1]
    if duration < distance or duration % 2 != distance % 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int,input().split()))for _ in range(n)]
ok = True
time = 0
nx = 0
ny = 0
for i in range(n):
    t = txy[i][0]
    x = txy[i][1]
    y = txy[i][2]
    dist = abs(x-nx)+abs(y-ny)
    if not(t - time >= dist and (t- time )%2 == dist%2):
        ok = False
        break
    time=t
    nx = x
    ny = y
if ok:print('Yes')
else:print('No')