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

pt=0
px=0
py=0

flag=1

for i in range(N):
    t,x,y=map(int,input().split())
    lt=t-pt
    lxy=abs(x-px)+abs(y-py)
    if lxy>lt or abs(lxy%2-lt%2) >0:
        flag=-1

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

Submission status: Accepted

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

def check(txy1, txy2):
    dt = txy2[0] - txy1[0]
    dx = abs(txy2[1] - txy1[1])
    dy = abs(txy2[2] - txy1[2])
    return (dt >= dx + dy) and (dt % 2 == (dx + dy) % 2)

print('Yes' if all(check(*rows) for rows in zip(txys, txys[1:])) else 'No')

Submission status: Accepted

Solution code:
#input one int
#a = int(input())

#input some val
#a, b, c = (int(i) for i in input().split())
#val = [[int(i) for i in input().split()] for i in range(N)]

#input matrix
#a = [input().split() for i in range()]

N = int(input())
val = [[int(i) for i in input().split()] for i in range(N)]
val.insert(0, [0, 0, 0])

def abs(a):
    if(a < 0):
        return (-a)
    else:
        return a

dist = 0
t = 0
flag = 1
j = 0
for j in range(N):
    t = val[j+1][0] - val[j][0]
    dist = abs(val[j+1][1] - val[j][1]) + abs(val[j+1][2] - val[j][2])
    if(flag==1 and dist<=t and t%2==dist%2):
        flag = 1
    else:
        flag = 0

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

Submission status: Accepted

Solution code:
t,x,y,f=0,0,0,1
for i in [0]*int(input()):
    a,b,c=map(int,input().split())
    d=abs(x-b)+abs(y-c)
    e=abs(t-a)
    if e<d or e%2!=d%2:f=0
    else:t,x,y=a,b,c
print(['No','Yes'][f])

Submission status: Accepted

Solution code:
prev_t = 0
prev_x = 0
prev_y = 0

n = int(input())
ans = True
for _ in range(n):
    t, x, y = map(int, input().split())
    dist = (x - prev_x) + (y - prev_y)
    time = t - prev_t
    if dist > time or dist % 2 != time % 2:
        ans = False
        break

    prev_x = x
    prev_y = y
    prev_t = t

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

Submission status: Accepted

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

for m in range(N):
    dt = T[m+1]-T[m]
    ds = abs(X[m+1]-X[m]) + abs(Y[m+1]-Y[m])
    if dt < ds:
        a = 0
    if dt%2 != ds%2:
        a = 0

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

Submission status: Accepted

Solution code:
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]
arr.insert(0, [0, 0, 0])
res = 'Yes'

for i in range(N):
    x = arr[i+1][1] - arr[i][1]
    y = arr[i+1][2] - arr[i][2]
    t = arr[i+1][0] - arr[i][0]
    
    if x+y <= t:
        if (x+y-t)%2 == 0:
            pass
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)

Submission status: Accepted

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

cnt = int(input())

for i in range(cnt):
    t, x, y = map(int, input().split())
    # 条件1：そもそも届かない
    if t < x + y:
        print("No")
        exit()
    # 条件2：奇数偶数が違うのでぴったり止まれない
    elif t % 2 != (x + y) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

flag = True
t, x, y = 0, 0, 0

for _ in range(N):
    t_nxt, x_nxt, y_nxt = map(int, input().split())
    dist = abs(x_nxt - x) + abs(y_nxt - y)
    if dist == 0 or not (dist <= t_nxt and (t_nxt - dist) % 2 == 0):
        flag = False

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

Submission status: Accepted

Solution code:
n = int(input())
t1, x1, y1=map(int, input().split())
if t1<x1+y1 or (x1+y1+t1)%2==1:
  print("No")
  exit()
for i in range(n-1):
  t2, x2, y2=map(int, input().split())
  if t2<x2+y2 or (abs(x2-x1)+abs(y2-y1))>t2-t1 or (x2+y2+t2)%2==1:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	#文字列を逆順にして、該当する単語を除いていく
	#eraseとeraserは"er"を決してしまうと判定できないので、先に消去
	n = int(input())
	#t, x, y = list(map(int, [re.split(" +", input()) for i in range(n)]))
	for i in range(n):
		t, x, y = map(int, input().split())
		if t < x + y or (x + y + t) % 2:
			print("No")
			exit()
	print("Yes")

if __name__ == '__main__':
	main()

Submission status: Accepted

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

n=int(input())

S=[]

NowT=0
Dist=0
Sx=0
Sy=0

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

for i in range(n):
    NowT=S[i][0]-NowT
    Dist=abs(S[i][1]-Sx)+abs(S[i][2]-Sy)
    if NowT>=Dist and NowT%2 ==Dist%2:
        pass
    else:
        
        print("No")
        exit()
    NowT=S[i][0]
    Sx=S[i][1]
    Sy=S[i][2]
    
print("Yes")

Submission status: Accepted

Solution code:
import sys
ans = 'Yes'; input()
for e in sys.stdin:
    t, x, y = map(int, e.split())
    t = t - x - y
    if t < 0 or t % 2 == 1: ans = 'No'; break
print(ans)

Submission status: Accepted

Solution code:
import sys
can = True; input()
e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]
for a, b in zip(e[1:], e):
    t = a[0] - b[0] - abs(a[1] - b[1]) - abs(a[2] - b[2])
    if t < 0 or t % 2 == 1: can = False; break
print(['No', 'Yes'][can])

Submission status: Accepted

Solution code:
can = True
e = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(int(input()))]
for a, b in zip(e[1:], e):
    dt = a[0] - b[0]
    dist = abs(a[1] - b[1]) + abs(a[2] - b[2])
    if dt < dist: can = False; break
    if dt % 2 != dist % 2: can = False; break
print(['No', 'Yes'][can])

Submission status: Accepted

Solution code:
N = int(input())
it, ix, iy = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = abs(it - t)
    dx = abs(ix - x)
    dy = abs(iy - y)
    d = dt - (dx + dy)
    if d < 0 or d % 2 != 0:
        ans = 'No'
        break
    it, ix, iy = t, x, y
print(ans)

Submission status: Accepted

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

for i in range(N):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destinations[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] - Destinations[i][0]

    if move_distance == 0:
        print("No")
        break

    if move_distance > move_time*1:
        print("No")
        break
    elif move_distance%2 == move_time%2:
        pass
    else:
        print("No")
        break

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

Submission status: Accepted

Solution code:
n=int(input())
#l=[]
j=0
for i in range(n):
    #l.append(list(map(int,input().split())))
    #一旦全部受け取ってから操作しなくてもよい
    #読み取るー操作をした方が処理量も少なくて済む
    l=list(map(int,input().split()))
    if l[1]+l[2]>l[0] or (l[0]+l[1]+l[2])%2!=0:
        print("No")
        j=1
        break
if j==0:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    num_n = int(input())
    plan_lists = [[0, 0, 0]]
    for i in range(num_n):
        plan_lists.append(list(map(int, input().split())))
    for i in range(num_n):
        if sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:]) > (plan_lists[i+1][0] - plan_lists[i][0]):
            return print("No")
        if (plan_lists[i+1][0] - plan_lists[i][0]) % 2 == 0:
            if (sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:])) % 2 == 0:
                continue
            else:
                return print("No")
        else:
            if (sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:])) % 2 == 1:
                continue
            else:
                return print("No")
    print("Yes")





if __name__ == '__main__':
    main()

Submission status: Accepted

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


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


def judge(T, points, N):
    for i in range(N):
        delta_t = T[i + 1] - T[i]
        d = distance(points[i + 1], points[i])
        if not (delta_t >= d and (delta_t - d) % 2 == 0):
            return "No"
    return "Yes"


print(judge(T, points, N))

Submission status: Accepted

Solution code:
def m():
    n = int(input())
    nowt = 0
    nowx = 0
    nowy = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        divt = abs(nowt - t)
        divx = abs(nowx - x)
        divy = abs(nowy - y)
        if divt < divx + divy:
            return "No"
        if divt == divx + divy:
            continue
        if (divt - divx + divy) % 2 == 0:
            continue
        return "No"
    return "Yes"

print(m())

Submission status: Accepted

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

if N == 1:
    timeInterval = list[1][0] - list[0][0]
    distance = abs(list[1][1]+list[1][2]-list[0][1]-list[0][2])
    if timeInterval < distance:
        print("No")
    elif (timeInterval - distance)%2 == 0:
        print("Yes")
    else:
        print("No")
else:
    for i in range(N):
        timeInterval = list[i+1][0] - list[i][0]
        distance = abs(list[i+1][1]+list[i+1][2]-list[i][1]-list[i][2])
        if timeInterval < distance:
            print("No")
            break
        elif (timeInterval - distance)%2 == 0:
            if i == N-1:
                print("Yes")
        else:
            print("No")
            break

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    tl, xl, yl = [], [], []
    for i in range(n):
        t, x, y = map(int, input().split())
        tl.append(t)
        xl.append(x)
        yl.append(y)

    prex, prey, pret = 0, 0, 0
    for t, x, y in zip(tl, xl, yl):
        sumxy = x + y - prex - prey
        sumt = t - pret
        prex, prey, pret = x, y, t
        if sumxy > sumt or sumt % 2 != sumxy % 2:
            print('No')
            exit()
    print('Yes')

Submission status: Accepted

Solution code:
def pred(t,x,y):
    return (t >= x + y and (y + x - t)%2 == 0)
result = True

t = 0
x = 0
y = 0

N = input()
for i in range(N):
    nt,nx,ny = map(int ,raw_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:
import sys

N = int(input())
place_info_list = list()

for _ in range(N):
    t, x, y = list(map(int, input().split()))
    place_info_list.append({
        't': t,
        'x': x,
        'y': y,
    })

place_info_list.sort(key=lambda place: place["t"])

current_place_info = {
    't': 0,
    'x': 0,
    'y': 0,
}

for place_info in place_info_list:
    distance = abs(place_info['x'] - current_place_info['x']) +\
               abs(place_info['y'] - current_place_info['y']) 
    necessary_time = distance / 1.0
    remained_time = place_info['t'] - current_place_info['t']

    if remained_time < necessary_time:
        print("No")
        sys.exit()

    if (remained_time - necessary_time) % 2 == 1:
        print("No")
        sys.exit()
    
    current_place_info['t'] = place_info['t']
    current_place_info['x'] = place_info['x']
    current_place_info['y'] = place_info['y']

print("Yes")

Submission status: Accepted

Solution code:

N = int(input())

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

point = [0,0]
flag = "Yes"
t = 0
for i in txy:
    t_, x, y = i
    t__ = t_ - t 
    move = abs(x-point[0])+abs(y-point[1])
    if move > t__:
        flag = "No"
        break
    elif (t__ - move) % 2 == 1:
        flag = "No"
        break
    point = [x,y]
    t = t_

print(flag)

Submission status: Accepted

Solution code:
n = int(input())

c = (0, 0, 0)
check = True
for i in range(n):
    ct, cx, cy = c
    t, x, y = [int(i) for i in input().strip().split(' ')]
    dt = t - ct
    d = abs(cx - x) + abs(cy - y)
    if dt < d or (dt - d) % 2 != 0:
        check = False

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

Submission status: Accepted

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

x = y = t = 0
for ti,xi,yi in src:
    dist = abs(x-xi) + abs(y-yi)
    if ti - t >= dist and (ti-t)%2 == dist%2:
        t,x,y = ti,xi,yi
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
s_list = [list(map(int, input().split())) for i in range(n)]
ans = "Yes"
for s in s_list:
    if s[0] < s[1] + s[2]:
        ans = "No"
        break
    elif s[0] % 2 == 0 and (s[1] + s[2]) % 2 == 1:
        ans = "No"
        break
    elif s[0] % 2 == 1 and (s[1] + s[2]) % 2 == 0:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append([int(num) for num in input().split()])
#print(a)

ans = True
for i in range(n):
#    print(a[i][0])
#    print(a[i][1] + a[i][2])
    if(a[i][0] >= (a[i][1] + a[i][2])):
        if(a[i][0]%2 != (a[i][1] + a[i][2])%2):
            ans = False
            break
    else:
        ans = False
        break
    
if(ans):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import math
l = []
for i in range(int(input())):
    l.append(list(map(int,input().split())))
start = [0,0]
back = 0
for i in l:
    dist = math.fabs((start[0] - i[1]) + (start[1] -i[2]))
    if(dist > (i[0]-back)):
        print("No")
        sys.exit()
    else:
        if((dist-(i[0]-back))%2 == 0):
            start = [i[1],i[2]]
            back = i[0]
        else:
            print("No")
            sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
def c_traveling(N, P):
    t = x = y = 0  # 初期時刻には原点にいる
    for t_next, x_next, y_next in P:
        dt = t_next - t
        dd = abs(x_next - x) + abs(y_next - y)
        if dt >= dd and dt % 2 == dd % 2:
            # 制限時間は次の座標へのマンハッタン距離以上持っていないとたどり着けない
            # 制限時間と距離の偶奇が一致していないと次の座標で止まることができない
            t, x, y = t_next, x_next, y_next
        else:
            return 'No'
    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:
N=int(input().strip())
txy=[]
t1,x1,y1 = 0,0,0
flag=True
for i in range(N):
    t2,x2,y2 = map(int,input().split())
    dt=t2-t1
    dist=abs(x2-x1)+abs(y2-y1)
    if dist>dt or (dist-dt)%2!=0:
        flag=False
        break
print(["No", "Yes"][flag])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t = [0]
x = [0]
y = [0]
ans = "Yes"
for i in range(n):
    t_i, x_i, y_i = map(int,input().split())
    t.append(int(t_i))
    x.append(int(x_i))
    y.append(int(y_i))

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 dist > dt:
        ans = "No"
        break
    if dist%2 != dt%2:
        ans = "No"
        break
print(ans)

Submission status: Accepted

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

flag = 1

for i in range(1,len(trv)):
    time = trv[i][0]-trv[i-1][0]
    dist = abs(trv[i][1]-trv[i-1][1]) + abs(trv[i][2]-trv[i-1][2])
    if time < dist:
        flag = 0
    elif time >= dist and (time-dist) % 2 == 0:
        None
    else:
        flag = 0
        break
        
if flag == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)] #(t,x,y)
flag = True
for i in range(n):
    dt,dx,dy = [data[i][k]-(0 if i==0 else data[i-1][k]) for k in range(3)]
    if not(dx+dy<=dt and (dt-dx-dy)%2==0):
        flag = False
        break
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
result = 'Yes'
for i in range(N + 1):
    if i == 0:
        pass
    else:
        d_t = t_list[i] - t_list[i-1]
        d_x = x_list[i] - x_list[i-1]
        d_y = y_list[i] - y_list[i-1]
        if d_t >= d_x + d_y:
            if (d_t - (d_x + d_y)) % 2 == 0:
                pass
            else:
                result = 'No'
        else:
            result = 'No'
print(result)

Submission status: Accepted

Solution code:
# 11th
n = int(input())
a = [[int(i) for i in input().split()] for j in range(n)]
t = [i[0] for i in a]
x = [i[1] for i in a]
y = [i[2] for i in a]
tmpt=0
tmpx=0
tmpy=0
for i in range(n):
    tmp = (t[i] - tmpt) - abs(x[i] - tmpx) - abs(y[i] - tmpy)
    tmpt = t[i]
    tmpx = x[i]
    tmpy = y[i]
    if tmp >= 0 and tmp%2 == 0:
        continue
    print("No")
    break
else:
    #最後までfor文がbreakしなかった場合
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
a=[list(map(int,input().split()))for i in range(n)]
a.insert(0,[0,0,0])
for i in range(1,n+1):
    t=a[i][0]-a[i-1][0]
    dis=abs(a[i][1]-a[i-1][1])+abs(a[i][2]-a[i-1][2])
    if t<dis:
        print("No")
        exit()
    elif (t-dis)%2!=0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(raw_input())
m=flag=f=0
temp=[[0,0,0]]
for i in range(n):
	ip=map(int,raw_input().split())
	temp.append(ip)
	
for i in range(1,n+1):
	if temp[i][0]-temp[i-1][0] >=abs(temp[i][1]+temp[i][2]-temp[i-1][1]-temp[i-1][2]):
		flag=1
	if ((temp[i][0]-temp[i][1]-temp[i][2])%2==0):
		f=1
	if flag==1 and f==1:
		m=m+1
	flag=f=0
	
if n==m:
	print 'Yes'
else:
	print 'No'

Submission status: Accepted

Solution code:
n=int(input())
kh=[]
dif=[]
current=0
for i in range(n):
    kh.append(list(map(int,input().split())))
    dif.append(kh[-1][0]-current)
    current=kh[-1][0]
    
   
current=[0,0]
flag=True
for i in range(n):
    need=abs(kh[i][1]-current[0])+abs(kh[i][2]-current[1])
    current=[kh[i][1],kh[i][2]]
    
    if dif[i] < need :
        flag = False
        break
    elif (dif[i] - need) % 2 != 0 :
        flag = False 
        break
if flag :
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
travel=[]
dif=[]
current=0
for i in range(n):
    travel.append(list(map(int,input().split())))
    dif.append(travel[-1][0]-current)
    current=travel[-1][0]
    
   
current=[0,0]
tamam=True
for i in range(n):
    need=abs(travel[i][1]-current[0])+abs(travel[i][2]-current[1])
    current=[travel[i][1],travel[i][2]]
    
    if dif[i] < need :
        tamam = False
        break
    elif (dif[i] - need) % 2 != 0 :
        tamam = False 
        break
if tamam :
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(1, n+1):
    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])
    if not (distance <= time and distance % 2 == time % 2):
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
is_yes = False
 
for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y <= t) & ((x + y + t) % 2 == 0):
        is_yes = True
    else:
        print("No")
        quit()
 
if is_yes:
    print("Yes")

Submission status: Accepted

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

for i in range(0,n):
    tin, xin, yin = (int(i) for i in input().split())
    t.append(tin)
    x.append(xin)
    y.append(yin)

for i in range(1,n+1):
    TimeGap = t[i]-t[i-1]
    DisGap = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    if TimeGap%2 != DisGap%2 or TimeGap < DisGap:
        ok = False
if ok == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
listT = [0]
listX = [0]
listY = [0]

for i in range(N):
    A,B,C = map(int,input().split())
    listT.append(A)
    listX.append(B)
    listY.append(C)

'''
for j in range(N+1):
    print(listT[j])
    print(listX[j])
    print(listY[j])
'''

flag = 'Yes'

for j in range(1,N+1):
    m = listT[j]-listT[j-1] -listX[j]-listY[j] +listX[j-1]+listY[j-1]
#    print('m',m)

    if m%2==0 and m>=0:

        continue
    else:
        flag = 'No'

print(flag)

Submission status: Accepted

Solution code:
N = int(input())
t_bef = 0
x_bef = 0
y_bef = 0

flag = False
for i in range(N):
    t, x, y = map(int, input().split())
    t_diff = t - t_bef
    dist = abs(x - x_bef) + abs(y - y_bef)
    if (t_diff - dist)%2 != 0 or dist > t_diff:
        flag = True
    else:
        t_bef = t
        x_bef = x
        y_bef = y

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

Submission status: Accepted

Solution code:
N=int(input())
t_before=0
x_before=0
y_before=0
import sys

for i in range (N):
    t, x, y =map(int,input().split())
    t_diff=t-t_before
    distance=abs(x-x_before)+abs(y-y_before)
    if (t_diff-distance)%2!=0 or distance>t_diff:
        print("No")
        sys.exit()
    else:
        t_before=t
        x_before=x
        y_before=y
    
        

print ("Yes")

Submission status: Accepted

Solution code:
N = int(input())
coords_list = tuple([(0, 0, 0)] + [tuple([int(elem) for elem in input().split(' ')]) for _ in range(N)])

for i in range(N):
    dt = coords_list[i + 1][0] - coords_list[i][0]
    diff = [abs(coords_list[i + 1][1] - coords_list[i][1]), 
            abs(coords_list[i + 1][2] - coords_list[i][2])]

    if sum(diff) > dt:
        print("No")
        exit(0)
    elif (diff[0] + diff[1]) % 2 == dt % 2:
        continue
    else: # diff == 0
        print("No")
        exit(0)
else:
    print("Yes")

Submission status: Accepted

Solution code:
class Point:
	def __init__(self, x, y):
		self.x = x
		self.y = y

def ham_dist(p1, p2):
	dx = abs(p1.x - p2.x)
	dy = abs(p1.y - p2.y)

	return dx+dy

n = int(input())
possible = True

pos = Point(0, 0)
t = 0

for i in range(n):
	_t, x, y = map(int, input().split())
	
	dest = Point(x, y)
	dt = _t - t
	dist = ham_dist(pos, dest)

	if dt < dist or (dt - dist) % 2 != 0:
		possible = False
		
	t = _t
	pos = dest

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

Submission status: Accepted

Solution code:
import sys

m = int(input())
t = []
x = []
y = []

i = 0
while(i < m):
  a = input().split()
  t.append(int(a[0]))
  x.append(int(a[1]))
  y.append(int(a[2]))
  i += 1

cx = 0
cy = 0
ct = 0

i = 0
while(i < m):
  dx = abs(x[i] - cx)
  dy = abs(y[i] - cy)
  dt = (t[i] - ct) - (dx + dy)
  if(dt < 0 or dt > 0 and dt % 2 == 1):
    print('No')
    sys.exit()
  cx = x[i]
  cy = y[i]
  ct = t[i]
  i += 1
print('Yes')

Submission status: Accepted

Solution code:

r = 1
t = 0
m = 0
N = int(input())
txy = []

for i in range(N):
    txy.append([int(x) for x in input().split()])


for i in txy:
    t = i[0] - t
    m = abs((i[1] + i[2]) - m)
    
    if t < m:
        print("No")
        break
    elif (t - m) % 2 != 0:
        print("No")
        break
    
    
    
    if r == N and t >= m:
        print("Yes")
        
    r += 1

Submission status: Accepted

Solution code:
N = int(input())
X = []
flag = True
dt=0
dx=0
dy=0

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

for i in X:
     dt = abs(i[0] - dt)
     dx = abs(i[1] - dx)
     dy = abs(i[2] - dy)
     if dx + dy > dt:
         flag = False
     elif (dt - dx - dy) % 2 == 1:
         flag = False

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

Submission status: Accepted

Solution code:

r = 1
t = 0
m = 0
N = int(input())
txy = []

for i in range(N):
    txy.append([int(x) for x in input().split()])


for i in txy:
    t = i[0] - t
    m = abs((i[1] + i[2]) - m)
    
    if i[0] % 2 == 0:
        if (i[1] + i[2]) % 2 != 0:
            print("No")
            break
        elif t < m:
            print("No")
            break
            
    else:
        if (i[1] + i[2]) % 2 != 1:
            print("No")
            break
        elif t < m:
            print("No")
            break
    
   
    if r == N and t >= m:
        print("Yes")
        
    r += 1

Submission status: Accepted

Solution code:
n = int(input())
points = [list(map(lambda x: int(x), input().split(" "))) for x in range(n)]

t = 0
x = 0
y = 0

able = True
for point in points:
    dt = point[0] - t
    dl = abs(point[1] - x)+abs(point[2]-y)
    if dt-dl>=0 and (dt-dl)%2 == 0:
        pass
    else:
        able = False
    t = point[0]
    x = point[1]
    y = point[2]
print("Yes" if able 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)]
for i in range(n):
    t[i],x[i],y[i] = map(int, input().split(" "))

for i in range(n):
    if i == 0:
        sum = abs(x[i]) + abs(y[i])
        time = t[i]
    else:
        sum = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
        time = t[i]-t[i-1]
    if sum > time:
        print("No")
        quit()
    if sum%2 != time%2:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
def can_travel(ts, xs, ys):
    t_prev, x_prev, y_prev = 0, 0, 0
    for t, x, y in zip(ts, xs, ys):
        t_diff = t - t_prev
        d = abs(x - x_prev) + abs(y - y_prev)

        if t_diff < d:
            return False

        if t_diff % 2 != d % 2:
            return False

    return True


if __name__ == '__main__':
    N = int(input())
    values = [list(map(int, input().split())) for _ in range(N)]
    ts, xs, ys = zip(*values)

    if can_travel(ts, xs, ys):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
t_list = []
x_list = []
y_list = []
t_list.append(0)
x_list.append(0)
y_list.append(0)
for i in range(N):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

judge = True 
for i in range(N):
    distance = t_list[i + 1] - t_list[i]
    distance_abs = abs(x_list[i + 1] - x_list[i]) + abs(y_list[i + 1] - y_list[i])

    if (distance < distance_abs):
        judge = False
    if (distance % 2 != distance_abs % 2):
        judge = False

if judge is True:
    print('Yes')
if judge is False:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
loc_x=0
loc_y=0
judge=0
for i in range(n):
    if judge!=0:
        break
    if txy[i][0]%2==0:
        if (txy[i][1]+txy[i][2])%2!=0:
            judge+=1
    elif (txy[i][1]+txy[i][2])%2==0:
        judge+=1
    temp = abs(loc_x-txy[i][1])+abs(loc_y-txy[i][2])
    if i == 0:
        if temp > txy[0][0]:
            judge+=1
    else:
        if temp > txy[i][0]-txy[i-1][0]:
            judge+=1
    loc_x = txy[i][1]
    loc_y = txy[i][2]
print('No') if judge else print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
loc_x=0
loc_y=0
judge=0
for i in range(n):
    if txy[i][0]%2==0:
        if (txy[i][1]+txy[i][2])%2!=0:
            judge+=1
    elif (txy[i][1]+txy[i][2])%2==0:
        judge+=1
    temp = abs(loc_x-txy[i][1])+abs(loc_y-txy[i][2])
    if i == 0:
        if temp > txy[0][0]:
            judge+=1
    else:
        if temp > txy[i][0]-txy[i-1][0]:
            judge+=1
    loc_x = txy[i][1]
    loc_y = txy[i][2]
print('No') if judge else print('Yes')

Submission status: Accepted

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

for j in range(0,N):
    t,x,y = map(int,input().split())
    plan.append(t)
    plan.append(x)
    plan.append(y)

if (plan[0] < plan[1] + plan[2]) or ((plan[0] % 2) != ((plan[1] + plan[2]) % 2)):
    print("No")
    exit()

for i in range(0,N-1):
    time_dis = plan[i*3 +3] - plan[i*3]
    x_dis = abs(plan[i*3+1] - plan[i*3+1 +3])
    y_dis = abs(plan[i*3+2] - plan[i*3+2 +3])
    
    if (time_dis < x_dis + y_dis) or ((time_dis % 2) != ((x_dis + y_dis) % 2)):
        print("No")
        exit()
        
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)

can = True
for i in range(n):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dist > dt:
        can = False
    elif dist%2 != dt%2:
        can = False
if can:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
t1, x1, y1 = 0, 0, 0
feasible = True
for _ in range(n):
    t2, x2, y2 = map(int, input().split())
    movements = abs(x2 - x1) + abs(y2 - y1)
    if movements > (t2 - t1) or movements % 2 != (t2 - t1) % 2:
        feasible = False
    t1, x1, y1 = t2, x2, y2
print('Yes') if feasible else print('No')

Submission status: Accepted

Solution code:
n=int(input())
info=[[int(i)for i in input().split()]for i in range(n)]
info.insert(0,[0,0,0])
for i in range(n):
    t=info[i+1][0]-info[i][0]
    d=abs(info[i+1][1]-info[i][1])+abs(info[i+1][2]-info[i][2])
    if d<=t:
        if d%2==0 and t%2==0:
            pass
        elif d%2==1 and t%2==1:
            pass
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Accepted

Solution code:
def validate(plan):
    pre_time = 0
    pre_x, pre_y = 0, 0
    available = True
    for t, x, y in plan:
        elapsed = t - pre_time
        dist = abs(x-pre_x) + abs(y-pre_y) 
        if elapsed < dist or elapsed%2 != dist%2:
            available = False
            break
    return available

def solve():
    N = int(input())
    plan = []
    for i in range(N):
        plan.append(map(int, input().split()))
    available = validate(plan)
    if available:
        print('Yes')
    else:
        print('No')

solve()