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())
plan = [[0,0,0]]
for i in range(N):
    plan.append(list(map(int,input().split())))
flag = 0
for i in range(N):
    t_d = plan[i+1][0]-plan[i][0]
    p_d = abs(plan[i+1][2]-plan[i][2])+abs(plan[i+1][1]-plan[i][1])
    if t_d%2 != p_d%2 or p_d > t_d:
        flag = 1
print("Yes" if flag == 0 else "No")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    t = [None]*N
    x = [None]*N
    y = [None]*N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())
    flag=True
    # check first step
    if (t[0] - max(x[0], -x[0]) - max(y[0], -y[0])) %2 != 0 or t[0] < max(x[0], -x[0]) + max(y[0], -y[0]):
        print('No')
        flag = False
    
    for i in range(N-1):
        delta_t = t[i+1] - t[i]
        delta_x = x[i+1] - x[i]
        if delta_x < 0:
            delta_x = -delta_x
        delta_y = y[i+1] - y[i]
        if delta_y < 0:
            delta_y = -delta_y
        delta = delta_x + delta_y
        if (delta_t - delta) % 2 == 0 and delta_t >= delta:
            continue
        else:
            if flag:
                print('No')
                flag = False
            break
    if flag:
        print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
i=0
 
flag=0
beforeTxy=[0,0,0]
while i<N:
  afterTxy=list(map(int,input().split()))
  #print(afterTxy)
  #unk=afterTxy[0]-beforeTxy[0]-abs(afterTxy[1]-beforeTxy[1])-abs(afterTxy[2]-beforeTxy[2])
  #unk2=afterTxy[0]-beforeTxy[0]-abs(afterTxy[1]-beforeTxy[1])
  dt=afterTxy[0]-beforeTxy[0]
  dist=abs(afterTxy[1]-beforeTxy[1])+abs(afterTxy[2]-beforeTxy[2])
  #print(dt,dist)
  if dt < dist or dt%2!=dist%2:
    flag=1
  beforeTxy=afterTxy
  i=i+1
 
if flag==0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N=int(input())
dst = [[0, 0, 0]]
for i in range(N):
    dst.append(input().split())
    
flag = True

for i in range(1, N+1):
    time_diff = int(dst[i][0])-int(dst[i-1][0])
    dst_diff = abs(int(dst[i][1])-int(dst[i-1][1]))+abs(int(dst[i][2])-int(dst[i-1][2]))
    if (time_diff>=dst_diff and (time_diff+2)%2 == (dst_diff+2)%2):
        flg = True
    else:
        flg = False
        break

if flg == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

n = int(input())
lst = [[0,0,0]]
for i in range(n):
    l = list(map(int,input().split()))
    lst.append(l)
flg = True
for i in range(1,n+1):
    t = lst[i][0] - lst[i-1][0]
    dst = (abs(lst[i][1] - lst[i-1][1])) + (abs(lst[i][2] - lst[i-1][2]))
    if dst > t or dst%2 != t%2:
        flg = False
        break

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

Submission status: Accepted

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

flag=True
#時間経過
tk=0
#現在座標
xk=0
yk=0

for i in range(N):
    txy=input()
    #時間　x座標　y 座標
    t,x,y=txy.split()
    t=int(t)
    x=int(x)
    y=int(y)
    #時間に余裕があるか
    if abs(t-tk) >= abs(x-xk)+abs(y-yk):
        #偶数　奇数
        if (abs(t-tk)+abs(x-xk)+abs(y-yk))%2==0:
            flag=True
        else:
            flag=False
    else:
        flag=False
    
    tk=t
    xk=x
    yk=y
    
    if not flag:
        print('No')
        break

if flag:
    print('Yes')

Submission status: Accepted

Solution code:
def check(x0, y0, x1, y1, s):
  dist = abs(x1 - x0) + abs(y1 - y0)
  if dist > s:
    return False
  if (dist + s) % 2 == 0:
    return True
  return False

N = int(input())
s0, x0, y0 = 0, 0, 0
ret = True
for i in range(N):
  s1, x1, y1 = map(int, input().split())
  if not check(x0, y0, x1, y1, s1 - s0):
    ret = False
    break
  s0, x0, y0 = s1, x1, y1
if ret:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())

t0 = 0
x0 = 0
y0 = 0

for i in range(n):
  t, x, y = map(int, input().split())
  if (x-x0)+(y-y0) <= t-t0 and(t-t0)%2 == ((x-x0)+(y-y0))%2:
    t0 = t
    x0 = x
    y0 = y
  else:
    print('No')
    exit()
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
tmpt = 0
for i in range(n):
    v1,v2,v3 = map(int,input().split())
    t.append(v1)
    x.append(v2)
    y.append(v3)
for i in range(n):
    if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i] - tmpt and (abs(tmpx-x[i]) + abs(tmpy-y[i])) % 2 == (t[i] - tmpt) % 2:
        tmpx = x[i]
        tmpy = y[i]
        tmpt = t[i]
        continue
    else:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
t[0] = 0
x[0] = 0
y[0] = 0
for n in range(N):
  n = n+1
  t[n], x[n], y[n] = map(int, input().split())

ans = "Yes"
for n in range(N):
    dt = t[n+1] - t[n]
    dist = abs(x[n+1] - x[n]) + abs(y[n+1] - y[n])
    if (dt < dist) or ((dt - dist) % 2 == 1):
        ans = "No"

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
txy = [[0]*3 for _ in range(N)]
for i in range(N):
  txy[i] = list(map(int, input().split()))
flag = True
for sh in txy:
  Sxy = sh[1] + sh[2]
  if (Sxy % 2 == 0) ^ (sh[0] % 2 == 0):
    flag = False
  if sh[0] < Sxy:
    flag = False
  if not(flag):
    break
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:

n = int(input()) + 1
data = [[0] * 3 for i in range(n)]

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

for i in range(1, n):
    dt = data[i][0] - data[i - 1][0]
    dx = data[i][1] - data[i - 1][1]
    dy = data[i][2] - data[i - 1][2]

    for j in range(dt//2 + 1):
        if dt - 2 *j == abs(dx) + abs(dy):
            if i == n - 1:
                print('Yes')
            break
    else:
        if i == n - 1:
            print('No')

Submission status: Accepted

Solution code:
n = int(input())

cur = [0, 0, 0]

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

    dur = t - cur[0]
    dist = abs(x - cur[1]) + abs(y - cur[2])
    if not (dist <= dur and (dur - dist) % 2 == 0):
        ok = False
        print("No")
        break
    
    cur = [t, x, y]

if ok:
    print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    flag = True
    p = (0, 0)
    ct = 0
    for i in range(N):
        d = abs(x[i] + y[i])
        dt = t[i] - ct
        if dt - d < 0 or (dt - d) % 2 != 0:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, t, x, y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
T = [0]
X = [0]
Y = [0]
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(1, N + 1):
    dr = abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1])
    dt = T[i] - T[i-1]
    if dr > dt or (dr - dt) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def solve():
    list_of_txy = read()
    result = think(list_of_txy)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_txy = [[0, 0, 0]]
    for _ in range(n):
        list_of_txy.append(read_int(3))
    return list_of_txy


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_of_txy):
    for i in range(len(list_of_txy) - 1):
        t, x, y = list_of_txy[i]
        nt, nx, ny = list_of_txy[i + 1]
        dx, dy, dt = abs(nx - x), abs(ny - y), abs(nt - t)
        if dx + dy > dt:
            return False
        if (dt - dx - dy) % 2 != 0:
            return False
    return True


def write(result):
    if result:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
T, X, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

t, x, y = 0, 0, 0
ok = True
for i in range(N):
    dt = T[i] - t
    d = abs(x - X[i]) + abs(y - Y[i])
    if not (dt >= d and (dt - d) % 2 == 0):
        ok = False
    t = T[i]
    x = X[i]
    y = Y[i]
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
TS = sorted([[0,0,0]] + [list(map(int, input().split())) for k in range(N)])
result = True
for k in range(N):
    length = [abs(TS[k+1][i] - TS[k][i]) for i in range(3)]
    reminder = length[0] - length[1] - length[2]
    result = result and (reminder >= 0) and (reminder % 2 == 0)
print("Yes") if result else print("No")

Submission status: Accepted

Solution code:
N = int(input())
t, x, y = [0] * (N+1), [0] * (N+1), [0] * (N+1)


def main():
    for i in range(1, N + 1):
        t[i], x[i], y[i] = map(int, input().split())
    print("Yes" if detect() else "No")


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


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
z=0
p=s[0][0]-abs(s[0][1])-abs(s[0][2])
if p>=0 and p%2==0:
        pass
else:
    print('No')
    exit()
    
for i in range(1,n):
    z=s[i][0]-s[i-1][0]-abs(s[i][1]-s[i-1][1])-abs(s[i][2]-s[i-1][2])
    if z>=0 and z%2==0:
        pass
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
dt = [0]*N
dist = [0]*N
for i in range(1,N+1):
    t[i], x[i], y[i] = map(int, input().rstrip().split())

for j in range(1,N+1):
    dt[j-1] = t[j] - t[j-1]
    dist[j-1] = abs(x[j] - x[j-1]) + abs(y[j] - y[j-1])

Flag = "OK"
for k in range(N):
    if dt[k] < dist[k]:
        Flag = "NG"
    else:
        if (dt[k]-dist[k]) % 2 != 0:
            Flag = "NG"

if Flag == "OK":
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

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

for i in li:
    cost = abs(i[1] - now[0]) + abs(i[2] - now[1]) 
    if (i[0] - t) < cost or (i[0] - t - cost) % 2 != 0:
        print("No")
        break
    t = i[0]
    now = [i[1], i[2]]
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

x_before = 0
y_before = 0
t_before = 0
ans = 'Yes'

for i in range(N):
    t, x, y = map(int, input().split())
    
    #i番目とi+1番目までの距離
    distance = abs(x-x_before) + abs(y-y_before)
    
    #i番目とi+1番目までの時間
    time = t-t_before
    
    #i+1番目のtimeで行くことが可能か判定
    if time-distance<0:
        ans = 'No'
        break
    if time%2 != distance%2:
        ans = 'No'
        break
        
    #i+1番目のtimeで行くことが可能なら値を更新
    x_before = x
    y_before = y
    t_before = t
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t_old, x_old, y_old = 0, 0, 0

for i in range(N):
  t, x, y = map(int, input().split())
  dt = t - t_old
  dx = x - x_old
  dy = y - y_old
  t_old = t
  x_old = x
  y_old = y
  if abs(dx) + abs(dy) <= dt and (dt - (abs(dx) + abs(dy))) % 2 == 0:
    if i == N - 1:
      print('Yes')
    pass
  else:
    print('No')
    break

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)%2 != t%2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N_POINTS = int(input())
POINTS = [[0, 0, 0]]
for _ in range(N_POINTS):
    POINTS.append([int(value) for value in input().split(' ')])


def is_accessible_point(point1, point2):
    distance = abs(point1[1] - point2[1]) + abs(point1[2] - point2[2])
    time = point2[0] - point1[0]
    if distance > time or (time - distance) % 2 != 0:
        return False
    return True


def is_accessible_points(n_points, points):
    for i in range(n_points):
        if is_accessible_point(points[i], points[i + 1]):
            continue
        else:
            return False
    return True


if is_accessible_points(N_POINTS, POINTS):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(n):
	temp=list(input().rstrip().split())
	temp2=[]
	for element in temp:
		temp2.append(int(element))
	timeline.append(temp2)


i=0
flag=True
output="Yes"

while i<n and flag:
	dif=[timeline[i+1][0]-timeline[i][0],timeline[i+1][1]-timeline[i][1],timeline[i+1][2]-timeline[i][2]]
	if dif[0]<abs(dif[1])+abs(dif[2]) or (dif[0]-abs(dif[1])-abs(dif[2]))%2 ==1 :
		flag=False
		output="No"
	i+=1

print(output)

Submission status: Accepted

Solution code:

def main():
    n = int(input()) 
    l = list()
    t = 0
    x , y = 0 , 0
    flag = True
    for i in range(n):
        c , a , b = map(int,input().split())
        if abs(a-x) + abs(b-y) > abs(c-t) :
            # print('%')
            flag = False 
        elif (abs(c-t)-abs(a-x)-abs(b-y)) % 2 !=0:
            # print('$')
            flag = False 
        else:
            x , y , t = a , b , c
    if flag:
        print('Yes')
    else:
        print('No')


        

main()

Submission status: Accepted

Solution code:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(1,n+1):t[i],x[i],y[i]=map(int,input().split())
print('YNeos'[not all(t[i+1]-t[i]-abs(x[i]-x[i+1])-abs(y[i]-y[i+1])>=0 and (t[i+1]-t[i]-abs(x[i]-x[i+1])-abs(y[i]-y[i+1]))%2==0 for i in range(n))::2])

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
flag = 0

for i in range(n):
    a,b,c = [int(z) for z in input().split()]
    p = np.abs(b)+np.abs(c)
    if a < p or (a-p)%2 != 0:
        flag = 1
    
if flag:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

flag = 0
S = [0,0]
for i in range(N):
    t,x,y = [int(zz) for zz in input().split()]
    p = abs(S[0]-x)+abs(S[1]-y)
    if t < p or (t-p)%2 != 0:
        flag = 1

if flag:
    print('No')
else:
    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())))

can = True

for i in range(n):
    dt = t[i+1][0] - t[i][0]
    dist = abs(t[i+1][1] - t[i][1]) + abs(t[i+1][2] - t[i][2])
    if dt < dist:
        can = False
    if dt % 2 != dist % 2:
        can = False

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
T = [[0 for i in range(3)] for j in range(N)]
for i in range(3):
    T = [[0,0,0]]
for i in range(1,N+1):
    row = input().split()
    for j in range(len(row)):
        row[j] = int(row[j])
    T.append(row)

for i in range(N):
    dist = abs(T[i+1][1]-T[i][1]) + abs(T[i+1][2]-T[i][2])
    time = T[i+1][0]- T[i][0]

    if dist > time or (dist - time) % 2 == 1:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
# ABC086C - Traveling (ARC089C)
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))
    for t, x, y in A:
        t -= x + y
        if t < 0 or t % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC086C - Traveling (ARC089C)
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ABC086C - Traveling (ARC089C)
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
n = int(raw_input())
data = [map(int, raw_input().split()) for i in range(n)]
t = 0
x = 0
y = 0
for d in data:
  duration = d[0] - t
  distance = abs(x - d[1]) + abs(y - d[2])
  if (distance > duration) or ((duration - distance) % 2 == 1):
    print 'No'
    sys.exit()
  t = d[0]
  x = d[1]
  y = d[2]
print 'Yes'

Submission status: Accepted

Solution code:
def is_reachable(time, x, y):
  if time < x + y:
    return False
  if (time - x - y) % 2 == 0:
    return True
  else:
    return False
  
N=int(input())
X=[list(map(int, input().split())) for i in range(N)]
t = 0
x = 0
y = 0
for i in range(N):
  if is_reachable(X[i][0]-t, abs(X[i][1]-x), abs(X[i][2]-y)):
    t = X[i][0]
    x = X[i][1]
    y = X[i][2]
  else:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8

n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
before_t = before_x = before_y = 0
for _ in range(N):
  t, x, y = map(int, input().split())
  distance = abs(x-before_x) + abs(y-before_y)
  diff_t = t-before_t
  if diff_t < distance or (diff_t-distance)%2 != 0:
    print('No')
    exit()
  before_t = t
  before_x = x
  before_y = y
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    ans = ['Odd', 'Even']
    print(ans[(a*b)%2-1])
    return

#B
def B():
    a, b = map(str,input().split())
    a = a + b
    if math.sqrt(int(a)).is_integer():
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = II()
    pre = (0, 0, 0)
    for _ in range(n):
        t,x,y = LI()
        dist = abs(pre[0] - x) + abs(pre[1] - y)
        if dist <= t - pre[2] and dist % 2 == (t - pre[2]) % 2:
            pre = (x, y, t)
            continue
        print("No")
        return
    print("Yes")
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    ans = ['Odd', 'Even']
    print(ans[(a*b)%2-1])
    return

#B
def B():
    a, b = map(str,input().split())
    a = a + b
    if math.sqrt(int(a)).is_integer():
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = II()
    pre = (0, 0, 0)
    for _ in range(n):
        t,x,y = LI()
        dist = abs(pre[0] - x) + abs(pre[1] - y)
        if dist <= t - pre[2] and dist % 2 == (t - pre[2]) % 2:
            continue
        print("No")
        return
    print("Yes")
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
import fractions
def main31():
    num = int(input())
    txy = []
    txy.append([0,0,0])
    for i in range(num):
        kari = []
        data = input().split()
        for j in range(3):
            kari.append(int(data[j]))
        txy.append(kari)
    for i in range(num):
        kyori = abs(txy[i][1]-txy[i+1][1]) + abs(txy[i][2]-txy[i+1][2])
        zikan = txy[i+1][0] - txy[i][0]
        if not(kyori <= zikan and (kyori - zikan) % 2 == 0):
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main31()

Submission status: Accepted

Solution code:
N = int(input())
txy = [[0, 0, 0]]
for i in range(N):
    txy.append(list(map(int, input().split())))
flag = False
for i in range(N):
    t_tmp = txy[i+1][0] - txy[i][0]
    x_diff = txy[i+1][1] - txy[i][1]
    y_diff = txy[i+1][2] - txy[i][2]
    if t_tmp >= (x_diff + y_diff) and (t_tmp - (x_diff + y_diff)) % 2 == 0:
        flag = True
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

travel.sort()

if travel[0][0]<(travel[0][1]+travel[0][2]) or travel[0][0]%2!=(travel[0][1]+travel[0][2])%2:
    ans=0
else:
    for k in range(n-1):
     a=travel[k+1][0]-travel[k][0]
     b=travel[k+1][1]-travel[k][1]
     c=travel[k+1][2]-travel[k][2]
     if a<abs(b)+abs(c) or a%2!=(b+c)%2:
         ans=0
         break

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

Submission status: Accepted

Solution code:
#ABC 86 C - travelling
n = int(input())
A = [[int(el) for el in 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]
    d = abs(A[i][1] - A[i-1][1]) + abs(A[i][2] - A[i-1][2])
    if (d <= t) & (d % 2 == t % 2):
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
et = 0
ex = 0
ey = 0
ans = 'Yes'
for i in range(N):
    t, x, y = map(int, input().split())
    T = t - et
    dist = x - ex + y - ey
    if T % 2 != dist % 2 or T < dist:
        ans = 'No'
        break
    et = t
    ex = x
    ey = y
print(ans)

Submission status: Accepted

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

pt, px, py = [0, 0, 0]
ans = 'Yes'
for t, x, y in XY:
    lim = t - pt
    need = abs(x-px) + abs(y-py)
    if lim < need or (lim-need)%2==1:
        ans = 'No'
        break
    pt, px, py = t, x, y

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]
t = [0]
x = [0]
y = [0]
for t_i, x_i, y_i in txy:
    t.append(t_i)
    x.append(x_i)
    y.append(y_i)
can = True
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dt < dist:
        can = False
    elif dist % 2 != dt % 2:
        can = False
if can == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
judge = 'Yes'
past_t = past_x = past_y = 0
for i in range(n):
    t, x, y = map(int,input().split())
    if t - past_t < x + y or ((t-past_t)-(x+y)) % 2 != 0:
        judge = 'No'
print(judge)

Submission status: Accepted

Solution code:
N = int(input())
now = [0] * 2
prev_t = 0

for i in range(N):
    t,x,y = map(int, input().split())
    distance = abs(x-now[0]) + abs(y-now[1])
    if distance <= t - prev_t and (t - prev_t - distance)%2 == 0:
        now = [x,y]
        prev_t = t
    else:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

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

t, x, y = 0, 0, 0
for i in place:
  next_t, next_x, next_y = i
  rest = (next_t - t) % (abs(next_x - x) + abs(next_y - y))
  if rest % 2 != 0 or (next_t - t) < (abs(next_x - x) + abs(next_y - y)):
    print('No')
    exit()
    
  t, x, y = next_t, next_x, next_y

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

pos_t=0
pos_x=0
pos_y=0

def judge(target_t,target_x,target_y,
          pos_t,pos_x,pos_y):

    #print(target_t,target_x,target_y,
    #        pos_t,pos_x,pos_y)

    t = abs(target_t-pos_t)
    x = abs(target_x-pos_x)
    y = abs(target_y-pos_y)

    #print(t,x,y)

    if x+y == t:
        #print("case1")
        return 0
    elif x == 0 and y== 0 and t%2==0:
        #print("case2")
        return 0
    elif ((x+y)%2 == 1) and (t%2==1) \
        and (x+y < t):
        #print("case3")
        return 0
    elif ((x+y)%2 == 0) and (t%2==0) \
        and (x+y<t):
        #print("case4")
        return 0
    else:
        return -1

no = 0
for i in range(n):
    t, x, y = map(int,input().split())
    ret = judge(t,x,y,pos_t,pos_x,pos_y)
    pos_t=t
    pos_x=x
    pos_y=y
    if ret == -1:
        no = 1

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

Submission status: Accepted

Solution code:
n = int(input())

f = False
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if f:
        continue
    if t < x + y:
        print('No')
        f = True
    if t % 2 == 0 and (x + y) % 2 == 1:
        print('No')
        f = True
    if t % 2 == 1 and (x + y) % 2 == 0:
        print('No')
        f = True
if not f:
    print('Yes')

Submission status: Accepted

Solution code:
#86

#入力（1次元）
N = int(input())
#入力（２次元）
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

ans = 'Yes'

for i in range(N):
    t = X[i][0] - X[i][1]- X[i][2]
    if t < 0 or X[i][0] % 2 != (X[i][1] + X[i][2]) % 2 :
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    txy = []
    for i in range(N):
        t,x,y = map(int, input().split())
        txy.append((t,x,y))
        
    xx = 0
    yy = 0
    for i, val in enumerate(txy):
        t,x,y = val
        tmp = abs(xx-x) + abs(yy-y)
        if tmp > t:
            print("No")
            sys.exit()
        tmptmp = (tmp - t) % 2
        if tmptmp == 1:
            print("No")
            sys.exit()
            
    print("Yes")
	
if __name__ == "__main__":
	main()