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 = []
p = [0, 0, 0]
while(n):
    a, b, c = input().split(' ')
    t.append([int(a), int(b), int(c)])
    n-=1
for i in t:
    while(p[0] < i[0]):
        p[0]+=1
        if i[1] > p[1]:
            p[1]+=1
        elif i[2] > p[2]:
            p[2]+=1
        elif i[1] < p[1]:
            p[1]-=1
        elif i[2] < p[2]:
            p[2]-=1
        else:
            p[1]-=1
    if p != i:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
 
ti,xi,yi = 0,0,0
found = True
for _ in range(n):
    t, x, y = map(int, input().split())
    root = abs(x-xi)+abs(y-yi)
    if root > (t-ti) or (t-ti-root)&1:
        found = False
    ti,xi,yi = t,x,y  
    
print("Yes" if found else "No")

Submission status: Accepted

Solution code:
n = int(input())

ti,xi,yi = 0,0,0
found = True
for _ in range(n):
    t, x, y = map(int, input().split())
    root = abs(x-xi)+abs(y-yi)
    if root > (t-ti) or (t-ti-root)&1:
        found = False
    ti,xi,yi = t,x,y  
    
print("Yes" if found else "No")

Submission status: Accepted

Solution code:
n = int(input())
found = True
ti,xi,yi = 0,0,0
for _ in range(n):
  t,x,y = map(int,input().split())
  rt = abs(x-xi)+abs(y-yi)
  if rt > (t-ti) or (t-ti-rt)&1:
    found = False
  ti,xi,yi = t,x,y
print("Yes" if found else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit

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

l.insert(0, [0, 0, 0])
for i in range(n):
    t1, x1, y1 = l[i]
    t2, x2, y2 = l[i+1]
    d = abs(x2 - x1) + abs(y2 - y1)
    t = t2 - t1
    if d > t or (d + t) % 2 == 1:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
t0=0
x0=0
y0=0
 
for i in range(N):
  t1,x1,y1=map(int,input().split())
  AbsT=t1-t0
  AbsX=abs(x1-x0)
  AbsY=abs(y1-y0)
  if AbsX+AbsY>AbsT or (AbsX+AbsY-AbsT)%2!=0:
    print("No")
    break
  else:
      x0=x1
      y0=y1
      t0=t1

else:
  print("Yes")

Submission status: Accepted

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

for i in range(1, n+1):
    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])
    
    tmp = dt - dx - dy
    if tmp < 0 or tmp % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    if i>0:
        distance = abs(data[i][1]-data[i-1][1])+abs(data[i][2]-data[i-1][2])
        time = abs(data[i][0]-data[i-1][0])
    else:
        distance = abs(data[i][1])+abs(data[i][2])
        time = abs(data[i][0])
    
    if distance <= time:
        if (data[i][0] + data[i][1] + data[i][2])% 2 == 0:
            continue
        else:
            break
    else:
        break
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Accepted

Solution code:
n = int(input())

s = 0
p = 0
for _ in range(n):
  t,x,y = map(int, input().split())
  s = t - s
  p = abs((x+y)-p)
  if s < p:
    print("No")
    exit()
  elif s%2 != p%2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
txy = [0]*n

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

t_ = 0
x_ = 0
y_ = 0

for i in range(n):
  dx = 0
  dy = 0
  t = txy[i][0]
  x = txy[i][1]
  y = txy[i][2]
  dx = abs(x-x_)
  dy = abs(y-y_)
  d = dx + dy
  if d == abs(t - t_):
    t_ = t
    x_ = x
    y_ = y
  elif d > abs(t - t_):
    print("No")
    exit()
  else:
    if (abs(t - t_)-d)%2 == 0:
      t_ = t
      x_ = x
      y_ = y      
    else:
      print("No")
      exit()
      
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t, x, y = [0]*3
for _ in range(N):
  t_, x_, y_ = map(int, input().split())
  dis = abs(x_ - x) + abs(y_ - y)
  dt = t_ - t
  if dis > dt:
    print("No")
    exit()
  if dis%2 == dt%2:
    t, x, y = t_, x_, y_
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
tb, xb, yb = 0, 0, 0
for _ in range(n):
    ta, xa, ya = list(map(int, input().split()))
    tdiff = abs(ta - tb)
    mdiff = abs(xa - xb) + abs(ya - yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
        
    tb, xb, yb = ta, xa, ya
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
tb,xb,yb = 0,0,0
for _ in range(n):
    ta,xa,ya = list(map(int, input().split()))
    tdiff = abs(ta-tb)
    mdiff = abs(xa-xb) + abs(ya-yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
    
    tb,xb,yb = ta,xa,ya

print('Yes')

Submission status: Accepted

Solution code:
n = int(input());
told,xold,yold = 0,0,0; 
ans = 'Yes';
for i in range(n) :
    tnew,xnew,ynew = [int(x) for x in input().split()];
    dis = abs(xnew-xold) + abs(ynew-yold);
    diff = tnew - told;
    if (diff - dis)%2 == 1 or diff < dis :
        ans = 'No';
        break;
    else :
        told,xold,yold = tnew,xnew,ynew;

print(ans);

Submission status: Accepted

Solution code:
n = int(input())

t = [0]*1001001
x = [0]*1001001
y = [0]*1001001


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

flag = 1    
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:
        flag = 0
    if dist % 2 != dt % 2:
        flag = 0

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

Submission status: Accepted

Solution code:
n = int(input())

s = 0
p = 0
for _ in range(n):
  t,x,y = map(int, input().split())
  s = t - s
  p = abs((x+y)-p)
  if s < p:
    print("No")
    exit()
  elif s%2 != p%2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

def manhattan(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])

N = int(input().strip())
ts = [None for _ in range(N+1)]
ps = [None for _ in range(N+1)]

ts[0] = 0
ps[0] = (0, 0)

for n in range(1, N+1):
    t, p, q = tuple(map(int, input().strip().split()))
    ts[n] = t
    ps[n] = (p, q)

for n in range(N):
    dt = ts[n+1] - ts[n]
    dist = manhattan(ps[n+1], ps[n])
    if (dist > dt) or (dt % 2) != (dist % 2):
        print("No")
        exit()

print("Yes")

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker

Submission status: Accepted

Solution code:
import sys

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())


def main():
    N = ii()
    txy = [list(mi()) for i in range(N)]
    t, x, y = [list(i) for i in zip(*txy)]
    if t[0]-x[0]-y[0] < 0 or (t[0]-x[0]-y[0])%2:
        print('No')
        return
    for i in range(N-1):
        k = t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i])
        if k < 0 or k%2:
            print('No')
            return
    print('Yes')
    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A = [[0,0]]
N = int(input())
for _ in range(N):
    t,x,y = map(int,input().split())
    A.append([t,x+y])
for i in range(1,N+1):
    
    if A[i][0]-A[i-1][0] >= abs(A[i][1]-A[i-1][1]) and (A[i][0]-A[i-1][0])%2 == (A[i][1]-A[i-1][1])%2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
normal = True
def judge(a, b):
  m = b[0]-a[0]-abs(b[1]-a[1])-abs(b[2]-a[2])
  if m>=0 and m%2==0:
    return True
  else:
    return False
for i in range(N):
  if judge(T[i], T[i+1]):
    pass
  else:
    normal = False
    break
print("Yes" if normal else "No")

Submission status: Accepted

Solution code:
from pprint import pprint
 
# import math
# import collections
 
n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
t, x, y = [0], [0], [0]
d = [0]
dd = [0]
td = [0]
 
for i in range(1, n + 1):
    _t, _x, _y = map(int, input().split(' '))
    t.append(_t)
    x.append(_x)
    y.append(_y)
 
    d.append(abs(x[i] - x[0]) + abs(y[i] - y[0]))
    dd.append(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))
    td.append(t[i] - t[i-1])
 
# 時刻の奇遇と距離の奇遇は一致する
# d <= t である
movable = [False] * (n + 1)
 
for i in range(n + 1):
    if d[i] <= t[i] and (t[i] % 2 == d[i] % 2) and dd[i] <= td[i]:
        movable[i] = True
 
if all(movable):
    res = 'Yes'
else:
    res = 'No'
 
# pprint(d)
# pprint(movable)
print(res)

Submission status: Accepted

Solution code:
N = int(input())

prev_t = 0
prev_x = 0
prev_y = 0

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

print("Yes")

Submission status: Accepted

Solution code:
from pprint import pprint

# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
t, x, y = [0], [0], [0]
d = [0]
dd = [0]
td = [0]

for i in range(1, n + 1):
    _t, _x, _y = map(int, input().split(' '))
    t.append(_t)
    x.append(_x)
    y.append(_y)

    d.append(abs(x[i] - x[0]) + abs(y[i] - y[0]))
    dd.append(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))
    td.append(t[i] - t[i-1])

# 時刻の奇遇と距離の奇遇は一致する
# d <= t である
movable = [False] * (n + 1)

for i in range(n + 1):
    if d[i] <= t[i] and (t[i] % 2 == d[i] % 2) and dd[i] <= td[i]:
        movable[i] = True

if all(movable):
    res = 'Yes'
else:
    res = 'No'

# pprint(d)
# pprint(movable)
print(res)

Submission status: Accepted

Solution code:
n=int(input())
x=0
y=0
t=0
fl=True
for i in range(n):
  nt,nx,ny=map(int,input().split())
  dist=abs(x-nx)+abs(y-ny)
  if (nt-t)%2!=dist%2 or (nt-t)<dist:
    print("No")
    break
  x,y=nx,ny
  t=nt
else:
  print("Yes")

Submission status: Accepted

Solution code:
import sys

N = int(input())
now = [0]*3
for i in range(N):
    a, b, c = map(int, input().split())
    val0 = a-now[0]
    val1 = abs(b-now[1]) + abs(c-now[2])
    
    while val1 < val0:
        val1 += 2
    if val1 != val0:
        print('No')
        sys.exit()
    now = [a, b, c]
print('Yes')

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    pos = (0, 0)
    time_before = 0
    can = True

    for i in range(n):
        t, x, y = map(int, input().split())
        dist = abs(pos[0] - x) + abs(pos[1] - y)
        time = t - time_before
        # 時間内に到達不可
        if dist > time:
            can = False
            break
        if (dist % 2 == 0 and time % 2 != 0) or (dist % 2 != 0 and time % 2 == 0):
            can = False
            break
        time_before = t
        pos = (x, y)
    print('Yes' if can else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

l = [[0, 0, 0]]
l.extend(L)

flag = True
for c in range(1, len(l)):
    dt = l[c][0] - l[c-1][0]
    dist = abs(l[c][1] - l[c-1][1]) + abs(l[c][2] - l[c-1][2])

    if dist > dt or (dist % 2) != (dt % 2):
        flag = False

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

Submission status: Accepted

Solution code:
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
flag = 0
t1 = 0
x1,y1 = 0,0
for i in range(N):
    t2,x2,y2 = X[i]
    dt = t2-t1
    d = dist((x1,y1),(x2,y2))
    if dt>=d and (dt-d)%2==0:
        t1,x1,y1 = t2,x2,y2
        continue
    flag = 1
    break
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# 最高で進んでもtを超えることはできない
# 1ターンにつき1進むので偶奇をみる

n = int(input())
pre = [0, 0, 0]  # time, x, y
for i in range(n):
    t, x, y = map(int, input().split())
    t -= pre[0]
    x -= pre[1]
    y -= pre[2]
    if t < abs(x) + abs(y) or (abs(x) + abs(y)) % 2 != t % 2:
        print("No")
        exit()
    pre = [t, x, y]
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
tc, xc, yc = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t, x, y = map(int, input().split())
  if (t - tc - abs(x-xc) - abs(y-yc)) % 2 == 1 or t - tc - abs(x-xc) - abs(y-yc) < 0:
    ans = 'No'
    break
  tc, xc, yc = t, x, y
print(ans)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

n = int(input())
T = []
X = []
Y = []
for i in range(n):
    t,x,y = readInts()
    T.append(t)
    X.append(x)
    Y.append(y)
cx,cy,ct = 0,0,0
for i in range(n):
    dist_place = abs(X[i] - cx) + abs(Y[i] - cy)
    dist_time = abs(T[i] - ct)
    if dist_time >= dist_place and (dist_time - dist_place) % 2 == 0:
        cx = X[i]
        cy = Y[i]
        ct = T[i]

        pass
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
tc = 0
xc, yc = 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x-xc)+abs(y-yc)
    if d > t-tc:
        print('No')
        exit()
    else:
        if (t-tc-d)%2 != 0:
            print('No')
            exit()
    xc, yc, tc = x, y, t
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
T=X=Y=0
ans = "Yes"
for t,x,y in txy:
    if abs(T-t) < abs(X-x)+abs(Y-y):
        ans = "No"
        break
    a = abs(T-t) - (abs(X-x)+abs(Y-y))
    if a%2!=0:
        ans = "No"
        break
    T,X,Y = t,x,y
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

t_0 = 0
x_0 = 0
y_0 = 0
flag = True

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

    if not (abs(x-x_0) + abs(y-y_0) <= abs(t-t_0) and (abs(x-x_0)+abs(y-y_0))%2 == abs(t-t_0)%2):
        flag = False
    x_0 = x
    y_0 = y
    t_0 = t

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

Submission status: Accepted

Solution code:
n = int(input())
tp, xp, yp = 0, 0, 0
for _ in range(n):
    t, x, y = map(int, input().split())
    td = t - tp
    xd = x - xp
    yd = y - yp
    if td < abs(xd) + abs(yd) or (td - abs(xd) - abs(yd)) % 2 == 1:
        print('No')
        break
    tp = t
    xp = x
    yp = y
else:
    print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
T0,X0,Y0=0,0,0
for i in range(N):
  T,X,Y=map(int,input().split())
  tmp=T-T0
  if abs(X-X0)+abs(Y-Y0)>tmp:
    print('No')
    exit()
  else:
    Par=tmp%2
    if Par==1:
      if (abs(X-X0)+abs(Y-Y0))%2==0:
        print('No')
        exit()        
    else:
      if (abs(X-X0)+abs(Y-Y0))%2==1:
        print('No')
        exit()
  T0,X0,Y0=T,X,Y
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
now, nx, ny = [0, 0, 0]

f = True
for i in range(n):
    t, x, y = map(int, input().split())
    mdist = abs(nx-x) + abs(ny-y)
    if t - now < mdist:
        f = False
        break
    elif mdist%2 != (t-now)%2:
        f = False
        break
    else:
        now = t
        nx, ny = x, y
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-27 10:45:46 +0900
# LastModified: 2020-06-27 11:10:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    current = [0, 0, 0]
    flag = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        if flag == 1:
            continue
        judge = int(abs(x-current[1]))+int(abs(y-current[2]))
#        print(judge)
        if t-current[0] < judge:
            flag = 1
        elif t-current[0] == judge:
#            print(t,x,y)
            current[0] = t
            current[1] = x
            current[2] = y
        else:
            ama = t-current[0]
            if (ama-judge)%2 != 0:
                flag = 1
            else:
                current[0] = t
                current[1] = x
                current[2] = y

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



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
T = [0 for _ in range(N)]
X = [0 for _ in range(N)]
Y = [0 for _ in range(N)]
count = 0
t = 0
x = 0
y = 0

for i in range(N):
    T[i], X[i], Y[i] = map(int, input().split())
    t = abs(T[i] -t)
    x = abs(X[i] -x)
    y = abs(Y[i] -y)
    if t>= x+y and (t-(x+y))%2 == 0:
        count +=1
    else:
        break
    #     else:
    #         print('No1')
    #         exit()
    # else:
    #     print('No2')
    #     break

print('Yes' if count==N else 'No')

Submission status: Accepted

Solution code:
N = int(input())
txy = [tuple(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
for i in range(N):
    nt,nx,ny = txy[i]
    t = nt-t
    x = nx-x
    y = ny-y
    d = abs(x)+abs(y)
    if t < d:
        print("No")
        exit(0)
    elif (t-d)%2 == 1:
        print("No")
        exit(0)
    t,x,y = txy[i]
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
flag='Yes'
p,q,r=0,0,0
for _ in range(N):
  t,x,y=map(int,input().split())
  a=abs(x-p)+abs(y-q)
  e=t-r
  if a<=e:
    if (e-a)%2!=0:
      flag='No'
      break
  else:
    flag='No'
    break
  p,q,r=x,y,t
print(flag)

Submission status: Accepted

Solution code:
N=int(input())
t_pre=0
x_pre=0
y_pre=0

for i in range(N):
    t,x,y = map(int,input().split())
    t_af=t-t_pre
    x_af=x-x_pre
    y_af=y-y_pre
    if (abs(x_af+y_af)<=t_af) & ((x_af+y_af+t_af)%2 == 0):
      t_pre=t
      x_pre=x
      y_pre=y
      continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
TP = [[0, 0, 0]]
for _ in range(n):
    TP.append(list(map(int, input().split())))
for i in range(1, n + 1):
    td = TP[i][0] - TP[i-1][0]
    pd = abs(TP[i][1] - TP[i-1][1]) + abs(TP[i][2] - TP[i-1][2])
    if td >= pd and td % 2 == pd % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
now_t, now_x, now_y = 0, 0, 0
for i in range(N):
    next_t, next_x, next_y = map(int, input().split())
    distance = abs(next_x - now_x) + abs(next_y - now_y)
    spent_time = next_t - now_t
    if spent_time < distance or distance % 2 != spent_time % 2:
        print('No')
        exit()
    now_t, now_x, now_y = next_t, next_x, next_y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
xc, yc, tc = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t, x, y = map(int, input().split())
  if (t - tc - abs(x-xc) - abs(y-yc)) % 2 == 0 and t - tc - abs(x-xc) - abs(y-yc) >= 0:
    xc, yc, tc = x, y, t
  else:
    ans = 'No'
    break
print(ans)

Submission status: Accepted

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

T=X=Y=0
ok = True
for t,x,y in txy:
  if abs(X-x)+abs(Y-y) <= t-T:
    if (t-T)%2 == 0:
      if (abs(X-x)+abs(Y-y))%2!=0:
        ok = False
        break
    else:
      if (abs(X-x)+abs(Y-y))%2==0:
        ok = False
        break
  else:
    ok = False
    break
  T,X,Y = t,x,y
print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
flag = 0
t1,x1,y1 = 0,0,0
for i in range(N):
    t2,x2,y2 = X[i]
    d = dist((x1,y1),(x2,y2))
    dt = t2-t1
    if dt>=d and (dt-d)%2==0:
        t1,x1,y1 = X[i]
    else:
        flag=1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

x_dif = t_list[0][1]
y_dif = t_list[0][2]
t_dif = t_list[0][0]
if x_dif + y_dif <= t_dif and (x_dif+y_dif)%2 == t_dif%2:
    pass
else:
    print('No')
    exit()
for i in range(n-1):
    x_dif = abs(t_list[i+1][1]-t_list[i][1])
    y_dif = abs(t_list[i+1][2]-t_list[i][2])
    t_dif = t_list[i+1][0]-t_list[i][0]
    # print(i, x_dif, y_dif, t_dif)
    if x_dif + y_dif <= t_dif and (x_dif+y_dif)%2 == t_dif%2:
        pass
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

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

t_0 = 0
x_0 = 0
y_0 = 0

for t,x,y in txy:
    dt = t - t_0
    dx = x - x_0
    dy = y - y_0
    if (abs(dx) + abs(dy))%2 == dt%2 and (abs(dx)+abs(dy)) <= dt:
        t_0 = t
        x_0 = x
        y_0 = y
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    tc, xc, yc = 0, 0, 0
    for i in range(N):
        t, x, y = inm()
        d = abs(xc - x) + abs(yc - y)
        if d > (t - tc):
            return False
        if ((t - tc) - d) % 2 == 1:
            return False
        tc, xc, yc = t, x, y

    return True


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n=int(input())
currtime=0
currx=0
curry=0
for i in range(n):
  t,x,y=map(int,input().split())
  if abs(y-curry)+abs(x-currx)<=t-currtime and (abs(y-curry)+abs(x-currx))%2==(t-currtime)%2:
    currx=x
    curry=y
    currtime=t
  else:
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
tpr, xpr, ypr = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(x-xpr) + abs(y-ypr)
    n = ((t-tpr) - d) / 2
    if n >= 0 and n % 1 == 0:
        count += 1
    tpr, xpr, ypr = t, x, y
if count == N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

now_x, now_y = 0, 0
pre_t = 0

for t, x, y in txy:
    walk = abs(now_x - x) + abs(now_y - y)
    if t - pre_t < walk:
        print('No')
        exit()
    if (t-pre_t) % 2 != walk % 2:
        print('No')
        exit()
    now_x = x
    now_y = y
    pre_t = t

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
ans = 'Yes'
t_diff = 0
x_diff = 0
y_diff = 0
for i in p:
  t_diff = i[0] - t_diff
  x_diff = abs(i[1] - x_diff)
  y_diff = abs(i[2] - y_diff)
  if t_diff >= x_diff + y_diff:
    if (t_diff - x_diff - y_diff)%2 != 0:
      ans = 'No'
      break
  else:
    ans = 'No'
    break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = [list(map(int,input().split())) for _ in range(n)]
now = 0
now_t = 0
flag = 1
for i in range(n):
    t,x,y = s[i][0],s[i][1],s[i][2]
    next = x+y
    dist = abs(next - now)
    time = t - now_t
    if dist == 0 and time == 1:
        print('No')
        exit()
    if dist > time:
        print('No')
        exit()
    elif dist == time:
        now_t = t
        now = next
    else:
        if abs(dist - time) % 2 == 0:
            now_t = t
            now = next
        else:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

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

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

dt = [-1 for _ in range(n)]
dx = [-1 for _ in range(n)]
dy = [-1 for _ in range(n)]
for i in range(n):
    if i == 0:
        dt[0] = t[0]
        dx[0] = x[0]
        dy[0] = y[0]
    else:
        dt[i] = t[i] - t[i-1]
        dx[i] = x[i] - x[i-1]
        dy[i] = y[i] - y[i-1]

ok = True
for i in range(n):
    tr = dt[i]%2
    pr = (dx[i]+dy[i])%2
    if (tr == pr) and (dt[i] >= abs(dx[i])+abs(dy[i])):
        pass
    else:
        ok = False
#        import pdb; pdb.set_trace()
        break

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

Submission status: Accepted

Solution code:
from sys import stdin
data = stdin.readlines()

N = int(data[0])
l = [0, 0]
i = 1
while i <= N:
    l.append(int(data[i].split()[0]))
    l.append(int(data[i].split()[1])+int(data[i].split()[2]))
    i += 1

def check(x):
    diffrent_time = l[2*x] - l[2*x-2]
    diffrent_place = abs(l[2*x+1] - l[2*x-1])
    return diffrent_time % 2 == diffrent_place % 2 and diffrent_time >= diffrent_place

count = 0
i = 1
while i <= N:
    if check(i) == False:
        count = 1
    i += 1
if count == 0:
    print("Yes")
elif count == 1:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
pret=0
prex=0
prey=0
for i in range(N):
    t,x,y=map(int, input().split())
    d=abs(x-prex)+abs(y-prey)
    dt=t-pret
    if dt >= d and (dt-d)%2==0:
        prex=x
        prey=y
        pret=t
    else:
        
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]
stxy = sorted(txy, key=lambda x:(x[0]))

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

for i in range(1, N+1):
    if stxy[i][0] - stxy[i-1][0] < abs(stxy[i][1]-stxy[i-1][1]) + abs(stxy[i][2]-stxy[i-1][2]):
        print("No")
        exit()
    elif (stxy[i][0] - stxy[i-1][0] - (abs(stxy[i][1]-stxy[i-1][1]) + abs(stxy[i][2]-stxy[i-1][2])))%2 == 1:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

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

flag = True
for i in range(1,n+1):

    if (t[i]-t[i-1])%2 != (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 or (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))>t[i]-t[i-1]:
        flag = False


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

Submission status: Accepted

Solution code:
n = int(input())
plcs = [list(map(int,input().split())) for _ in range(n)]
A = [0, 0, 0]
for i in range(n):
    A = [plcs[i][j] - A[j] for j in range(3)]
    if A[0] >= abs(A[1]) + abs(A[2]) and plcs[i][0] % 2 == (abs(plcs[i][1]) + abs(plcs[i][2])) % 2:
        continue
    else:
        print('No')
        exit()
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())
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):
    time=t[i]-t[i-1]
    trip=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if time<trip:
        print("No")
        exit()
    else:
        extra=time-trip
        if extra%2!=0:
            print("No")
            exit()

print("Yes")