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:
import sys

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

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
import math
from itertools import accumulate as acc
input=sys.stdin.readline
N=int(input())
a=[[0,0,0]]+[list(map(int,input().split())) for i in range(N)]

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
import math
from itertools import accumulate as acc
input=sys.stdin.readline
N=int(input())
a=[[0,0,0]]+[list(map(int,input().split())) for i in range(N)]

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0: print("No"),sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
# ARC089C - Traveling (ABC086C)
n = int(input())
for _ in range(n):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y) % 2 != 0:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
t,x,y=0,0,0
ans='Yes'
for i in range(n):
    s,a,b=map(int,input().split())
    if abs(x-a)+abs(y-b)<=s-t and (a-x+y-b-s+t)%2==0:
        0
    else:
        ans='No'
        break
    t,x,y=s,a,b

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
bt,bx,by = 0,0,0
for i in range(N):
    t,x,y = inpl()
    dt = t-bt
    dx,dy = abs(x-bx),abs(y-by)
    if dx+dy > dt:
        print('No')
        exit()
    else:
        if (dt - (dx+dy)) %2 != 0:
            print('No')
            exit()
    bt,bx,by = t,x,y

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
li=[[int(it) for it in input().split()] for i in range(N)]

to,ao,bo=0,0,0
flag = "Yes"
for tn,an,bn in li:
  dt = tn-to
  dr = abs(an-ao)+abs(bn-bo)
  if (dt<dr):
    flag = "No"
  if (dr%2!=dt%2):
    flag = "No"
  to,ao,bo=tn,an,bn
print (flag)

Submission status: Accepted

Solution code:
N = int(input())
tnow = 0
xnow = 0
ynow = 0
flag = 1
for i in range(N):
  t, x, y = map(int, input().split())
  cost = abs(x-xnow)+abs(y-ynow)
  if cost <= t - tnow and (t-tnow-cost)%2==0:
    tnow = t
    xnow = x
    ynow = y
    continue
  else:
    flag = 0
    break
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N=int(input())
travel=[[0,0,0]]+[ list(map(int,input().split(' '))) for i in range(N) ]
ans='Yes'
for i in range(N):
  dt = travel[i+1][0]-travel[i][0]
  dx = abs(travel[i+1][1]-travel[i][1])
  dy = abs(travel[i+1][2]-travel[i][2])
  if dx+dy<=dt and (dx+dy)%2==dt%2:
    continue
  else:
    ans='No'
    break
print(ans)

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

prev = [0, 0, 0]
for step in steps:
    t, x, y = step
    diff = abs(x - prev[1]) + abs(y - prev[2])
    time = t - prev[0]
    if diff > time or (time - diff) % 2 > 0:
        print('No')
        sys.exit()
    prev = [t, x, y]

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
last = [0,0,0]
for i in range(N):
    ti,xi,yi = map(int,input().split())
    a = ti-last[2] - (abs(xi-last[0])+abs(yi-last[1]))
    if a >= 0  and a % 2 == 0:
        flag = True
    else:
        flag = False
        break
    last = [xi,yi,ti]
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
tmp = [[int(i) for i in input().split()] for i in range(N)]
tmp.insert(0, [0, 0, 0])
ans = 'Yes'

for i in range(N):
    t = tmp[i+1][0] - tmp[i][0]
    dx = abs(tmp[i+1][1] - tmp[i][1])
    dy = abs(tmp[i+1][2] - tmp[i][2])
    d = dx + dy
    if t < d \
    or t % 2 != d % 2:
        ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    T, X, Y = 0, 0, 0
    for _ in range(N):
        t, x, y = list(map(int, input().split()))
        dx = abs(x - X)
        dy = abs(y - Y)
        dt = t - T
        if (dx + dy) % 2 != dt % 2:
            print('No')
            return
        if dx + dy > dt:
            print('No')
            return
        T, X, Y = t, x, y
    print('Yes')

main()

Submission status: Accepted

Solution code:
n=int(input())
x=[[0,0,0]]+[list(map(int,input().split()))for i in range(n)]
y=[]
for i in range(n):
    s,t,r=x[i+1]
    q,p,w=x[i]
    temp=s-q
    abso=abs(t-p)+abs(r-w)
    if temp<abso or (temp%2!=abso%2):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import math
n = int(raw_input())

xy = [[0, 0, 0]]
for _ in xrange(n):
	xy.append([int(x) for x in raw_input().split()])

flag = True
for i  in xrange(0, n):
	t1, x1, y1 = xy[i]
	t2, x2, y2 = xy[i+1]
	xx = (t2-t1) - math.fabs(x2-x1) - math.fabs(y2-y1)
	if xx  < 0:
		flag = False
		break
	if xx % 2 != 0:
		flag = False
		break
if flag:
	print 'Yes'
else:
	print 'No'

Submission status: Accepted

Solution code:
n=int(input())
now=(0,0,0)
result=True
for i in range(n):
    t,a,b=[int(i) for i in input().split()]
    time=t-now[0]
    x=abs(a-now[1])
    y=abs(b-now[2])
    if (x+y-time)%2!=0 or (x+y)>time:
        result=False
    else:
        now=(t,a,b)
if result:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

ans="Yes"
for i in range(N):
        n=abs(t[i][1][0]-t[i+1][1][0])+abs(t[i][1][1]-t[i+1][1][1])
        if(n%2!=(t[i+1][0]-t[i][0])%2 or n>(t[i+1][0]-t[i][0])):
                ans="No"

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=[list(map(int,input().split()))for i in range(n)]
s.insert(0,[0,0,0])
p=0
for i in range(n):
    c=s[i+1][0]-s[i][0]
    d=abs(s[i+1][1]-s[i][1])+abs(s[i+1][2]-s[i][2])
    if c<d or (c-d)%2==1:
        p=1
        break
print("No" if p==1 else "Yes")

Submission status: Accepted

Solution code:
z = int(input())
x = 0
y = 0
t = 0
for i in range(z):
    s,a,b = map(int,input().split(" "))
    if s - t < abs(a-x) + abs(b-y):
        print("No")
        exit()
    elif (s - t) % 2 == 1 and (abs(a-x) + abs(b-y)) % 2 == 0:
        print("No")
        exit()
    elif (s - t) % 2 == 0 and (abs(a-x) + abs(b-y)) % 2 == 1:
        print("No")
        exit()
    else:
        x = a
        y = b
        t = s
print("Yes")

Submission status: Accepted

Solution code:
import sys
N = input()
p_t, p_x, p_y = 0, 0, 0
for _ in range(N):
    c_t, c_x, c_y = map(int, raw_input().split())
    if not c_t - p_t >= abs(c_x - p_x) + abs(c_y - p_y) or \
        not (c_t - p_t) % 2 == (abs(c_x - p_x) + abs(c_y - p_y)) % 2:
        print "No"
        sys.exit()
    p_t, p_x, p_y = c_t, c_x, c_y
print "Yes"

Submission status: Accepted

Solution code:
N = int(input())
txy = [input() for i in range(N)]
now_pos = [0, 0]
now_time = 0
fail_flag = False
for i in range(N):
    t, x, y = map(int, txy[i].split(' '))
    if (x+y) % 2 != t % 2:
        fail_flag = True
    distance = (abs(now_pos[0]-x) + abs(now_pos[1]-y))
    if distance > t-now_time:
        fail_flag = True
    if fail_flag:
        print('No')
        exit()
    now_pos = [x,y]
    now_time = t
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txy = [input() for i in range(N)]
now_pos = [0, 0]
now_time = 0
fail_flag = False
for i in range(N):
    t, x, y = map(int, txy[i].split(' '))
    if (x+y) % 2 != t % 2:
        fail_flag = True
    distance = (abs(now_pos[0]-x) + abs(now_pos[1]-y))
    if distance > t:
        fail_flag = True
    if fail_flag:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def mhd(sx, sy, tx, ty):
    return(abs(sx-tx)+abs(sy-ty))
def inpl(): return [int(i) for i in input().split()]

N = int(input())
Sx, Sy, St = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    Tt, Tx, Ty = inpl()
    if mhd(Sx, Sy, Tx, Ty) > Tt-St or (mhd(Sx, Sy, Tx, Ty) - Tt + St) % 2:
        ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
N=int(input().strip())
t=[]
x=[]
y=[]
for i in range(N):
    tm, xm, ym=map(int,input().strip().split(' '))
    t.append(tm)
    x.append(xm)
    y.append(ym)
tn=0
xn=0
yn=0
fl=True
for i in range(N):
    tn=t[i]-tn
    xn=x[i]-xn
    yn=y[i]-yn
    #print(tn,xn,yn)
    if tn<abs(xn)+abs(yn) or tn%2!=(xn+yn)%2:
        fl=False
        break
if fl:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
s,a,b = 0,0,0
f = True
for _ in [0]*n:
  t,x,y = map(int,input().split())
  p = t-s-(abs(x-a)+abs(y-b))
  if p%2 == 1 or p<0:
    f = False
  s,a,b = t,x,y
print("Yes" if f else "No")

Submission status: Accepted

Solution code:
n = int(input())
s,a,b = 0,0,0
f = True
for _ in [0]*n:
  t,x,y = map(int,input().split())
  p = t-s-(abs(x-a)+abs(y-b))
  if p%2 == 1 or p<0:
    f = False
print("Yes" if f else "No")

Submission status: Accepted

Solution code:
import sys

def chk1(t, x, y):
    return t % 2 == (x + y) % 2
def chk2(t, x, y):
    return t >= abs(x) + abs(y)
def chk(t, x, y):
    return chk1(t, x, y) and chk2(t, x, y)

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):
    dt, dx, dy = T[i] - T[i - 1], X[i] - X[i - 1], Y[i] - Y[i - 1]
    if not chk(dt, dx, dy):
        print('No')
        sys.exit(0)
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

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


def isReachable(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
    else:
        return False


ret = True
for i in range(0, N):
    t1, x1, y1 = list[i]
    t2, x2, y2 = list[i + 1]
    b = isReachable(t1, x1, y1, t2, x2, y2)
    if b == False:
        ret = False
        break

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

Submission status: Accepted

Solution code:
N = int(input())

t0, x0, y0 = 0, 0, 0
judge = "Yes"

for i in range(N):
	t, x, y = list(map(int, input().split()))
	if abs(x - x0) + abs(y - y0) <= t - t0 and (abs(x - x0) + abs(y - y0) - (t - t0)) % 2 == 0:
		x0 = x
		y0 = y
		t0 = t
	else:
		judge = "No"
		break

print(judge)

Submission status: Accepted

Solution code:
N = int(input())
st, sx, sy = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - st
    dr = abs(x - sx) + abs(y - sy)
    if not (dt >= dr and (dt - dr) % 2 == 0):
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t0,x0,y0 = 0,0,0
for _ in range(N):
    t1,x1,y1 = list(map(int, input().split()))
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    dis = abs(x)+abs(y)
    if dis<=t and (dis-t)%2 == 0:
        t0, x0, y0 = t1,x1,y1
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

t0 = 0
x0 = 0
y0 = 0

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

    d = abs(x - x0) + abs(y - y0)
    if t - t0 < d or ((t - t0) - d) % 2:
        print('No')
        exit()

    t0 = t
    x0 = x
    y0 = y

print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8

def md(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

MI = lambda: map(int, input().split())

def main():
    N = int(input())
    t, x, y = 0, 0, 0
    for i in range(N):
        tn, xn, yn = MI()
        tr = tn - t - md(x, y, xn, yn)
        if tr < 0 or tr % 2:
            return "No"
    return "Yes"


if __name__ == "__main__":
    print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def manhattanDist(p1, p2):
    (x1, y1) = p1
    (x2, y2) = p2
    return abs(x1-x2) + abs(y1-y2)

N = int(input())
ans = "Yes"
now = 0
(nx, ny) = (0, 0)
for _ in range(N):
    t, x, y = map(int, input().split())
    d = manhattanDist((nx, ny), (x, y))
    sa = t - now
    if d <= sa and (sa-d) % 2 == 0:
        ()
    else:
        ans = "No"
        break

    now = t
    nx = x
    ny = y

    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

t_org = 0
x_org = 0
y_org = 0
i = 0

for row in range(N):
    INPUT = input()
    t = int(INPUT.split( )[0])
    x = int(INPUT.split( )[1])
    y = int(INPUT.split( )[2])
    
    if t - t_org >= (x - x_org) + (y - y_org) and (t - t_org - (x - x_org) - (y - y_org)) % 2 == 0:
        t_org = t
        x_org = x
        y_org = y
        i += 1
    else:
        break

if i == N:
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
ans = 'Yes'
m = []
t_last = x_last = y_last = 0
N = int(input())
for i in range(0, N):
  m.append(list(map(int, input().split())))

for l in m:
  t = abs(l[0] - t_last)
  mv = abs(l[1] - x_last) + abs(l[2] - y_last)
  if mv > t or (t - mv) % 2 != 0 :
    ans = 'No'
    break
  t_last=l[0]
  x_last=l[1]
  y_last=l[2]


print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print("Yes")

Submission status: Accepted

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

ans = 'Yes'
if a[0][0] < abs(a[0][1])+abs(a[0][2]) or (a[0][0]-abs(a[0][1])-abs(a[0][2]))%2 == 1:
    ans = 'No'
for i in range(n-1):
    if (a[i+1][0]-a[i][0]) < (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])):
        ans = 'No'
    if (a[i+1][0]-a[i][0]-abs(a[i+1][1]-a[i][1])-abs(a[i+1][2]-a[i][2]))%2!=0:
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
lx = 0
ly = 0
lt = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    dt = t - lt
    dx = abs(x - lx)
    dy = abs(y - ly)
    dxy = dx + dy
    if dxy > dt:
        print('No')
        exit()
    elif (dt - dxy) % 2 == 1:
        print('No')
        exit()
    lx = x
    ly = y
    lt = t
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

isok = True
x_now = 0
y_now = 0
t_now = 0
for i in range(N):
    t,x,y = map(int,input().split())
    c = t-t_now
    l = abs(x-x_now)+abs(y-y_now)
    if c%2!=l%2 or c<l:
        isok=False
    x_now = x
    y_now = y
    t_now = t
    
if isok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque

num = int(input())

to_num = lambda x : [int(i) for i in input().split(' ')]

masume = {}
for i in range(num):
    line = to_num(1)
    for l in range(len(line)):
        masume[line[0]] = (line[1], line[2])

masume_deque = deque(list(masume.keys()))
pre_pos = (0, 0)
pre_times = 0
for index in range(num):
    cur_times = masume_deque[index]
    cur_pos = masume[cur_times]
    distance = sum([abs(cur_pos[i]-pre_pos[i]) for i in [0, 1]])
    times = abs(cur_times - pre_times)
    if distance % 2 != times % 2 or distance > times:
        ans = False
        break
    else:
        ans = True
    pre_pos = cur_pos
    pre_times = cur_times
    
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def dist(a,b,c,d):
    return abs(a-c)+abs(b-d)

n=int(input())
nx,ny=0,0
now=0
for i in range(n):
    t,x,y=map(int,input().split())
    if t-now>=dist(nx,ny,x,y) and (dist(nx,ny,x,y)-(t-now))%2==0:
        nx,ny=x,y
        now=t
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
ans = True
tprev = 0
xprev = 0
yprev = 0
for _ in range(N):
    tnow,xnow,ynow = list(map(int,input().split()))
    time = abs(xnow-xprev) + abs(ynow-yprev)
    if time > tnow-tprev or (tnow-tprev-time)%2 == 1:
        ans = False
        break
    tprev = tnow
    xprev = xnow
    yprev = ynow
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
def travel(xs,ys,xf,yf,t):
    d=abs(xf-xs)+abs(yf-ys)
    if d>t:
        return False
    else:
        if d%2==t%2:
            return True
        else:
            return False

N=int(input())
txy=[[0,0,0]]
for i in range(N):
    txy.append([int(j) for j in input().split(" ")])

for i in range(N):
    if travel(txy[i][1],txy[i][2],txy[i+1][1],txy[i+1][2],txy[i+1][0]-txy[i][0])==False:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

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

step = 0
start = (0, 0)
for g in goals:
    s = g[0] - step
    d = abs(g[1] - start[0]) + abs(g[2] - start[1])

    if s < d or s % 2 != d % 2:
        print('No')
        break

    step = g[0]
    start = (g[1], g[2])
else:
    print('Yes')

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())
    dt = abs(ti-t)
    dr = abs(xi-x) + abs(yi-y)
    if dt < dr or (dt-dr)%2 == 1 :
        print('No')
        exit()
    else :
        t = ti
        x = xi
        y = yi
else :
    print('Yes')

Submission status: Accepted

Solution code:
def solve(plan, N):
    """

    :param plan: [time, x, y]
    :param N: number of plan
    :return: 'Yes' or 'No'
    """
    time = 0
    posi = [0,0]
    for i in range(N):
        next = plan[i][1:]
        dist = abs(next[0]-posi[0])+abs(next[1]-posi[1])
        if dist > plan[i][0] - time:
            return 'No'
        elif (plan[i][0] - time - dist) % 2 == 1 :
            return 'No'
        posi=next[:]
        time=plan[i][0]

    return 'Yes'

if __name__ == '__main__':
    N = int(input())

    plan = []
    for i in range(N):
        plan.append(list(map(int, input().split(' '))))

    plan.sort(key=lambda x: x[0])
    print(solve(plan, N))

Submission status: Accepted

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

time = 0;_x = 0;_y = 0

for i in range(N):
    t, x, y = map(int, input().split())
    time = t - time
    dis = abs(_x - x) + abs(_y - y)
    if dis == time:
        time, _x, _y = t, x, y
    elif dis < time and (time - dis) % 2 == 0:
        time, _x, _y = t, x, y
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = input()
tt, xx, yy = 0, 0, 0
for i in range(n):
	t, x, y = map(int, raw_input().split())
	d = abs(x - xx) + abs(y - yy)
	if d > t - tt or (d + t - tt) % 2 > 0:
		print 'No'
		exit()
	tt, xx, yy = t, x, y
print 'Yes'

Submission status: Accepted

Solution code:
import math

n = int(input())
t = 0
x = 0
y = 0
ans = "Yes"

for i in range(n):
    t1 = t
    x1 = x
    y1 = y
    t, x, y = map(int,input().split(' '))

#    print(t, x, y)

    td = abs(t - t1)
    xd = abs(x - x1)
    yd = abs(y - y1)

#    print(td, xd, yd)

    if xd + yd > td:
        ans = "No"
        break
    
    if ( xd + yd ) % 2 != td %2:
        ans = "No"
        break

print(ans)

Submission status: Accepted

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

def HammingDist(p1,p2):
  xd = abs(p1[0]-p2[0])
  yd = abs(p1[1]-p2[1])
  return xd+yd
def check(time,dist):
  if (dist > time):
    return False
  elif ((time - dist) % 2 == 0):
    return True
  else:
    return False

flag = 0
length = len(l)

for i in range(length-1):
  if not check(l[i+1][0] - l[i][0], HammingDist(l[i][1],l[i+1][1])):
    flag = 1

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

Submission status: Accepted

Solution code:
#arc089c
import sys

def yn(s,x,y):
 r=abs(x)+abs(y)
 if s>=r and (s-r)%2==0:
  return True
 else:
  return False

n=int(raw_input())
s0,x0,y0=map(int,raw_input().split())
if yn(s0,x0,y0)==False:
 print 'No'
 sys.exit()
for i in xrange(n-1):
 s,x,y=map(int,raw_input().split())
 if yn(s-s0,x-x0,y-y0)==False:
  print 'No'
  sys.exit()
 s0,x0,y0=s,x,y
print 'Yes'

Submission status: Accepted

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	cx = 0; cy = 0
	prev_t = 0

	for i in range(I()):
		t, dist_x, dist_y = LI()

		diff = abs(dist_x - cx) + abs(dist_y - cy)		
		spend_time = t - prev_t


		if spend_time >= diff and (spend_time - diff)%2 == 0:
			f = True
		else:
			f = False
			break

		prev_t = t
		cx = dist_x
		cy = dist_y
	
	if f:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    b_t = 0
    b_x = 0
    b_y = 0
    flg = True
    for _ in range(N):
        a_t, a_x, a_y = map(int, input().split())
        spend_time = a_t - b_t
        distance = abs(a_x - b_x) + abs(a_y - b_y)
        if spend_time >= distance and (distance - spend_time) % 2 == 0:
            continue
        else:
            flg = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = input()
ipts = [map(int,raw_input().split(" ")) for i in range(N)]

def solve():
    x,y = 0,0
    pt = 0
    for i in range(N):
        t,nx,ny = ipts[i]
        mv = abs(nx-x) + abs(ny-y)
        mt = t - pt
        
        if mv > mt:
            print "No"
            return
        if (mv - mt)%2:
            print "No"
            return
        x,y = nx,ny
        pt = t

    print "Yes"
            
        

solve()

Submission status: Accepted

Solution code:
def test(n,t,x,y):
	for i in range(n-1):
		t1=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
		t2=t[i+1]-t[i]
		if (t1>t2 or (t2-t1)%2): return 0
	return 1
def main():
	n=int(input())
	n+=1
	t=[0]*n
	x=[0]*n
	y=[0]*n
	for i in range(1,n):
		t[i],x[i],y[i]=map(int,input().split())
	if (test(n,t,x,y)): print("Yes")
	else: print("No")
main()

Submission status: Accepted

Solution code:
def check(dt, dl):
    if dt < dl:
        return False
    left = dt - dl
    return left % 2 == 0

N = int(input())
t, x, y = 0, 0, 0
for n in range(N):
    ti, xi, yi = map(int, input().split())
    dt = ti - t
    dx = xi - x
    dy = yi - y

    if not check(dt, abs(dx) + abs(dy)):
        print('No')
        exit(0)

    t, x, y = ti, xi, yi
print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def pred(t, x, y):
    return x + y <= t and (x + y - t) % 2 == 0
result = True
t, x, y = 0, 0, 0
for _ in range(int(input())):
    nt, nx, ny = map(int, input().split())
    if not pred(nt - t, abs(nx - x), abs(ny - y)):
        result = False
        break
    t, x, y = nt, nx, ny
print(['No', 'Yes'][result])

Submission status: Accepted

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


def f(poss):
    lastPos = (0, 0, 0)

    for pos in poss:
        t = pos[0] - lastPos[0]
        d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])
        lastPos = pos

        if t < d or (t-d)%2 != 0:
            return False

    return True



def main():
    n = int(input())
    poss = [tuple(map(int, input().split())) for i in range(n)]

    print('Yes' if f(poss) else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
x0, y0, t0 = 0, 0, 0
result = True
for i in range(n):
    t, x, y = map(int, raw_input().split())
    left = t - t0 - abs(x - x0) - abs(y - y0)
    if left < 0 or left % 2 != 0:
        result = False

if result:
    print "Yes"
else:
    print "No"

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**15
mod = 10**9+7

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 S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [[0,0,0]] + sorted([LI() for _ in range(n)])
    for i in range(n):
        t1,x1,y1 = a[i]
        t2,x2,y2 = a[i+1]
        sa = abs(x1-x2) + abs(y1-y2)
        ts = t2 - t1
        if ts < sa or (ts+sa) % 2 == 1:
            return 'No'

    return 'Yes'

print(main())

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N=int(input())
a4=[[0,0,0]]
for i in range(N):
    t,x,y=[int(i) for i in input().split()]
    #例えば[-y,x]とかにして正負とか左右とか入れ替えも可能です
    a4.append([t,x,y])
flag = 0

#print(a4)


for i in range(N):
    dist = abs(a4[i+1][1] - a4[i][1]) + abs(a4[i+1][2] - a4[i][2])
    tdist = a4[i+1][0] - a4[i][0]
 #   print(dist)
    if dist > tdist or  (dist - tdist)%2 == 1:
        flag = -1
#        print('FNO')

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

Submission status: Accepted

Solution code:
n = int(input())

t_now = 0
p = (0,0)
ans = True

for _ in range(n):
    t,x,y = map(int,input().split())
    td = t - t_now
    d = abs(p[0]-x) + abs(p[1]-y)
    tmp = td - d
    if tmp >= 0 and tmp % 2 == 0:
        t_now = t
        p = (x,y)
        continue
    else:
        ans = False
        break

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

Submission status: Accepted

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

n = int(raw_input())

t = [0 for i in range(n)]
x = [0 for i in range(n)]
y = [0 for i in range(n)]

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

flag = True

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

	if dt < dx + dy:
		flag = False
		break
	else:
		if (dt - (dx + dy)) % 2 == 1:
			flag = False
			break

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

Submission status: Accepted

Solution code:
import sys


N = int(input())
#print(N)
#a = list(map(int, input().split()))
t = []
x = []
y = []
flag = 0

for i in range(0,N):
    line = input().split()
    t0 = int(line[0])
    x0 = int(line[1])
    y0 = int(line[2])
    if len(t)>0:
        if ((t0-t[i-1])-(x0-x[i-1])-(y0-y[i-1])) % 2 != 0:
        #if ((t0-t[i-1])-(x0-x[i-1])-(y0-y[i-1])) % 2 != 0 or ((abs(t0-t[i-1])-abs(x0-x[i-1])-abs(y0-y[i-1])) > 0:
            flag = 1
        if (abs(t0-t[i-1])-abs(x0-x[i-1])-abs(y0-y[i-1])) < 0:
            flag = 1
    else:
        if t0 - x0 -y0 <0:
            flag = 1

    t.append(t0)
    x.append(x0)
    y.append(y0)
    #print(line[0])



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