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: Wrong Answer

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

n = int(raw_input())

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

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

px = 0
py = 0
flag = True

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

	if dt < dx + dy:
		flag = False
		print str(t[i] + x[i] + y[i])
		break
	else:
		if (t[i] - (x[i] + y[i])) % 2 == 1:
			flag = False
			break
if flag:
	print "Yes"
else:
	print "No"

Submission status: Wrong Answer

Solution code:
def main():
     N = int(input())
     dic = {}
     for i in range(N):
         try:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
         except Exception:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
     f = False
     index = 0
     coordinate = None
     for j in dic.items():
         if not f:
            index = j[0]
            coordinate = j[1]
         else:
             distance = abs(j[1][0]-coordinate[0])+abs(j[1][1]-coordinate[1])
             if j[0]-index>=distance and (j[0]-index)%2==distance%2:
                 continue
             else:
                 print('No')
                 exit()
     print('Yes')


if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log
from itertools import *
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())


n=input()
l=[]
x1,y1=0,0
flag=1
t1=0
for i in range(n):
	z=list(mp())
	t=z[0]
	t-=t1
	x=z[1]
	y=z[2]
	if (abs(x-x1)+abs(y-y1))<=t:
		if (abs(x-x1)+abs(y-y1))%2==1:
			if t%2==0:
				flag=0
		else:
			if t%2==1:
				flag=0
	else:
		flag=0
	x1,y1=x,y
	t1=t

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

Submission status: Wrong Answer

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

n = int(input())
tprev = 0
tdiff = 0
pos = [0, 0]
for i in range(n):
    t, x, y = list(map(int,input().split()))
    tdiff = t - tprev
    print(pos,tdiff,abs(x-pos[0])+abs(y-pos[1]))
    if(tdiff>=abs(x-pos[0])+abs(y-pos[1])):
        if((tdiff-(abs(x-pos[0])+abs(y-pos[1])))%2 == 0):
            tprev = t
            pos = [x, y]
        else:
            print('No')
            sys.exit()
    else:
        print('No')
        sys.exit()
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys


def main():
    n = int(input())
    t0 = x0 = y0 = 0
    for line in sys.stdin:
        t1, x1, y1 = map(int, line.split())
        d = abs(x1 - x0) + abs(y1 - y0)
        if (t0 - t1) % 2 != d % 2:
            print('No')
            return
        t0, x0, y0 = t1, x1, y1
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
n = int(input())
v = np.array([(0,0,0)]+[tuple(map(int, input().split( ))) for i in range(n)])


for i in range(n):
    if (v[i+1]+v[i]).sum()%2:
        print("No")
        exit()
    if v[i+1][0]-v[i][0]<abs(v[i+1][1:]-v[i][1:]).sum():
        print("No")
        exit()
print("Yes")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
v = np.array([(0,0,0)]+[tuple(map(int, input().split( ))) for i in range(n)])


for i in range(n):
    if (v[i+1]+v[i]).sum()%2:
        print("No")
        exit()
    if v[i+1][0]-v[i][0]<abs(v[i+1][1:]-v[i][1:]).sum():
        print("No")
        exit()
print("Yes")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = 0
y = 0
t = 0
flag = True
for _ in range(N):
    new_t, new_x, new_y = [int(i) for i in input().split()]
    gap_t = new_t - t
    gap_x = new_x - x
    gap_y = new_y - y
    total_move = gap_x + gap_y
    possible_nums = list(range(-gap_t, gap_t+1, 2))
    if total_move in possible_nums:
        pass
    else:
        flag = False
        break

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

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 27.09.2020 23:57:30

import sys

N = int(input())

t1, x1, y1 = 0, 0, 0

for i in range(N):
    t, x, y = map(int, input().split())
    dx = abs(x - x1)
    dy = abs(y - y1)
    dt = t - t1
    d = dx + dy
    # print(f"{dt=}{d=}")

    if (d <= dt) & (dt % 2 == d % 2):
        pass
    else:
        print("No")
        exit()

    t1, x1, y1 = t, x, y

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
now,nowx,nowy=0,0,0
out = "Yes"
for i in range(N):
    t,x,y = list(map(int,input().split()))
    D = abs(x-nowx)+abs(y-nowy)
    T = t-now
    if D<=T and T%2==D%2:
        now,nowx,nowy = t,x,y
        continue
    else:
        now,nowx,nowy = t,x,y
        out="No"
print(out)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

n = map(int,readline().split())
data = list(map(int,read().split()))

t,x,y = 0,0,0
it = iter(data)
for ti,xi,yi in zip(it,it,it):
    dif = abs(x-xi) + abs(y-yi)
    if(ti-t < dif)|(dif%2 != (ti-t)%2):
        print('No')
        exit()
    t,x,y = ti,xi,yi
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
s = (0,0,0)
for _ in range(N):
    t, x, y = map(int, input().split())
    t0, x0, y0 = s
    if abs(x-x0) + abs(y-y0) <= t-t0 and (abs(x-x0) + abs(y-y0))%2==(t-t0)%2:
        s = (t,x,y)
        continue
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
 
n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    if (abs(x - prevx) + abs(y - prevy)) > (t - prevt) or (t - prevt) % 2 != (abs(x - prevx) + abs(y - prevy)) % 2:
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("Yes" if ans else "No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    totalt = t - prevt
    totald = abs(x - prevx) + abs(y - prevy)
    if totald > totalt or (totald % 2) != (totalt % 2):
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("Yes" if ans else "No")

Submission status: Accepted

Solution code:
N = int(input())
x_pred = 0
y_pred = 0
t_pred = 0
ans = 'Yes'
for i in range(N):
    t,x,y = map(int,input().split())
    check = ((t-t_pred)-(abs(x-x_pred)+abs(y-y_pred)))
    if((check<0) or (check%2!=0)):
        ans = 'No'
    else:
        t_pred = t
        x_pred = x
        y_pred = y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

T = [0]
XY = [[0,0]]
for i in range(N):
    t, *xy = map(int, input().split())
    T.append(t)
    XY.append(xy)

for i in range(1,N+1):
    tmp_t = T[i] - T[i-1]
    tmp_cnt = abs(XY[i][0] - XY[i-1][0]) + abs(XY[i][1] - XY[i-1][1])
    if tmp_t < tmp_cnt:
        print('No')
        exit()
    else:
        if (tmp_t - tmp_cnt)%2 != 0:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
# from itertools import product, takewhile
def calc_min_path(current_c, next_c):
    x = abs(current_c[1]-next_c[1])
    y = abs(current_c[2]-next_c[2])
    return x+y


def is_movable(current_c, next_c):
    move_count = next_c[0] - current_c[0]
    min_path = calc_min_path(current_c, next_c)
    if move_count == min_path:
        return True
    if move_count < min_path:
        return False
    if move_count > min_path:
        must_move_count = move_count-min_path
        if must_move_count % 2 == 0:
            return True
        else:
            return False


def main():
    N = int(input())
    coordinate = [[int(x) for x in input().split(" ")] for _ in range(N)]
    coordinate.insert(0, [0, 0, 0])

    for i in range(N):
        if not is_movable(coordinate[i], coordinate[i+1]):
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
arr_t = [0]
arr_x = [0]
arr_y = [0]
flag = 0

for i in range(N):
  t, x, y = list(map(int, input().split()))
  arr_t.append(t)
  arr_x.append(x)
  arr_y.append(y)

for i in range(N):
  if arr_t[i+1]-arr_t[i] < abs(arr_x[i+1]-arr_x[i])+abs(arr_y[i+1]-arr_y[i]):
    flag = 1
  elif ((arr_t[i+1]-arr_t[i])-abs(arr_x[i+1]-arr_x[i])+abs(arr_y[i+1]-arr_y[i]))%2 == 0:
    flag = 0
  else:
    flag = 1

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

Submission status: Accepted

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

pre = [0, 0, 0]
jdg = True
for t, x, y in txy:
    d = abs(x - pre[1]) + abs(y - pre[2])
    tt = t - pre[0]
    if tt - d >= 0 and (tt - d) % 2 == 0:
        jdg = True
        pre = [t, x, y]
    else:
        jdg = False
        break
        
print('Yes' if jdg else 'No')

Submission status: Accepted

Solution code:
n, *lst = map(int, open(0).read().split())
start = [0, 0, 0]
for i in range(n):
  tmplst = lst[3 * i : 3 * i + 3]
  tmp =  (tmplst[0] - start[0]) - (abs(tmplst[1] - start[1]) + abs(tmplst[2] - start[2]))
  if tmp < 0 or tmp % 2:
    print('No')
    quit()
  start = tmplst
else:
  print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
txy=[input().split() for i in range(n)]
if n!=1:
  for i in range(n-1):
    subX=abs(int(txy[i+1][1])-int(txy[i][1]))
    subY=abs(int(txy[i+1][2])-int(txy[i][2]))
    subT=int(txy[i+1][0])-int(txy[i][0])
    t=[]
    p=subT-subX-subY
    t.append(p)
  for i in range(len(t)):
      if t[i]<0 or t[i]%2==1:
        print('No')
      else:
        print('Yes')
else:
  subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])
  if subby>=0 and subby%2==0:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
result='Yes'

plan=[[0,0,0]]

for _ in range(N):
    plan.append(list(map(int,input().split())))

for i in range(1,N+1):
    t_sp=plan[i][0]-plan[i-1][0]
    dis=abs(plan[i][1]-plan[i-1][1])+abs(plan[i][2]-plan[i-1][2])

    if dis>t_sp or (dis-t_sp)%2==1:
        result='No'
        break

print(result)

Submission status: Accepted

Solution code:
import sys

a,b,c = 0,0,0
for i in range(int(input())):
    t,x,y = map(int,input().split())
    dif = abs(x - a) + abs(y - b)
    t_dif = t - c
    if dif > t_dif:
        print("No")
        sys.exit()
    if (t_dif % dif) % 2 == 0:
        a,b,c = x,y,t
    else:    
        print("No")
        sys.exit()
    
print("Yes")

Submission status: Accepted

Solution code:
import sys

a,b,tt = 0,0,0
for i in range(int(input())):
    t,x,y = map(int,input().split())
    dif = abs(x - a) + abs(y - b)
    if (t - tt) % dif != 0:
        print("No")
        sys.exit()
    a,b,tt = x,y,t
print("Yes")

Submission status: Accepted

Solution code:
#!python3

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


def judge(p1, p2):
    t = p2[0] - p1[0]
    d = abs(p1[1] - p2[1]) + abs(p1[2] - p2[2])
    if t < d:
        return False
    if (t - d) % 2 == 0:
        return True
    else:
        return False


def main():
    txy.sort()
    p1 = (0, 0, 0)
    for p2 in txy:
        if judge(p1, p2):
            continue
        else:
            print("No")
            return
    print("Yes")
    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
pt, px, py = 0, 0, 0
t,  x,  y  = 0, 0, 0
for i in range(N):
  pt, px, py = t, x, y
  t, x, y = map(int, input().split())
  T = t - pt
  X = abs(x - px)
  Y = abs(y - py)
  if T < X + Y or T % 2 != (X + Y) % 2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
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())
    
for i in range(N):
    if(x[i]+y[i] > t[i]):
        print("No")
        break
    if((x[i]+y[i])%2 == 0):
        if(t[i]%2 != 0):
            print("No")
            break
    else:
        if(t[i]%2 == 0):
            print("No")
            break
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
txy = nan(n)

ct = 0
cx, cy = 0, 0
flag = True
for i in range(n):
    t, x, y = txy[i]
    nx, ny = abs(cx - x), abs(cy - y)
    p = abs(nx - ny)
    if ct + t < nx + ny:
        flag = False
    if t > nx + ny and (ct + t) % 2 != p % 2:
        flag = False
    cx, cy = x, y
    ct = t

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())
v = [(0,0,0)]+[tuple(map(int, input().split( ))) for i in range(n)]


for i in range(n):
    if (v[i+1][0]+v[i][0]+v[i+1][1]+v[i][1]+v[i+1][2]+v[i][2])%2:
        print("No")
        exit()
    if v[i+1][0]+v[i][0]<abs(v[i+1][1]-v[i][1])+abs(v[i+1][2]-v[i][2]):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

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

ans = "Yes"
for i in range(1,N+1):
    dl = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    dt = t[i]-t[i-1]
    if (dt < dl)or((dt-dl) % 2 != 0):
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
maex=0
maey=0
maet=0
flag=0
for i in range(n):
    t,x,y=map(int,input().split())
    kyori=abs(x-maex)+abs(y-maey)
    jikan=t-maet
    if jikan>=kyori and (jikan-kyori)%2==0:
        flag+=0
    else:
        flag=1
    maex=x
    maey=y
    maet=t
print('Yes' if flag==0 else 'No')

Submission status: Accepted

Solution code:
N, = map(int, input().split())
tt, aa, bb = 0, 0, 0
for _ in range(N):
    t, a, b = map(int, input().split())
    d = abs(aa-a) + abs(bb-b)
    if d <= t - tt and (t-tt-d) % 2 == 0:
        pass
    else:
        print("No")
        break
    aa, bb, tt = a, b, t
else:
    print("Yes")

Submission status: Accepted

Solution code:
def manh(coord_x, coord_y):
    return abs(coord_x + coord_y)

def main():
    N = int(input())
    nt, nx, ny = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        d = manh(x - nx, y - ny)
        T = t - nt

        if d > T or (d - T) & 1:
            print("No")
            return
        
        nt, nx, ny = t, x, y
    
    print("Yes")
        

if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(n):
  sa=li[i+1][0]-li[i][0]
  kyori=abs(li[i+1][1]-li[i][1])+abs(li[i][2]-li[i+1][2])
  if kyori==0 or sa<kyori or sa%2!=kyori%2:
    print("No")
    exit()
  else:
    continue
print("Yes")

Submission status: Accepted

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

for i in range(0,N):
	ti, xi, yi = map(int, input().split())
	T.append(ti)
	X.append(xi)
	Y.append(yi)
 
message = "Yes"
 
for i in range(1,N + 1):
	time_dis = T[i] - T[i-1]
	x_dis = abs(X[i] - X[i-1])
	y_dis = abs(Y[i] - Y[i-1])
	total_dis = x_dis + y_dis

	if time_dis >= total_dis and (time_dis - total_dis) % 2 == 0:
		continue
		
	else:
		message = "No"
		break
		
print(message)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    T = Scanner.int_list_list(N)
    x, y, t = 0, 0, 0
    for i in T:
        len = abs(i[1] - x) + abs(i[2] - y)
        time = i[0] - t
        if len <= time and len % 2 == time % 2:
            t, x, y = i
        else:
            print("No")
            return
    print("Yes")
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
pos = [0, 0]
time = 0
p = "Yes"
for i in range(N):
  A = list(map(int, input().split()))
  dt = A[0] - time
  dx = A[1] - pos[0]
  dy = A[2] - pos[1]
  if dt < dx + dy or dt % 2 != (dx + dy) % 2:
    p = "No"
  pos[:] = [A[1], A[2]]
  time = A[0]
print(p)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

N = int(input())
prev = [0, 0, 0]
for _ in range(N):
    t, x, y = map(int, input().split())
    if abs(x - prev[1]) + abs(y - prev[2]) > t - prev[0]:
        print('No')
        exit()
    elif (x-prev[1] + y - prev[2]) % 2 != (t-prev[0])%2:
        print('No')
        exit()
    else:
        prev = [t, x, y]
print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
px,py,ct=0,0,0
for i in range(N):
  t,x,y=map(int,input().split())
  dis=abs(px-x)+abs(py-y)
  mt=t-ct
  if dis>mt or (mt-dis)%2==1:
    print("No")
    exit(0)
  px,py,ct=x,y,t
print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

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


def solve(N: int, t, x, y):
    ct = 0
    cx = 0
    cy = 0
    for i in range(N):
        r = t[i] - ct - abs(cx - x[i]) - abs(cy - y[i])
        if r < 0 or r & 1:
            return NO
        ct = t[i]
        cx = x[i]
        cy = y[i]
    return YES


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))
    print(solve(N, t, x, y))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = map(int, input().split())
flag = True
if (x0+y0)%2 != t0%2 or x0+y0 > t0:
    flag = False
for _ in range(N-1):
    t1, x1, y1 = map(int, input().split())
    if (x1+y1-x0-y0)%2 != (t1-t0)%2 or (x1+y1-x0-y0) > t1-t0:
        flag = False
    t0, x0, y0 = t1, x1, y1
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    px = py = pt = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        d = abs(x - px) + abs(y - py)
        if d > t - pt or d % 2 != (t - pt) % 2:
            print("No")
            exit()
        pt, px, py = t, x, y
    print("Yes")

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

t, x, y = 0, 0, 0
flag = True
for i in range(n):
    ti, xi, yi = map(int, input().split())
    dist = abs(xi-x) + abs(yi-y)
    dt = ti - t
    if dist <= dt and dist % 2 == dt % 2:
        flag = True
    else:
        flag = False
        break
    t, x, y = ti, xi, yi

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

Submission status: Accepted

Solution code:
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
def Manhattan(a,b):
    l_1=abs(a[1]-b[1])+abs(a[2]-b[2])
    return l_1
ok=0
if a[0][0]>=a[0][1]+a[0][2] and((a[0][0]%2==0 and (a[0][1]+a[0][2])%2==0) or (a[0][0]%2==1 and (a[0][1]+a[0][2])%2==1)):
    ok+=0
else:
	ok+=1
#print(a)
for i in range(n-1):
    if Manhattan(a[i],a[i+1])>a[i+1][0]-a[i][0]:
        ok+=1
    elif (Manhattan(a[i],a[i+1])%2==0 and (a[i+1][0]-a[i][0])%2==0) or (Manhattan(a[i],a[i+1])%2==1 and (a[i+1][0]-a[i][0])%2==1):
        ok+=0
    else:
        ok+=1
#print(ok)
if ok!=0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    tn = xn = yn = 0
    for i in range(n):
        t, x, y = list(map(int, input().rstrip('\n').split()))
        d = abs(xn - x) + abs(yn - y)
        td = t - tn
        if d - td > 0:
            print("No")
            exit()
        elif (d - td) % 2 != 0:
            print("No")
            exit()
        xn = x
        yn = y
        tn = t
    print("Yes")


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
def solve():
  n = int(input())
  time = 0
  x,y = 0,0
  travel = True
  for i in range(n):
    t,nx,ny = (int(i) for i in input().split())
    timediff = t-time
    xdif = abs(nx-x)
    ydif = abs(ny-y)
    
    movement = xdif + ydif
    if movement > timediff:
      travel = False
    elif movement == time:
      pass
    else:
      if movement%2 == timediff%2:
        pass
      else:
        travel = False
    x,y = nx,ny
    time = t
  print("Yes") if travel else print("No")
    
solve()

Submission status: Accepted

Solution code:
def main(N, moves):
    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: #時間差=経路差 ⇒ OK
            pre_t, pre_x, pre_y = new_t, new_x, new_y #次のステップ(途中地点)へ
        elif remain_time > 0: #時間差＞経路差の場合：場合分けが必要
            if remain_time % 2 == 0: #残り時間が偶数 ⇒ 行ったり来たりの往復で時間を潰せばOK
                pre_t, pre_x, pre_y = new_t, new_x, new_y #次のステップへ
            else: 
                return "No" #残り時間が奇数 ⇒ ダメ
        else:
            return "No" #時間差＞経路差の場合 ⇒ 何やってもダメ
    return "Yes"

N = int(input())
moves = [] 
for i in range(N):
    moves.append([int(j) for j in input().split()]) #与えられた途中地点を代入
print(main(N, moves))

Submission status: Accepted

Solution code:
N = int(input())
flag = True
t_0,x_0,y_0 = 0,0,0

for i in range(N):
    t_1,x_1,y_1 = map(int,(input().split()))
    dt = t_1 - t_0
    dx = abs(x_1 - x_0)
    dy = abs(y_1 - y_0)
    if dx+dy<=dt and (dx+dy+dt)%2==0:
        t_0,x_0,y_0 = t_1,x_1,y_1
    else:
        flag = False
        break

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

Submission status: Accepted

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

currentT = 0;
currentX = 0;
currentY = 0;
flag = True;

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

    timeDiff = t - currentT;
    xDiff = abs(x - currentX);
    yDiff = abs(y - currentY);

    currentT = t;
    currentX = x;
    currentY = y;

    leftMoveCount = timeDiff - (xDiff + yDiff);

    if leftMoveCount < 0:
        flag = False;
        break;
    elif leftMoveCount % 2 == 0:
        continue;
    else:
        flag = False;
        break;

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ARC087C
import sys
import math

n=int(input())

pt=0
px=0
py=0

for i in range(0,n):
	tmp = input().split()
	t,x,y = list(map(lambda a: int(a), tmp))

	if((t-pt)%2!=(abs(x-px)+abs(y-py))%2):
		print("No")
		sys.exit()
	if(t-pt<(abs(x-px)+abs(y-py))):
		print("No")
		sys.exit()
	pt=t
	px=x
	py=y
#	print("{} {} {}".format(t,x,y))
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = [0 for i in range(N + 1)]
x = [0 for i in range(N + 1)]
y = [0 for i in range(N + 1)]
t[0] = 0
x[0] = 0
y[0] = 0

def valid_move(t1, x1, y1, t2, x2, y2):
    d = abs(x1 - x2) + abs(y1 - y2)
    return (t2 - t1) >= d and (t2 - t1) % 2 == d % 2

for i in range(1, N + 1):
    t[i], x[i], y[i] = map(int, input().split())
    
yes = True
for i in range(N):
    if not valid_move(t[i], x[i], y[i], t[i + 1], x[i + 1], y[i + 1]):
        yes = False
        break
        
if yes:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for _ in range(N):
    t, x, y = map(int,input().split())
    tn = t - t0
    xn = x - x0
    yn = y - y0
    if abs(xn) + abs(yn) <= tn and (abs(xn) + abs(yn)) % 2 == (tn % 2):
        t0 = t
        x0 = x
        y0 = y
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys

def manhattan(px, py, x, y):
    return abs(px-x) + abs(py-y)

N = int(input())
pt = 0
px = 0
py = 0
for i in range(N):
    t, x, y = map(int,input().split())
    dist = manhattan(px, py, x, y)
    time = t - pt
    if (time % 2 != dist % 2) or time < dist:
        print("No")
        sys.exit()
    else:
        pt = t
        px = x
        py = y
print("Yes")

Submission status: Accepted

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

for i in range(n):
    t = a[i+1][0]-a[i][0]
    z = a[i+1][1]-a[i][1]+a[i+1][2]-a[i][2]
    if t>=z and (t-z)%2==0:
        continue
    print('No')
    exit()

print('Yes')

Submission status: Accepted

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

t = txy[0][0]
d = abs(txy[0][1] + abs(txy[0][2]))
if t < d or t % 2 != d % 2:
    print('No')
    exit()

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

print('Yes')

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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