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 = [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())
# print(t, x, y)
can = True
for n in range(N):
    if x[n + 1] + y[n + 1] - x[n] - y[n] > t[n + 1] - t[n]:
        print("No")
        exit()
    elif (x[n + 1] + y[n + 1] - x[n] - y[n]) % 2 == (t[n + 1] - t[n]) % 2:
        pass
    else:
        can = False

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

Submission status: Accepted

Solution code:
N = int(input())
answer = 'Yes'
place_now = [0,0,0]
for i in range(N):
  place_next = list(map(int, input().split()))
  if place_next[0]-place_now[0] < place_next[1]+place_next[2]-place_now[1]-place_now[2]:
    answer = 'No'
    break
  elif (place_next[0]-place_now[0])%2 != (place_next[1]+place_next[2]-place_now[1]-place_now[2])%2:
    answer = 'No'
    break

print(answer)

Submission status: Accepted

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

def hantei(A,x):
  abs_0 = abs(A[0][1]) + abs(A[0][2])
  if A[0][0] < abs_0 or (A[0][0] - abs_0) % 2 != 0:
    return("No")
  for i in range(1, x):
    abs_i = abs(A[i][1] - A[i-1][1]) + abs(A[i][2] - A[i-1][2])
    if A[i][0] - A[i-1][0] < abs_i or (A[i][0] - A[i-1][0] - abs_i) % 2 != 0:
      return("No")
  return("Yes")

print(hantei(txy, N))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n+1):
    if i == 0:
        continue
    t, x, y = txy[i-1]
    nt, nx, ny = txy[i]
    if abs(nx - x) + abs(ny - y) > nt - t:
        print("No")
        exit()
    if (abs(nx - x) + abs(ny - y)) % 2 != (nt - t) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#高速化
import sys
input_ = sys.stdin.readline

n = int(input_())
t0, x0, y0 = 0, 0, 0

for i in range(n):
  ti, xi, yi = map(int, input_().split())
  test = (ti - t0) - (xi + yi - x0 - y0)
  
  if test >= 0 and test % 2 == 0:
    t0, x0, y0 = ti, xi, yi
    if i == n-1:
      print("Yes")
  else:
    print("No")
    break

Submission status: Accepted

Solution code:
n = int(input())
t0, x0, y0 = 0, 0, 0

for i in range(n):
  ti, xi, yi = map(int, input().split())
  test = (ti - t0) - (xi + yi - x0 - y0)
  
  if test >= 0 and test % 2 == 0:
    t0, x0, y0 = ti, xi, yi
    if i == n-1:
      print("Yes")
  else:
    print("No")
    break

Submission status: Accepted

Solution code:
n=int(input())
txy=[[int(i) for i in input().split()] for _ in range(n)]
ans='Yes'
for t,x,y in txy:
    if (x+y)%2!=t%2:
        ans='No'
        break
    if x+y>t:
        ans='No'
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

def solve(x0,y0,x1,y1,t):
    if (t >= (abs(x1-x0) + abs(y0-y1))) and (((t -abs(x1-x0)-abs(y0-y1))%2)==0):
        return True
    else:
        return False
x0=0
y0=0
t0=0
for i in range(N):
    ti,xi,yi = map(int,input().split())
    if solve(x0,y0,xi,yi,ti-t0) == True:
        x0 = xi
        y0 = yi
        t0 = ti
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = [None] * N
X = [None] * N
Y = [None] * N

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

def is_reachable(t, x, y):
    x, y = abs(x), abs(y)
    if t >= (x + y):
        if (t - x - y) % 2 == 0:
            return True
    return False

ans = 'No'
if is_reachable(T[0], X[0], Y[0]):
    ans = 'Yes'
    for i in range(N-1):
        t, x, y = T[i+1], X[i+1], Y[i+1]
        t, x, y = t - T[i], x - X[i], y - Y[i]
        if not is_reachable(t, x, y):
            ans = 'No'
            break
print(ans)

Submission status: Accepted

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

def canMove():
    for i in range(1, N+1):
        t = place[i][0] - place[i-1][0]
        x = place[i][1] - place[i-1][1]
        y = place[i][2] - place[i-1][2]
        if x + y <= t and (t -x-y)%2 == 0:
            continue
        else:
            return "No"
    return "Yes"

print(canMove())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(range(n))
for i in range(n):
    a[i] = list(map(int, input().split()))
dx = 0
dy = 0
c = 0
k = 0
for s in range(n):
    dx = a[s][1] - dx
    dy = a[s][2] - dy
    if((dx+dy)>a[s][0]):
        print("No")
        break
    if(((abs(dx)+abs(dy))%2) == ((a[s][0]-k)%2)):
        c += 1
        k += a[s][0]
    else:
        print("No")
        break
if(c == n):
    print("Yes")

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
txy = []
for i in range(N):
    txy.append(LI())

txy = sorted(txy, key=lambda x:x[0])
#  print(txy)
count = 0
current = [0,0]
for item in txy:
    #  print(count, current)
    dist = abs(current[0] - item[1]) + abs(current[1] - item[2])
    if dist > item[0] - count:
        # 足らず
        print('No')
        exit()
    elif dist == item[0] - count:
        # ちょうど
        count = item[0]
        current = [item[1], item[2]]
    else:
        # 余り
        rest = item[0] - count - dist
        count = item[0]
        current = [item[1], item[2]]
        #  print('rest', rest)
        if rest % 2 != 0:
            # いけない
            print('No')
            exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
N =int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    tmp_t,tmp_x,tmp_y = map(int,input().split())
    t.append(tmp_t)
    x.append(tmp_x)
    y.append(tmp_y)
for i in range(1,N+1):
    distance = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if t[i]-t[i-1] < distance or (distance+(t[i]-t[i-1]))%2 != 0 :
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def check(t1,x1,y1,t2,x2,y2):
  if t2-t1<abs(x1-x2)+abs(y1-y2):
    return False
  if ((t2-t1)-abs(x1-x2)-abs(y1-y2))%2==0:
    return True
  return False
n=int(input())
data=[[int(i) for i in l.split()] for l in sys.stdin]
t1=0
x1=0
y1=0
for i in range(n):
  t2,x2,y2=data[i]
  if check(t1,x1,y1,t2,x2,y2):
    t1=t2
    x1=x2
    y1=y2
  else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

def can_move(fr, to):
    from_t, from_x, from_y = fr
    to_t, to_x, to_y = to
    dist = abs(from_x - to_x) + abs(from_y - to_y)
    time = to_t - from_t
    if dist > time:
        return False
    return time%2 == dist%2

before_txy = (0, 0, 0)
for txy in txyn:
    if not can_move(before_txy, txy):
        print("No")
        break
    before_txy = txy
else:
    print("Yes")

Submission status: Accepted

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

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

def travel(x,y,t):
    if abs(t-t_st) >= abs(x-x_st) + abs(y-y_st) and abs(t-t_st) % 2 == (abs(x-x_st) + abs(y-y_st)) % 2:
        return True
    else:
        return False

t_st = 0
x_st = 0
y_st = 0

ans = travel(x[0],y[0],t[0])

for i in range(1,n):
    x_st = x[i-1]
    y_st = y[i-1]
    t_st = t[i-1]
    if travel(x[i],y[i],t[i]):
        pass
    else:
        ans = False

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
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-t)-(abs(X-x)+abs(Y-y)))%2 == 0:
        t, x, y = T, X, Y
    else:
        print('No')
        sys.exit()
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())
    T.append(t)
    X.append(x)
    Y.append(y)
flag=True
for i in range(N):
    t=T[i+1]-T[i]
    x=abs(X[i+1]-X[i])
    y=abs(Y[i+1]-Y[i])
    z=x+y
    if t>=z and (t-z)%2==0:
        flag=True
    else:
        flag=False
        break
print("Yes") if flag else print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = "Yes"
for _ in range(n):
    t, x, y = map(int, input().split())
    if ((t % 2) != ((x+y) % 2)) | (t < x+y):
        ans = "No"
print(ans)

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)
#print(T, X, Y)

judge = True

for i in range(1, N + 1) :
    if T[i] - T[i-1] >= abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1]) :
        if (T[i] - T[i-1] - (abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1]))) % 2 == 0 :
            #print('test')
            continue
    judge = False
    break

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

Submission status: Accepted

Solution code:
n = int(input())
position = [[0]*3 for _ in range(n)]
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())
    if ans != "No":
        if x + y > t:
            ans = "No"
        else:
            if t % 2 == (x+y) % 2:
                ans = "Yes"
            else:
                ans = "No"
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
TXY = [map(int,input().split()) for _ in range(N)]
ans = "Yes"
for t,x,y in TXY:
    if (x+y)%2 != t%2:
        ans = "No"
        break
    if x+y > t:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
T = [[0 for i in range(3)] for i in range(N+1)]
for i in range(1,N+1):
  input_lines = input().split()
  T[i][0] = int(input_lines[0])
  T[i][1] = int(input_lines[1])
  T[i][2] = int(input_lines[2])
T[0][0] = 0
T[0][1] = 0
T[0][2] = 0

for i in range(1,N+1):
  t = T[i][0] - T[i-1][0]
  d = abs(T[i][1] - T[i-1][1]) + abs(T[i][2] - T[i-1][2])
  if (t-d)%2 ==1:
    print("No")
    break
  if t < d:
    print("No")
    break
  if i == N:
    print("Yes")

Submission status: Accepted

Solution code:
# dt:=ti+1 - ti, d:=abs(xi - xi+1) + abs(yi - yi+1)とおくと
# dt<=t and t%2 =d%2で判定できる

n = int(input())
t, x, y = zip(*((map(int, input().split()) for _ in range(n))))
t = [z for z in t]
x = [z for z in x]
y = [z for z in y]
t.insert(0, 0)  # 1-indexedにするため先頭に0を追加
x.insert(0, 0)
y.insert(0, 0)
# print(t, x, y)
can = True
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
    if ((dist % 2) != (dt % 2)):
        can = False

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

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    cx = 0
    cy = 0
    ct = 0
    for i in range(N):
        ti,xi,yi = map(int,input().split())
        t = ti - ct
        x = abs(xi - cx)
        y = abs(yi - cy)
        if x + y > t:
            return 'No'
        if (x + y - t) % 2 != 0:
            return 'No'
        cx = xi
        cy = yi
        ct = ti
    return 'Yes'

print(solve())

Submission status: Accepted

Solution code:
n = int(input())
tn=0
xn=0
yn=0
f=0
for i in range(n):
    t, x, y = map(int, input().split())
    dt=t-tn
    dx=abs(x-xn)
    dy=abs(y-yn)
    dxy= dx + dy
    if dt < dxy:
        f=1
    else:
        if dt%2==0 and dxy%2!=0:
            f=1
        elif dt%2!=0 and dxy%2==0:
            f=1
if f==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
a = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
ans = "Yes"
for i in range(n) :
  diff = sum(a[i+1]) - sum(a[i])
  if(diff % 2 == 1 or diff - 2*(a[i+1][0] - a[i][0]) > 0) : ans = "No" 
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
t0=x0=y0=0
f=0
for i in range(n):
  t,x,y=map(int,input().split())
  t1=t-t0
  x1=abs(x-x0)
  y1=abs(y-y0)
  if t1<x1+y1 or t1%2!=(x1+y1)%2:
    f=1
  t0=t
  x0=x
  y0=y
if f==1:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
x0 = [[0,0,0]]
for i in range(n):
    x0 += [list(map(int,input().split()))]
flag = 1
for i in range(1,n+1):
    x1 = x0[i-1]
    x2 = x0[i]
    dt = x2[0]-x1[0]
    dx = abs(x2[1]-x1[1])
    dy = abs(x2[2]-x1[2])
    if dx+dy-dt>0:
        flag=0
        break
    else:
        if (dt-dx-dy)%2==1:
            flag = 0
            break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

prex = 0
prey = 0
pret = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    dt = t-pret
    mindis = abs(x-prex)+abs(y-prey)
    if dt >=mindis and (dt-mindis)%2==0:
        o = 1
    else:
        flag = False
    pret = t
    prex = x
    prey = y
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
travels = np.array([input().split() for _ in range(N)], dtype=int)
travels = np.insert(travels, 0, [0, 0, 0], axis=0)
travels = travels[travels[:,0].argsort(), :]
able = True
for i in range(0, N):
    dist = travels[i+1,:] - travels[i,:]
    x_dist = abs(dist[1])
    y_dist = abs(dist[2])
    time_dist = dist[0]
    x = travels[i+1,1]
    y = travels[i+1,2]
    time = travels[i+1,0]
    if x_dist+y_dist>time_dist:
        able = False
        break
    elif (x+y)%2==0 and time%2!=0:
        able = False
        break
    elif (x+y)%2!=0 and time%2==0:
        able = False
        break
if able:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

def judge():
    for i in range(N):
        dt = t[i + 1] - t[i]
        diff = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
        if diff > dt or (dt - diff) % 2 != 0:
            return False
    return True

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

Submission status: Accepted

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

last_x = 0
last_y = 0
last_t = 0
for t in Ti:
    dt = t[0] - last_t
    dx = abs(t[1] - last_x)
    dy = abs(t[2] - last_y)
    d = dx + dy
    if dt < d or dt % 2 != d % 2:
        print("No")
        exit()

    last_t = t[0]
    last_x = t[1]
    last_y = t[2]

print("Yes")

Submission status: Accepted

Solution code:

n = int(input())


here = list( map(int, input().split()) )
can = here[0] >= (here[1]+here[2])

for i in range(n-1):

    next = list(map(int, input().split()) )

    t = next[0] - here[0]

    d = abs( next[1] + next[2] - (here[1]+ here[2] ) )

    cond = t >= d and t % 2 == d % 2
    if not cond:
        can = False
        break

    here = next

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1,N+1):
  t,x,y = map(int,input().split())
  cond1 = t >= (x + y)
  cond2 = (t % 2 == 0 and (x + y) % 2 == 0) or (t % 2 == 1 and (x + y) % 2 == 1)
  if not cond1 or not cond2:
    print("No")
    break
  
  if i == N:
    print('Yes')

Submission status: Accepted

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

f=True
for i in range(int(n)):
    m = plan[i+1][0] - plan[i][0] - abs(plan[i+1][1] - plan[i][1]) - abs(plan[i+1][2] - plan[i][2]) 
    if m < 0 or m%2!=0:
        print("No")
        f=False
        break


if f:
    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] = list(map(int, input().split()))

for i in range(0, N):
  dist = (abs(X[i] - X[i+1]) + abs(Y[i] - Y[i+1]))
  if T[i+1] - T[i] >= dist and (T[i+1] - T[i] - dist)%2==0:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

ts, xs, ys = [], [], []
for _ in range(N):
    t, x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
    ts.append(t)

dt = ts[0]
dist = abs(xs[0]) + abs(ys[0])

if dist > dt:
    print("No")
    exit()
if (dt % 2) != (dist % 2):
    print("No")
    exit()

for t in range(N-1):
    dt = ts[t+1] - ts[t]
    dist = abs(xs[t+1]-xs[t]) + abs(ys[t+1]-ys[t])

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

    if (dt % 2) != (dist % 2):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
# 0位置からの計算でも途中位置からの計算でも計算コストは同じ
def travelable(t, x, y):
    min_step = x + y
    if t < min_step:
        return False
    return (t - min_step) % 2 == 0

ans = None
N = int(input())
for _ in range(N):
    t_x_y = list(map(int, input().split()))
    if not travelable(t_x_y[0], t_x_y[1], t_x_y[2]):
        ans = "No"
        break
if ans is None:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
def solve(T_X_Y):
    curr_t = 0
    curr_x = 0
    curr_y = 0
    for t_x_y in T_X_Y:
        t = t_x_y[0]
        x = t_x_y[1]
        y = t_x_y[2]
        if not travelable(curr_t, curr_x, curr_y, t, x, y):
            return "No"
    return "Yes"


def travelable(curr_t, curr_x, curr_y, t, x, y):
    dist_x = abs(x - curr_x)
    dist_y = abs(y - curr_y)
    min_step = dist_x + dist_y
    if t - curr_t < min_step:
        return False
    return (t - curr_t - min_step) % 2 == 0


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

print(solve(T_X_Y))

Submission status: Accepted

Solution code:
n = int(input())

now_t , now_x , now_y = 0, 0, 0
flag = 1
for _ in range(n):
    next_t , next_x, next_y = map(int,input().split())
    diff_t = next_t - now_t
    diff_x = next_x - now_x
    diff_y = next_y - now_y
    diff = diff_t - (diff_x+diff_y)
    if diff >= 0:
        if diff%2 == 0:
            pass
        else:
            flag= 0
    else:
        flag = 0
    
    now_t , now_x , now_y = next_t , next_x, next_y

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

Submission status: Accepted

Solution code:
N = int(input())
T = []
X = []
Y = []

for i in range(N):
  t,x,y = map(int,input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
  
judge = 1 # 1:可,0:不可
nx,ny = 0,0
for i in range(N):
  if(i == 0):
    t = T[i]
  else:
    t = T[i] - T[i-1]
    
  distance = abs(X[i]-nx) + abs(Y[i]-ny)
  time = 1*distance
  if(t < time):
    judge = 0
    break
  if((t - time)%2 != 0): #自分のマスに2秒で帰ってこれるので
    judge = 0
    break
  nx,ny = X[i],Y[i]
  
if(judge == 1):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/21
Solved on 2019/3/
@author: shinjisu
"""


# ABC 086 C Traveling
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    d.dmp(N)
    prevT, prevX, prevY = 0, 0, 0
    for i in range(N):
        T, X, Y = getIntList()
        d.dmp((T, X, Y), 'T, X, Y')
        dt, dx, dy = T-prevT, abs(X-prevX), abs(Y-prevY)
        d.dmp((dt, dx, dy), 'dt, dx, dy')
        if dt < dx+dy:
            return 'No'
        if (dt-dx-dy) % 2 == 1:
            return 'No'
        prevT, prevX, prevY = T, X, Y
    return 'Yes'


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]
ct = 0
p = [0, 0]
failed = False
for i in range(N):
    t, x, y = txy[i]
    dx, dy = abs(p[0]-x), abs(p[1]-y)
    dt = t - ct
    if dt < dx+dy:
        failed = True
        break
    elif dt % 2 and (dx+dy) % 2 == 0:
        failed = True
        break
    elif dt % 2 == 0 and (dx+dy) % 2:
        failed = True
        break
    ct = t
    p = [x, y]

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

Submission status: Accepted

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

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point_a += 1

for i in range(N):
    if point_a == 0 and ((TXY[i+1][0] - TXY[i][0]) % 2 != (abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2])) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
b = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if t < (x+y) or (t+x+y) % 2:
        print("No")
        b = 1
        break
if b == 0:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
N = int(input())
t, x, y = [], [], []
p_x, p_y = 0, 0
for i in range(N):
    t_t, x_t, y_t = map(int, input().split())
    t.append(t_t)
    x.append(x_t)
    y.append(y_t)
for i in range(N):
    if int(t[i]) < int(x[i]) + int(y[i]) or t[i] % 2 != (x[i] + y[i]) % 2:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  return (t-t0-minT)>=0 and (t-t0-minT)%2==0
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
num=0;bool=False
while num<=n-1:
  t,x,y=lst[num]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    num+=1
    bool=True
  else:
    bool=False
    break
if bool:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for i in range(0, N):
    t1, x1, y1 = map(int, input().split())
    id = (t1-t0)-abs(x1-x0)-abs(y1-y0)
    if id<0 or id%2==1:
        print("No")
        break
    elif i==N-1:
        print("Yes")
    t0 = t1
    x0 = x1
    y0 = y1

Submission status: Accepted

Solution code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  if (t-t0-minT)>=0 and (t-t0-minT)%2==0:
    return True
  else:
    return False
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
for i in range(n):
  t,x,y=lst[i]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    ans=True
  else:
    ans=False
    break
if ans:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())
tn,xn,yn = 0,0,0
for _ in range(n):
  to,xo,yo = tn,xn,yn
  tn,xn,yn = map(int,input().split())
  if tn-to >= abs(xn-xo)+abs(yn-yo) and (tn-to)%2 == (abs(xn-xo)+abs(yn-yo))%2:
    continue
  else:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline
lines = stdin.readlines

N = int(input())

txy = [[int(i) for i in line.split()] for line in lines()]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        dt = t - pt - abs(x - px) - abs(y - py)
        # 余った時間が奇数 戻れない
        if dt < 0 or dt % 2 == 1:
            break

        pt = t
        px = x
        py = y
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline
lines = stdin.readlines

N = int(input())

txy = ((map(int, line.split())) for line in lines())


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        dt = t - pt - abs(x - px) - abs(y - py)
        # 余った時間が奇数 戻れない
        if dt < 0 or dt % 2 == 1:
            break

        pt = t
        px = x
        py = y
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline

N = int(input())

txy = [[int(j) for j in input().split()] for i in range(N)]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        dt = t - pt - abs(x - px) - abs(y - py)
        # 余った時間が奇数 戻れない
        if dt < 0 or dt % 2 == 1:
            break

        pt = t
        px = x
        py = y
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline

N = int(input())

txy = [[int(j) for j in input().split()] for i in range(N)]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        d = abs(x - px) + abs(y - py)
        dt = t - pt
        # 到達 あるいは 通過
        # 距離と時間の偶奇が一致 戻れる
        if d <= dt and d % 2 == dt % 2:
            pt = t
            px = x
            py = y
        # 到達しない
        # 戻れない
        else:
            break
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline

N = int(input())

txy = [[int(j) for j in input().split()] for i in range(N)]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        d = abs(x - px) + abs(y - py)
        dt = t - pt
        # 到達 あるいは 通過
        if d <= dt:
            # 距離と時間の偶奇が一致しない 戻れない
            if d % 2 != dt % 2:
                break
            else:
                pt = t
                px = x
                py = y
        # 到達しない
        else:
            break
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:
from sys import stdin

input = stdin.readline

N = int(input())

txy = [[int(j) for j in input().split()] for i in range(N)]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        # 到達 あるいは 通過
        if abs(x - px) + abs(y - py) <= t - pt:
            # 距離と時間の偶奇が一致しない 戻れない
            if (abs(x - px) + abs(y - py)) % 2 != (t - pt) % 2:
                break
            else:
                pt = t
                px = x
                py = y
        # 到達しない
        else:
            break
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

Solution code:
def check_rote(a, b, t, x, y):
    cost_min = abs(a - x) + abs(b - y)
    if cost_min <= t and (t - cost_min) % 2 == 0:
        return True
    else:
        return False

n = int(input())
rotes = []

for i in range(n):
    rotes.append(tuple((int(x) for x in input().split())))

copy_t = 0
copy_a = 0
copy_b = 0

for i in rotes:
    t, a, b = i
    if not check_rote(a, b, t - copy_t, copy_a, copy_b):
        print("No")
        break
    copy_t = t
    copy_a = a
    copy_b = b
else:
    print("Yes")