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:
def acceptable(t, a, b, t_next, a_next, b_next):
    distance = abs(a_next - a) + abs(b_next - b)

    if (t_next - t) < distance:
        return False

    if (t_next - t) % 2 != distance % 2:
        return False

    return True


n = int(input())
t_next, a_next, b_next = 0, 0, 0
for i in range(n):
    t, a, b = t_next, a_next, b_next
    t_next, a_next, b_next = map(int, input().strip().split())

    if not acceptable(t, a, b, t_next, a_next, b_next):
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

Solution code:
import numpy as np
N=int(input())
x_origin=0
y_origin=0
t_origin=0
flag=0
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))

for i in range(N):
    b=np.abs(a[i][0]-t_origin)
    c=np.abs(a[i][1]-x_origin)
    d=np.abs(a[i][2]-y_origin)
    if b>=c+d:
        if (b-(c+d))%2==0:
            continue
        else:
            flag=1
            break
    else:
        flag=1
        break
if flag==1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
ts=[]; xs=[]; ys=[]

for i in range(n):
    t,x,y = map(int,input().split())
    ts.append(t); xs.append(x); ys.append(y)

flag=1
for i in range(n):
    t = ts[i]
    d = abs(xs[i]) + abs(ys[i])
    if t>=d and (t-d)%2==0: continue
    else: flag=0; break

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

Submission status: Accepted

Solution code:
def c_Traveling(N, P):
    t_old = x_old = y_old = 0
    for t, x, y in P:
        t1 = t - t_old
        x1 = x - x_old
        y1 = y - y_old
        cond1 = abs(x1) + abs(y1)
        cond2 = t1 % 2
        cond3 = cond1 % 2
        if t1 >= cond1 and cond2 == cond3:
            pass
        else:
            return 'No'
        t_old, x_old, y_old = t, x, y
    return 'Yes'

N = int(input())
P = [[int(i) for i in input().split()] for j in range(N)]
print(c_Traveling(N, P))

Submission status: Accepted

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

    _t, _x, _y = 0, 0, 0
    for t, x, y in txy:
        ok = False
        diff_t = t - _t
        diff_x = x - _x
        diff_y = y - _y

        dx = abs(diff_x)
        dy = abs(diff_y)
        if diff_t >= dx + dy:
            rem = dx + dy - diff_t
            if rem % 2 == 0:
                ok = True
                _t, _x, _y = t, x, y

        if not ok:
            print("No")
            return

    print("Yes")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
def dist(x1,y1,x2,y2):
    return abs(y1-y2)+abs(x1-x2)
result = "Yes"
pre_t,pre_x,pre_y = (0,0,0)
for i in range(n):
    tmp_t,tmp_x,tmp_y = map(int,input().split())
    if (dist(pre_x,pre_y,tmp_x,tmp_y) > tmp_t - pre_t) or ((dist(pre_x,pre_y,tmp_x,tmp_y)-(tmp_t - pre_t))%2!=0):
        result = "No"
    pre_t,pre_x,pre_y = tmp_t,tmp_x,tmp_y
print(result)

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)
def check(t,x,y):
    if t < x+y:
        return False
    elif (x+y-t)%2==0:
        return True
    else:
        return False
for i in range(N):
    if check(T[i+1]-T[i],abs(X[i+1]-X[i]),abs(Y[i+1]-Y[i])):
        pass
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

X =list()

Y = 0

for i in range(0,N):
    X.append(list(map(int,input().strip().split(' '))))

if (X[0][1]+X[0][2]-X[0][0])%2 == 0 and X[0][1]+X[0][2] <= X[0][0]:
    for i in range(0,N-1):
        T = X[i+1][0]-X[i][0]
        A = X[i+1][1]-X[i][1]
        B = X[i+1][2]-X[i][2]
        if (A+B-T)%2 == 0 and A+B <= T:
            Y = Y
        else:
            Y += 1
    if Y == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    while 1:
        try:
            n = int(input())
            T, X, Y = [], [], []
            for _ in range(n):
                tmp1, tmp2, tmp3 = LI()
                T.append(tmp1)
                X.append(tmp2)
                Y.append(tmp3)

            T.insert(0, 0)
            X.insert(0, 0)
            Y.insert(0, 0)
            for i in range(n):
                if X[i + 1] == X[i] and Y[i + 1] == Y[i]:
                    raise EndLoop
                time = T[i + 1] - T[i]
                dis = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
                if not ((time == dis) or (time > dis and (time - dis) % 2 == 0)):
                    raise EndLoop

            print("Yes")
            break
        except:
            print("No")
            break


solve()

Submission status: Accepted

Solution code:
import math
def get_while(n):
    ts = [0]
    ans = [[0, 0]]
    for _ in range(n):
        s = list(map(lambda x: int(x), input().split(" ")))
        ts.append(s[0])
        ans.append([s[1], s[2]])
    return ts, ans

def get_distance(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

def solve(ts, ps, n):
    for x in range(n):
        d = get_distance(ps[x], ps[x+1])
        if ((ts[x+1] - ts[x]) - d) < 0:
            return "No"
        if ((ts[x+1] - ts[x]) - d) % 2 != 0:
           return "No"
    return "Yes"
        

if __name__ == '__main__':
    n = int(input())
    ts, ps = get_while(n)
    print(solve(ts, ps, n))

Submission status: Accepted

Solution code:
n=int(input())
l=[]
l.append([0,0,0])
f=0
for i in range(n):
    ll=list(map(int,input().split()))
    l.append(ll)
for i in range(n):
    dt=abs(l[i][0]-l[i+1][0])
    da=abs(l[i][1]-l[i+1][1])
    db=abs(l[i][2]-l[i+1][2])
    if dt<da+db:
        f=1
    if dt==0 and da+db!=0:
        f=1
    if (da+db)%2 != (dt)%2 and dt>da+db:
        f=1
if f==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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())

ans = True
for i in range(N):
    dt = t[i + 1] - t[i]
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dl > dt or (dl <= dt and dl % 2 != dt % 2):
        ans = False

print(('No', 'Yes')[ans])

Submission status: Accepted

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

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

current_t = 0
current_x = 0
current_y = 0

flag = True

for i in range(N):
    dist = (X[i] - current_x) + (Y[i] - current_y)
    time = T[i] - current_t
    if dist > time:
        flag = False
        break
    elif (time - dist)%2 != 0:
        flag = False
        break
    else:
        current_t = T[i]
        current_x = X[i]
        current_y = Y[i]
        
if flag == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

#for i in range(N):
#	print(t[i],x[i],y[i], file=sys.stderr)

def solve(px,py,i,pt):
	global t, x, y
	diff = abs(x[i] - px) + abs(y[i] - py)
	if diff <= t[i] - pt:
		return True
	else:
		return False

ok = True
for i in range(N):
	shortest_time = 0
	if i == 0:
		if solve(0,0,i,0) == True:
			shortest_time = abs(x[i]) + abs(y[i])
		else:
			ok = False
			break
	else:
		if solve(x[i-1],y[i-1],i,shortest_time) == True:
			shortest_time = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
		else:
			ok = False
			break
#	print("shortest_time:", shortest_time, file=sys.stderr)

if ok == True:
	for i in range(N):
		if t[i] % 2 != ((x[i] + y[i]) % 2):
			ok = False


print("Yes" if ok == True else "No")

Submission status: Accepted

Solution code:
n=int(input())
t=[0 for i in range(n)]
x=[0 for i in range(n)]
y=[0 for i in range(n)]
count=1
for i in range(n):
    t[i],x[i],y[i]=[int(i) for i in input().split()]

x_a=abs(x[0])
y_a=abs(y[0])

if t[0]%2==(x_a+y_a)%2 and t[0]>=(x_a+y_a):
    for i in range(n-1):
        x_a=abs(x[i+1]-x[i])
        y_a=abs(y[i+1]-y[i])
        if (t[i+1]-t[i])%2==(x_a+y_a)%2 and (t[i+1]-t[i])>=(x_a+y_a):
            count=1
        else:
            count=0
            break
else:
    count=0


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

Submission status: Accepted

Solution code:

import math

N = int(input())

flag = True
currentt = 0
currentx = 0
currenty = 0

for i in range(N):
    tmp = input().split()
    nextt = int(tmp[0])
    nextx = int(tmp[1])
    nexty = int(tmp[2])
    
    subt = nextt - currentt
    subx = abs(nextx - currentx)
    suby = abs(nexty - currenty)

    if (subx + suby) > subt:
        flag = False
    
    tmp = subt - (subx + suby)
    if tmp % 2 == 1:
        flag = False

    currentt = nextt
    currentx = nextx
    currenty = nexty


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

Submission status: Accepted

Solution code:
import numpy as np


def check(t_diff, x_diff, y_diff):
    l1 = abs(x_diff) + abs(y_diff)
    if l1 > t_diff:
        return False
    elif (t_diff - l1) % 2 == 1:
        return False
    else:
        return True

N = int(input())
t = np.zeros(N+1,)
x = np.zeros(N+1,)
y = np.zeros(N+1,)
for i in range(N+1):
    if i != 0:
        t[i], x[i], y[i] = tuple(map(int, input().split()))

for j in range(N):
    t_diff = t[j+1] - t[j]
    x_diff = x[j+1] - x[j]
    y_diff = y[j+1] - y[j]
    if not check(t_diff, x_diff, y_diff):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())						# 5

T=[0]
X=[0]
Y=[0]

for i in range(N):
	t, x, y = map(int, input().split())		# 5 7 2
	T.append(t)
	X.append(x)
	Y.append(y)

#print(T)
#print(X)
#print(Y)

x0 = 0
y0 = 0
ans = 'No'
#ans = 'No_0'

#時間的に移動可能か？ →
# 秒数の差、距離、残り秒数
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])
	
	# 時間に対して距離が遠い
	if t < (x+y):
		#ans = "No_1"
		break
	
	#
	a = t - (x+y)
	if a%2==0:
		continue
	else:
		#ans = "No_2"
		break

else:
	ans='Yes'


print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    T = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    for t, x, y in T:
        if t < x + y or t & 1 != (x + y) & 1:
            print('No')
            break
    else:
        print('Yes')

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

t_pre = 0
x_pre = 0
y_pre = 0

cond = True
for i in range(N):
    t, x, y = map(int, input().split(' '))
    
    d = abs(x - x_pre) + abs(y - y_pre)
    
    if d > t:
        cond = False
        break         
        
    if (d % 2 == 0 and (t - t_pre) % 2 == 0) or (d % 2 == 1 and (t - t_pre) % 2 == 1):
        t_pre = t
        x_pre = x
        y_pre = y         
    
    else:
        cond = False
        break 


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

Submission status: Accepted

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

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

for i in range(1, N+1):
    def_t = a[i][0] - a[i-1][0]
    def_d = abs(a[i][1] - a[i-1][1]) + abs(a[i][2] - a[i-1][2])
    if abs(def_t - def_d) % 2 != 0 or def_t < def_d:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
flag = 0
for i in range(n):
    t_in, x_in, y_in = map(int, input().split())
    time_dis = t_in - t
    move_dis = abs(x_in-x) + abs(y_in-y)
    if time_dis < move_dis:
        flag = -1
    elif abs(move_dis - time_dis) % 2 == 1:
        flag = -1
    else:
        t, x, y = t_in, x_in, y_in

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

Submission status: Accepted

Solution code:
n = int(input())
aa = [[0, 0, 0]]

for i in range(n):
    aa.append(list(map(int, input().split())))


def get_distance(a1, a2):
    return abs(a1[1] - a2[1]) + abs(a1[2] - a2[2])

for i, a in enumerate(aa):
    if i > 0:
        xy_d = get_distance(aa[i], aa[i-1])
        t_d = aa[i][0] - aa[i-1][0]
        if xy_d > t_d or (xy_d - t_d) & 1:
            print('No')
            break
else:
    print('Yes')

Submission status: Accepted

Solution code:
# coding:utf-8                                                                  

N = int(raw_input())

xtmp = 0
ytmp = 0
ttmp = 0
flag = True
allinfo = []
for i in range(N):
    t, x, y = map(int, raw_input().split())
    allinfo.append((t, x, y))

for t, x, y in allinfo:
    xdif = abs(x - xtmp)
    ydif = abs(y - ytmp)
    tdif = t - ttmp
    if tdif >= xdif + ydif:
        if tdif % 2 == (xdif + ydif) % 2:
            continue
        else:
            flag = False
            break
    else:
        flag = False
        break

if flag:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C

import math

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)


def l1_distance(p,q):
    return int(math.fabs(p[0] - q[0]) + math.fabs(p[1] - q[1]))


# first step
if l1_distance([0,0], [X[0],Y[0]]) <= T[0] and (T[0] - l1_distance([0,0], [X[0],Y[0]])) % 2 == 0:
    pass
else:
    print("No")
    quit()

for i in range(N-1):
    if l1_distance([X[i],Y[i]], [X[i+1],Y[i+1]]) <= T[i+1] - T[i] and (T[i+1] - T[i] - l1_distance([X[i],Y[i]], [X[i+1],Y[i+1]])) % 2 == 0:
        pass
    else:
        print("No")
        quit()

print("Yes")

Submission status: Accepted

Solution code:
num = int(input())

base_t = 0
base_x = 0
base_y = 0
judge = True
for i in range(num):
    t, x, y = map(int, input().split())
    if (abs(base_t-t) - abs(base_x-x) +abs(base_y-y)) %2 == 0 and (abs(base_t-t) - abs(base_x-x) -abs(base_y-y)) >= 0:
        base_x = x
        base_y = y
        base_t = t
    else:
        judge = False
        break

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

Submission status: Accepted

Solution code:
import sys
import math




def isEnable(now, next):
    distance = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time_len = next[0] - now[0]

    if distance <= time_len and (time_len - distance) % 2 == 0:
        return True
    else:
        return False


N = int(input())

roots = []

roots.append((0, 0, 0))

for i in range(N):
    r = tuple(map(int, input().split(" ")))
    roots.append(r)

for i in range(N):
    if isEnable(roots[i], roots[i+1]):
        continue
    else:
        print('No')
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
N=input()
prev_x=0
prev_y=0
prev_t=0
a=[]
for i in range(N):
	t,x,y=map(int,raw_input().split())
	l=abs(x-prev_x)+abs(y-prev_y)
	t_diff=t-prev_t
	a.append( (t_diff,l) )
	prev_x=x
	prev_y=y
	prev_t=t


for i,j in a:
	if i>=j and (i-j)%2==0:
		continue
	else:
		print "No"
		quit()
else:
	print "Yes"

Submission status: Accepted

Solution code:
from pprint import pprint as pp
import collections
import math

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

now_t = 0
now_x = 0
now_y = 0

for t, x, y in txy:
  dt = t - now_t
  dx = x - now_x
  dy = y - now_y
  dp = dx + dy
  diff = dt - dp
  if ((diff % 2) == 1) or (diff < 0):
    print('No')
    break
  now_t = t
  now_x = x
  now_y = y
else:
  print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t = []
x = []
y = []
for i in range(n):
	ttemp,xtemp,ytemp = map(int,input().split())
	t.append(ttemp)
	x.append(xtemp)
	y.append(ytemp)
check = True
nowx = 0
nowy = 0
for i in range(n):
	disx = x[i] - nowx
	disy = y[i] - nowy
	total = disx + disy
	if i == 0:
		if t[i] >= total and (t[i]%2 == total%2):
			nowx = x[i]
			nowy = y[i]
		else:
			check = False
			break
	else:
		if (t[i]-t[i-1]) >= total and ((t[i]-t[i-1])%2 == total%2):
			nowx = x[i]
			nowy = y[i]
		else:
			check = False
			break
if check:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
N = int(input())
a = []
a.append([0, 0, 0])
for i in range(N):
    a.append(list(map(int, input().split())))
travel = True
for i in range(N):
    c = abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2])
    if c <= a[i+1][0]-a[i][0] and (a[i+1][0] - a[i][0] - c) % 2 == 0:
        pass
    else:
        travel = False
        break
if travel == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

N = int(input())

tc = 0
xc = 0
yc = 0
ok_flg = 1
for n in range(N):
    t, x, y = map(int, input().split())
    t_diff = tc - t
    x_diff = abs(x - xc)
    y_diff = abs(y - yc)
    xy_diff = x_diff + y_diff
    if t%2 == 0:
        if xy_diff <= t and xy_diff%2 ==0:
            continue
        else:
            ok_flg = 0
    else:
        if xy_diff <= t and xy_diff%2 ==1:
            continue
        else:
            ok_flg = 0
if ok_flg == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
i=0
f = 0
t0,x0,y0 = 0,0,0
while i <N:
    t1,x1,y1 = map(int,input().split(' '))
    dt = int(t1 - t0)
    dl = int(abs(x0-x1)+abs(y0-y1))
    if dt >= dl and int(dt-dl)%2 == 0:
        t0 = t1
        x0 = x1
        y0 = y1
        i += 1
    else:
        f = 1
        break
if f == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())

t_,x_,y_=0,0,0
for _ in range(n):
    t,x,y=map(int,input().split())
    if((((x-x_)+(y-y_)+(t-t_))%2==0)and((abs(x-x_)+abs(y-y_))<=t-t_)):
        t_,x_,y_=t,x,y
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

now_x = 0
now_y = 0
now_time = 0
flag = 0

for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    t.append(ti)
    x.append(xi)
    y.append(yi)

for i in range(N):
    if now_x < x[i]:
        now_time += x[i] - now_x
    else:
        now_time += now_x - x[i]
    now_x = x[i]

    if now_y < y[i]:
        now_time += y[i] - now_y
    else:
        now_time += now_y - y[i]
    now_y = y[i]

    if now_time <= t[i]:
        if (t[i] - now_time) % 2 == 0:
            now_time = t[i]
        else:
            flag = 1
            break
    else:
        flag = 1
        break

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
dt=0
dx=0
dy=0
for i in range(N):
  t,x,y=map(int,input().split())
  t=t-dt
  x=x-dx
  y=y-dy
  if(x+y > t):
    print('No')
    sys.exit()
  if( (x+y)%2==0 and t%2==1 ):
    print('No')
    sys.exit()
  elif( (x+y)%2==1 and t%2==0 ):
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys

N = int(input())
old_t, old_x, old_y = 0, 0, 0

for n in range(N):
    t, x, y = list(map(int, input().split()))
    dist = t - old_t
    shortest = abs(x - old_x) + abs(y - old_y)
    if dist < shortest or (dist - shortest) % 2 != 0:
        print("No")
        sys.exit()
    old_t, old_x, old_y = t, x, y

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t = 0
x = 0
y = 0
f = True
for _ in range(n):
    ti, xi, yi = (int(x) for x in input().split())
    dt = ti - t
    dd = abs(xi - x) + abs(yi - y)
    if dd > dt or (dt-dd)%2 != 0:
        f = False
        break
    else:
        t = ti
        x = xi
        y = yi
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
n=int(input())
y=0
x=1
for i in range(n):
	a=list(map(int,input().split()))
	if(a[1]+a[2]>a[0]):
		x=0
	elif((a[1]+a[2])%2!=a[0]%2):
		x=0
	else:
		y+=1
if(x==0):
	print("No")
elif(x!=0 and y==n):
	print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
r = [(0, 0, 0)]
for _ in range(n):
    t, x, y = [int(x) for x in input().split()]
    r.append((t, x, y))
for i in range(1, len(r)):
    l = abs(r[i][1] - r[i - 1][1]) + abs(r[i][2] - r[i - 1][2])
    t = r[i][0] - r[i - 1][0]
    if l > t or (l - t) % 2 == 1:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math, fractions, collections
# ===================================
flag = 1
st = 0
sx = 0
sy = 0
for _ in range(int(input())):
	t, x, y = [int(x) for x in input().split()]
	dur = abs(t-st)
	dx = abs(x-sx)
	dy = abs(y-sy)
	if(dx+dy > dur):
		flag = 0
	else:
		if((dx+dy)&1 and not(dur&1)):
			flag = 0
		elif(not((dx+dy)&1) and (dur&1)):
			flag = 0
	st = t
	sx = x
	sy = y
print("Yes" if flag else "No")

Submission status: Accepted

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

N = input()
N = int(N)

t_prev = 0
x_prev = 0
y_prev = 0

flag = True
for i in range(N ) : 
    s = input().split(" ")
    s = [int(i) for i in s]
    t = s[0]
    x  =s[1]
    y = s[2]
    
    eq = t - t_prev - abs(x - x_prev) - abs(y - y_prev)
    if eq < 0 : flag = False
    if eq % 2 == 1 : flag = False
    
    t_prev = t
    x_prev = x
    y_prev = y
    
if flag : print("Yes")
else : print("No")

Submission status: Accepted

Solution code:
def main():
  N = int(input())

  moves = []

  for i in range(N):
    moves.append([int(j) for j in input().split()])

  # 移動前
  pre_t = 0
  pre_x = 0
  pre_y = 0

  for move in moves:
    new_t, new_x, new_y = move[0], move[1], move[2]

    # 時刻の差分
    delta_t = new_t - pre_t

    # 位置の差分
    delta_x = abs(new_x - pre_x)
    delta_y = abs(new_y - pre_y)
    delta_sum = delta_x + delta_y

    remain_time = delta_t - delta_sum

    # 移動量と時間が一致
    if remain_time == 0:
      pre_t, pre_x, pre_y = new_t, new_x, new_y

    # 移動量の方が少ない
    elif remain_time > 0:
      # 残り時間が偶数なら行ったり来たりでOK
      if remain_time % 2 == 0:
        pre_t, pre_x, pre_y = new_t, new_x, new_y
      else:
        print("No")
        return

    # 時間が足りない
    else:
      print("No")
      return

  print("Yes")
  return

main()

Submission status: Accepted

Solution code:
import sys

t, x, y = 0, 0, 0
for _ in range(input()):
    [t2, x2, y2] = map(int, raw_input().split())
    d1 = abs(x2 - x) + abs(y2 - y)
    d2 = t2 - t
    if d1 > d2:
        print 'No'
        sys.exit(0)
    if d1 == d2 or (d2 - d1) % 2 == 0:
        t = t2
        x = x2
        y = y2
    else:
        print 'No'
        sys.exit(0)
        
print 'Yes'

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
t=[0]
x=[0]
y=[0]
ss="Yes"
for i in range(n):
 s=i2()
 t.append(s[0])
 x.append(s[1])
 y.append(s[2])
for i in range(n):
 tx=abs(x[i+1]-x[i])
 ty=abs(y[i+1]-y[i])
 if not(t[i+1]-t[i]>=tx+ty and (t[i+1]-t[i])%2==(tx+ty)%2):
   ss="No"
   break
print(ss)

Submission status: Accepted

Solution code:
n = int(input())
t = [0]
x = [0]
y = [0]
text = 'Yes'
for i in range(1,n+1):
  tt, xt, yt = map(int, input().split())
  t.append(tt)
  x.append(xt)
  y.append(yt)
  if abs(x[i] - x[i-1]) + abs(y[i]-y[i-1]) > t[i] - t[i-1]:
    text = 'No'

  if (t[i]-t[i-1] - abs(x[i]-x[i-1]) - abs(y[i]-y[i-1]))%2 != 0:
    text = 'No'

print(text)

Submission status: Accepted

Solution code:
n = int(input())
pret, prea, preb = 0, 0, 0
flag = True
for i in range(n):
    t, a, b = map(int, input().split())
    if (t - pret) % 2 == abs((a + b) - (prea + preb)) % 2 and t - pret >= abs((a + b) - (prea + preb)):
        pass
    else:
        print("No")
        break

    if i == n - 1:
        print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

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

ans = True
for i in range(N):
    d = abs(X[i] - X[i + 1]) + abs(Y[i] - Y[i + 1])
    t = T[i + 1] - T[i]
    if d > t or d % 2 != t % 2:
        ans = False

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

Submission status: Accepted

Solution code:
n = int(input())
pretime, prex, prey = 0, 0, 0
for i in range(n):
    nowtime, nowx, nowy = map(int, input().split())
    time = nowtime - pretime
    x = abs(nowx - prex)
    y = abs(nowy - prey)
    if x+y > time:
        print("No")
        exit()
    if (x+y) % 2 != time % 2:
        print("No")
        exit()
    pretime = nowtime
    prex, prey = nowx, nowy
else:
    print("Yes")

Submission status: Accepted

Solution code:
p = [map(int, raw_input().split()) for _ in xrange(input())]
ct, cx, cy = 0, 0, 0
flag = True
for dt, dx, dy in p:
    _ = dx - cx + dy - cy
    if dt < _ or (dt - _) % 2:
        flag = False
        break
print 'Yes' if flag else 'No'

Submission status: Accepted

Solution code:
N = int(input())

t_prev, x_prev, y_prev = 0, 0, 0
for _ in range(N):
    t, x, y = [int(x) for x in input().split()]
    l = (t - t_prev) - ((x - x_prev) + (y - y_prev))
    if not (l >= 0 and l % 2 == 0):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

	dis = abs(x-now[0]) + abs(y-now[1])
	if (t - prev_t - dis)%2 == 0 and (dis <= t-prev_t):
		now = [x,y]
		prev_t = t
	else:
		print("No")
		exit(0)

print("Yes")

Submission status: Runtime Error

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

pT, pX, pY = 0, 0, 0

for i in range(N):
    cT, cX, cY = l[i]
    mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)
    
    dam = mvT - (mvX+mvY)

    if dam %2 == 1 or dam < 0:
        print('No')
        exit()

    pT, pX, pY = l[i]

print('Yes')

Submission status: Runtime Error

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

ans = 'Yes'

for i in range(N-1):
    dt = l[i+1][0]-l[i][0]
    dx = l[i+1][1]-l[i][1]
    dy = l[i+1][2]-l[i][2]
    
    if dt < dx+dy:
        ans = 'No'
    else:
        if dt%2==0:
            if (dx+dy)%2!=0:
                ans = 'No'
        else:
            if (dx+dy)%2==0:
                ans = 'No'
                
print(ans)

Submission status: Runtime Error

Solution code:
using namespace std;

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int 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;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Submission status: Runtime Error

Solution code:
impport sys

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")
    sys.exit()
  print("Yes")

Submission status: Runtime Error

Solution code:
from collections import deque

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

N += 1
t.appendleft(0)
x.appendleft(0)
y.appendleft(0)

for i in range(N):
    t_sub = t[i+1] - t[i]
    x_sub = abs(x[i+1] - x[i])
    y_sub = abs(y[i+1] - y[i])
    dist = x_sub + y_sub
    if dist > t_sub or t_sub % 2 == dist % 2:
        print('No')
        exit()

print('Yes')

Submission status: Runtime Error

Solution code:
n=int(input())
arr=[[0,0,0]+[list(map(int,input().split())) for _ in range(n)]]
for i in range(n):
  t1,x1,y2=arr[i]
  t2,x2,y2=arr[i+1]
  if abs(x1-x2)+abs(y1-y2)>t1+t2:
    print('No')
    exit()
  if (abs(x1-x2)+abs(y1-y2))%2!=(t1+t2)%2:
    print('No')
    exit()
print('Yes')

Submission status: Runtime Error

Solution code:
n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num<su:
    ans="No"
    break
  else:
    if num%su==0:
      ans="Yes"
    elif su==0 and num%2==0:
      ans="Yes"
    else:
      ans="No"
      
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

num,a,b=0,0,0

for i in range(n):
  t,x,y=map(int,input().split())
  num,a,b=abs(t-num),abs(x-a),abs(y-b)
  su=a+b
  if num<su:
    ans="No"
    break
  else:
    if num%su==0:
      ans="Yes"
    else:
      ans="No"
      
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

t,x,y=map(int,input().split())
num=x+y

if t%num!=0:
  print("No")
  exit()
if n==1:
  print("Yes")
  exit()

for i in range(n-1):
  t,x,y=map(int,input().split())
  num-=(x+y)
  num=abs(num)
  if t%num!=0:
    print("No")
    exit()
    
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())

num=0

t,x,y=map(int,input().split())
num+=(x+y)
if t%num!=0:
  print("No")
  exit()
if n==1:
  print("Yes")
  
for i in range(n-1):
  t,x,y=map(int,input().split())
  num-=(x+y)
  num=abs(num)
  if t%num!=0:
    print("No")
    exit()
    
print("Yes")