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

pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = map(int, input().split())
  if (((t-pre_t) - (abs(x-pre_x) + abs(y-pre_y))) < 0
      or ((t-pre_t) - (abs(x-pre_x) + abs(y-pre_y))) % 2 != 0):
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
t, x, y = 0, 0, 0
for i in range(N):
    T, X, Y = TXY[i]
    z = (T - t) - ((X - x) + (Y - y))
    if z >= 0 and z % 2 == 0:
        t, x, y = T, X, Y
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
t, x, y = 0, 0, 0
for i in range(N):
    T, X, Y = TXY[i]
    z = (T - t) - ((X - x) + (Y - y))
    if z >= 0 and z % 2 == 0:
        t, x, y = T, X, Y
    else:
        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 (x + y) > t or (x + y + t) % 2 != 0:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
c=1
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
while c<n+1:
    a,b,d=(int(x) for x in input().split())
    t[c]=a
    x[c]=b
    y[c]=d
    c=c+1
c=1
kotae=0
while c<n+1:
    time=t[c]-t[c-1]
    kyori=x[c]-x[c-1]+y[c]-y[c-1]
    if time>=kyori:
        if time%2==kyori%2:
            kotae=1
        else:
            kotae=2
            break
    else:
        kotae=2
        break
    c=c+1
if kotae==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
t = []
x = []
y = []
N = int(input())
s = []
 
for i in range(N):
    t1, x1, y1 = [int(i) for i in input().split()]
    t.append(t1)
    x.append(x1)
    y.append(y1)
 
for i in range(N):
    if i == 0 and t[i] < abs(x[i]) + abs(y[i]):
        s.append(0)
    elif i > 0 and t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]):
        s.append(0)
    else:
        if (t[i] % 2 == 1 and x[i] % 2 == 0 and y[i] % 2 == 0) or (t[i] % 2 == 1 and x[i] % 2 == 1 and y[i] % 2 == 1):
            s.append(0)
        elif (t[i] % 2 == 0 and x[i] % 2 == 1 and y[i] % 2 == 0) or (t[i] % 2 == 0 and x[i] % 2 == 0 and y[i] % 2 == 1):
            s.append(0)
        else:
            s.append(1)
 
for i in s:
    if i == 0:
        print("No")
        break
else:
    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())
    
if t[0] >= x[0] + y[0] and t[0] % 2 == (x[0] + y[0]) % 2:
    flag = True
else:
    flag = False

for i in range(N-1):
    time = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if time < dist or time % 2 != dist % 2:
        flag = False
        break
        
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    n = int(input())
    t_, x_, y_ = 0, 0, 0
    for nn in range(n):
        t, x, y = map(int, input().split())
        diff = abs(x - x_) + abs(y - y_)
        if diff > t - t_ or (diff + t - t_) % 2:
            print('No')
            exit(0)
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main2(io):
	n=int(io())
	(t,x,y)=0,0,0
	for i in range(n):
		nt,nx,ny = map(int, io().split())
		dist = abs(x-nx) + abs(y-ny)
		duration = nt - t
		if dist > duration or dist%2 != duration%2:
			return False
		(t,x,y)=(nt,nx,ny)
	
	return True
	
def main(io):
	ret = main2(io)
	return 'Yes' if ret else 'No'

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Accepted

Solution code:
N = int(input())
txy = [list(map(int,input().split())) for _ in [0]*N]
tc,xc,yc = 0,0,0
for tn,xn,yn in txy:
    d = abs(xc-xn) + abs(yc-yn)
    dt = tn - tc
    if d > dt or (d+dt)%2 == 1 :
        print("No")
        break
    tc,xc,yc = tn,xn,yn
else:
    print("Yes")

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())
count = 0    
for j in range(1, N+1):
    if not(t[j]-t[j-1] >= abs(x[j]-x[j-1]) + abs(y[j]-y[j-1]) and (abs(x[j]-x[j-1]) + abs(y[j]-y[j-1])) % 2 == (t[j]-t[j-1]) % 2):
        print('No')
        count = 1
        break
        
if count == 0:
    print('Yes')

Submission status: Accepted

Solution code:
import sys

N = int(input())
t = [0]
x = [0]
y = [0]

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

for i in range(len(t)-1):
  T = t[i+1] - t[i]
  d = abs(x[i] - x[i+1]) + abs(y[i] - y[i+1])
  if not (d <= T and T%2 == d%2):
    print('No')
    sys.exit(0)
print('Yes')

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc086/tasks/arc089_a

n = int(input().split()[0])

txy_list = []

for i in range(0, n):
    work_list = list(map(int, input().split()))
    txy_list.append(work_list)

pre_txy = [0, 0, 0]
answer = False

for txy in txy_list:
    t, x, y = txy[0], txy[1], txy[2]
    pre_t, pre_x, pre_y = pre_txy[0], pre_txy[1], pre_txy[2]

    t_w, x_w, y_w = t - pre_t, abs(x - pre_x), abs(y - pre_y)
    work = t_w - (x_w + y_w)

    if (work % 2 == 0) and (work >= 0):
        pre_txy = txy
        continue
    else:
        break
else:
    answer = True

a = 'Yes' if answer else 'No'
print(a)

Submission status: Accepted

Solution code:
N = int(input())
z = [list(map(int, input().split())) for _ in range(N)]
# z[i][0]がt_i,z[i][1]がx_i,z[i][2]がy_iにそれぞれ対応している
for i in range(N):
	tmp = abs(z[i][1] + z[i][2])
	if z[i][0] % 2 == 0:
		if tmp % 2 == 0 and tmp <= z[i][0]:
			pass  # passとかかっこつけて使わなくていいなこれ
		else:
			print("No")
			exit()
	else:
		if tmp % 2 != 0 and tmp <= z[i][0]:
			pass
		else:
			print("No")
			exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
root=[]
t,x,y=0,0,0
for i in range(n):
    ti,xi,yi=map(int,input().split())
    if ti-t<xi-x+yi-y or (ti-t)%2!=(xi-x+yi-y)%2:
        print("No")
        break
    t,x,y=ti,xi,yi
else:
    print("Yes")

Submission status: Accepted

Solution code:
def is_possible(t0, x0, y0, t, x, y):
    dt, dm = t - t0, abs(x - x0) + abs(y - y0)
    if dt < dm:
        return False
    if (dt + dm) % 2 == 0:
        return True
    return False
n = int(input())
path = [(0, 0, 0)]
can_travel = True
for _ in range(n):
    t0, x0, y0 = path[-1]
    t, x, y = (int(i) for i in input().split())
    can_travel &= is_possible(t0, x0, y0, t, x, y)
    path.append((t, x, y))

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

Submission status: Accepted

Solution code:
N = int(input())
ex_x = 0
ex_y = 0
ex_t = 0
for _ in range(N):
    t, x, y = map(int, input().split(' '))
    dist = abs(x - ex_x) + abs(y - ex_y)
    dt = t - ex_t
    if dist > dt:
        print('No')
        break
    if dist % 2 != dt % 2:
        print('No')
        break
else:
    print('Yes')

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 :
    	print("No")
    	break
else:
    print("Yes")

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 :
    	print("No")
    	exit()
print("Yes")

Submission status: Accepted

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

for i in range(N):
    d = p[i+1][0] - p[i][0]
    diff = abs(p[i+1][1]-p[i][1]) + abs(p[i+1][2]-p[i][2])
    if d < diff or d % 2 != diff % 2:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

t, x, y = 0, 0, 0

for i in range(N):
    tn, xn, yn = map(int, input().split())
    l = abs(x-xn) + abs(y-yn)
    if l > tn - t or (l - (tn - t)) % 2 == 1:
        print('No')
        exit()
    t, x, y = tn, xn, yn
print('Yes')

Submission status: Accepted

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

t = 0
x = 0
y = 0

for i in range(N):
    distance = abs(x - data[i][1]) + abs(y - data[i][2])
    time = data[i][0] - t
    if distance > time :
        print('No')
        exit()
    if (distance - time) % 2 == 1:
        print('No')
        exit()

    t = data[i][0]
    x = data[i][1]
    y = data[i][2]

print('Yes')

Submission status: Accepted

Solution code:
n=int(input())

l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
c=[]
for i in range(n):
  t=l[i+1][0]-l[i][0]
  x=l[i+1][1]-l[i][1]
  y=l[i+1][2]-l[i][2]

  if t >=abs(x+y):
    if t%2 == (x+y)%2:
      c.append("Y")
    else:
      print("No")
      c.append("N")
      break
  else:
    print("No")
    c.append("N")
    break

if not "N" in c:
  print("Yes")

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:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys

N = int(input())
txy = [[int(i) for i in input().split()] for j in range(N)]

txy.insert(0, [0, 0, 0])

for i in range(1, N+1):
    t = txy[i][0] - txy[i-1][0]
    x = abs(txy[i][1] - txy[i-1][1])
    y = abs(txy[i][2] - txy[i-1][2])
    dis = x + y
    if dis > t:
        print('No')
        sys.exit()
    if (t - dis) % 2:
        print('No')
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

nx = 0
ny = 0#現在地
nt = 0
ans = "Yes"
for i in range(n):
  t,x,y = map(int, input().split())
  if ans == "Yes":
    if ((t - nt) % 2 == ((x-nx) + (y-ny)) % 2 and  ((x-nx) + (y-ny)) <= (t - nt)):
      nt = t
      nx = x
      ny = y
    else:
      ans = "No" 
  

print(ans)

Submission status: Accepted

Solution code:
n = [ input().split() for x in range(int(input()))]

curr = [0,0,0]
tf = 1

for t in n:
    plc = [int(x) for x in t]
    dif = plc[0]-curr[0] - (plc[1]-curr[1] + plc[2]-curr[2])
    if dif < 0 or dif % 2 != 0:
        tf = 0
        break

if tf:
    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 t<x+y or t%2!=(x+y)%2:print("No");exit()
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
tt,xx,yy=0,0,0
ans=0
for i in range(n):
  t,x,y=map(int,input().split())
  if (x-xx+y-yy)%2!=(t-tt)%2:
    ans=1
  if x-xx+y-yy>t-tt:
    ans=1
  tt,xx,yy=t,x,y
print("YNeos"[ans::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
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 = int(input())
p = [list(map(int, input().split())) for _ in range(N)]
ans = True
for i in range(N):
    if p[i][1] + p[i][2] > p[i][0]:
        ans = False
        break
    if (p[i][1] + p[i][2]) % 2 != p[i][0] % 2:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#086-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
Q=[]
for i in range(n):
    Q.append(IL())
t,x,y=0,0,0
for i in range(n):
    tt=Q[i][0]-t
    tx=Q[i][1]-x
    ty=Q[i][2]-y
    if tx+ty<=tt and (tt-(tx+ty))%2==0:
        t,x,y=Q[i]
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    a = input().split()
    t.append(int(a[0]))
    x.append(int(a[1]))
    y.append(int(a[2]))

bool = True
for i in range(N):
    d_t = abs(t[i+1]-t[i])
    d_xy = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if d_t < d_xy:
        bool = False
    elif d_t % 2 != d_xy % 2:
        bool = False

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in range(n):
    t, x, y = map(int, input().split())
    # print(t[i], x[i], y[i])
    if (t - (x + y)) < 0:
        ans += 1
    elif (t - (x + y)) % 2 == 0:
        pass
    else:
        ans += 1
if ans:
    print("No")
else:
    print("Yes")

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())
for i in range(1, N + 1):
    if t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]):
        print('No')
        exit()
    elif t[i] % 2 != (x[i] + y[i]) % 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())
flag = True
for i in range(N):
    if not(t[i] >= x[i] + y[i] and (x[i] + y[i]) %2 == t[i] %2):
        flag = False
        
print('Yes') if flag else print('No')

Submission status: Accepted

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

for i in range(N):
    d = abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2])
    td = txy[i+1][0] - txy[i][0]
    if d > td:
        print("No")
        exit()
    if d % 2 == 0 and td % 2 == 1:
        print("No")
        exit()
    elif d % 2 == 1 and td % 2 == 0:
        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)
for i in range(N):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
is_able = 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:
    is_able = False
  if dt % 2 != dist % 2:
    is_able = False
  
if is_able:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())

grid = [[0,0,0]]

for i in range(N):
  array = list(map(int, input().strip().split()))
  grid.append(array)
    
for h in range(N):
  bool = False
  t = 0
  x = 0
  y = 0
  t = grid[h+1][0] - grid[h][0]
  x = abs(grid[h+1][1] - grid[h][1])
  y = abs(grid[h+1][2] - grid[h][2])
  
  if grid[h+1][0] < 0 or grid[h+1][1] < 0 or grid[h+1][2] <0:
    break 

  if (t - x - y) % 2 == 0 and t >= x + y:
    bool = True
  
if bool:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

flag = True

for i in range(n):
    if abs(L[i][1] + L[i][2])>L[i][0] or (L[i][1] + L[i][2])%2 != L[i][0]%2:
        flag=False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#086 C Traveling
N =int(input())

List=[list(map(int,input().split())) for i in range(N)]
for i,l in enumerate(List):
    dt =List[i][0] - List[i-1][0]
    distance = abs(List[i][1] - List[i-1][1])+abs(List[i][2] - List[i-1][2])
        
    if i==0 and l[0] ==abs(l[1])+abs(l[2]):
        continue
    elif i==0 and l[0] !=abs(l[1])+abs(l[2]):
        print('No')
        exit()
    elif i!=0 and dt%2==distance%2 and distance<=dt:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
flag=True
ts=0
xs=0
ys=0
for i in range(n):
  te,xe,ye=map(int,input().split())
  if (te-ts)%2 == ((xe+ye)-(xs+ys))%2 and ((xe+ye)-(xs+ys))<=(te-ts):
    flag = True
  else:
    flag = False
    break;
  ts,xs,ys=te,xe,ye
if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n=int(raw_input())
t=[list(map(int,raw_input().split())) for i in range(n)]
flag=False
if n==1:
	if (t[0][1]+t[0][2])%2!=t[0][0]%2 or t[0][0]<t[0][1]+t[0][2]:
		flag=True
else:
	for i in range(n-1):
		dt=t[i+1][0]-t[i][0]
		dx=t[i+1][1]-t[i][1]
		dy=t[i+1][2]-t[i][2]
		if (dx+dy)%2!=dt%2 or dt<dx+dy:
			flag=True
			break

print "YNeos"[flag::2]

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

for i in range(1, N+1):
    if t[i]-t[i-1] < abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]):
        print('No')
        exit()
    elif t[i] % 2 != (x[i] + y[i]) % 2:
        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)
judge = 'Yes'

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

for i in range(1, N+1):
    if t[i]-t[i-1] < abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]):
        judge = 'No'
        break
    elif t[i] % 2 != (x[i] + y[i]) % 2:
        judge = 'No'
        break

print(judge)

Submission status: Accepted

Solution code:
N = int(input())
l = [[0]*3]*(N+1)
for n in range(N):
    l[n+1] = list(map(int, input().split()))

flag = True
for i in range(len(l)-1):
    d = l[(i+1)][0] - l[i][0]
    d_x = l[(i+1)][1] - l[i][1]
    d_y = l[(i + 1)][2] - l[i][2]
    distance = abs(d_x)+abs(d_y)
    if distance > d:
        flag = False
    elif distance % 2 != d % 2:
        flag = False

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

Submission status: Accepted

Solution code:
n = int(input())
nl = set(range(n))
txy = [[0, 0, 0]]
ans = 'Yes'
for i in nl:
    txy.append(list(map(int, input().split())))
    tmp = [txy[i+1][k] - txy[i][k] for k in range(3)]
    time_diff = tmp[0]
    time_even_odd = 'Even' if time_diff % 2 == 0 else 'Odd'
    distance_diff = abs(tmp[1]) + abs(tmp[2])
    distance_even_odd = 'Even' if distance_diff % 2 == 0 else 'Odd'
    if (time_diff < distance_diff) or (distance_even_odd != time_even_odd):
        ans = 'No'
        break
print(ans)

Submission status: Accepted

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

flag = 'Yes'
for i in range(n):
    if (t[i][1] +t[i][2]) > t[i][0] or (t[i][1] + t[i][2]) % 2 != t[i][0] % 2:
        flag = 'No'
print(flag)

Submission status: Accepted

Solution code:
n = int(input())

src_t = 0
src_x = 0
src_y = 0
success = True

for i in range(n):
    t, x, y = map(int, input().split(' '))
    if success == True:
        dt = t - src_t
        dist = abs(x - src_x) + abs(y - src_y)
        if dist <= dt and dist % 2 == dt % 2:
            src_t = t
            src_x = x
            src_y = y
            continue
        else:
            success = False

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    t_x_ys = []
    for _ in range(N):
        t_x_ys.append(list(map(int, input().split())))
    
    t_x_yi_minus_1 = [0, 0, 0]
    for t_x_yi in t_x_ys:
        ti_minus_1, xi_minus_1, yi_minus_1 = t_x_yi_minus_1
        ti, xi, yi = t_x_yi
        delta_t = ti - ti_minus_1
        dis = abs(xi - xi_minus_1) + abs(yi - yi_minus_1)

        if delta_t < dis:
            print("No")
            return 
        elif delta_t == dis:
            t_x_yi_minus_1 = t_x_yi
            continue
        else:
            if (dis - delta_t) % 2:
                print("No")
                return 
            else:
               t_x_yi_minus_1 = t_x_yi
               continue
             
    print("Yes")

main()

Submission status: Accepted

Solution code:
n = int(input())

prev_t = 0
prev_x = 0
prev_y = 0

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

    dt = t - prev_t
    dx = abs(x - prev_x)
    dy = abs(y - prev_y)
    dist = dx + dy

    if dist > dt:
        print('No')
        exit()
    
    if dt % 2 != dist % 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

r_init = [0, 0]
parity = 0 # 偶数
for i in range(1, n+1):
    dt = t[i] - t[i-1]
    dx = abs(x[i] - x[i-1])
    dy = abs(y[i] - y[i-1])
    dist = dx + dy

    if dist > dt:
        print('No')
        exit()
    
    if dt % 2 != dist % 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
txy=[[0, 0, 0]]+[list(map(int, input().split())) for i in range(n)]
def C(txy0, txy1):
    xx=txy1[1]-txy0[1]
    yy=txy1[2]-txy0[2]
    tt=txy1[0]-txy0[0]
    if xx+yy<=tt and (xx+yy-tt)%2==0:
        return True
    return False
if all(C(txy[i], txy[i+1]) for i in range(n)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

r_init = [0, 0]
parity = 0 # 偶数
for i in range(1, n+1):
    t_diff = t[i] - t[i-1]
    x_diff = abs(x[i] - x[i-1])
    y_diff = abs(y[i] - y[i-1])
    d_diff = x_diff + y_diff

    if d_diff > t_diff:
        print('No')
        exit()
    
    if (x[i] + y[i]) % 2 == 0:
        current_parity = 0
    else:
        current_parity = 1

    
    if t_diff % 2 == 0:
        # パリティ同じ
        if current_parity != parity:
            print('No')
            exit()
    else:
        # パリティ違う
        if current_parity == parity:
            print('No')
            exit()

    parity = current_parity
    

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) % 2 == 1 or (x + y) > t:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

for i in range(n):
    t_diff = txy[i+1][0] - txy[i][0]
    xy_diff = (txy[i+1][1] + txy[i+1][2]) - (txy[i][1] + txy[i][2])

    if t_diff % 2 != xy_diff % 2 or xy_diff > t_diff:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

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

tx = [0, (0, 0)]
ans = True

for i in range(n):
    dxy = (abs(xs[i][1][0]-tx[1][0])+abs(xs[i][1][1]-tx[1][1]))
    dt = xs[i][0]-tx[0]
    if dxy == dt:
        tx = xs[i]
    elif dxy < dt and (dt - dxy) % 2 == 0:
        tx = xs[i]
    else:
        ans = False
        break

msg = 'Yes' if ans else 'No'
print(msg)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    st, sx, sy = 0, 0, 0
    ans = []
    for _ in range(N):
        nt, nx, ny = map(int, input().split())
        if (nx + ny - sx - sy) > (nt - st):
            ans.append(False)
            continue
        if (nx + ny - sx - sy) % 2 != (nt - st) % 2:
            ans.append(False)
            continue
        ans.append(True)
    print('YNeos'[not all(ans)::2])


main()

Submission status: Accepted

Solution code:
n = int(input())
point_f = (0, 0, 0)
for i in range(n):
  point = list(map(int, input().split()))
  diff = point[0] - point_f[0] - abs(point[1] + point[2] - point_f[1] - point_f[2])
  if (diff >= 0 and diff % 2 == 0):
    if i == n - 1:
      print("Yes")
    else:
      continue
  else:
    print("No")
    break

Submission status: Accepted

Solution code:
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 != (dx + dy) % 2 or (dx + dy) > dt):
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (not (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt)):
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = True
  else:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

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

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

f = True

for i in range(0, n):
    l = abs(p[i][1] - p[i + 1][1]) + abs(p[i][2] - p[i + 1][2])
    dt = p[i + 1][0] - p[i][0]
    if l == 0 and dt == 1:
        f = False
        break
    if dt < l:
        f = False
        break
    else:
        if (dt - l) % 2 == 1:
            f = False
            break

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
def travel():
    t, x, y = 0, 0, 0
    for _ in range(N):
        nt, nx, ny = map(int, input().split())
        dt = nt - t
        dist = abs(nx - x) + abs(ny - y)
        if dt < dist:
            return False
        if (dt % 2) == (dist % 2):
            t, x, y = nt, nx, ny
        else:
            return False
    return True

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

Submission status: Accepted

Solution code:
n=int(input())
X=[[0,0,0]]
for i in range(n):
    t,x,y=map(int,input().split())
    X.append([t,x,y])
ans='Yes'
for i in range(n):
    if (X[i+1][0]-X[i][0]-abs(X[i+1][1]-X[i][1])+abs(X[i+1][2]-X[i][2]))%2==1 or (X[i+1][0]-X[i][0]-abs(X[i+1][1]-X[i][1])-abs(X[i+1][2]-X[i][2]))<0:
        ans='No'
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
listP = [[0,0,0]]
while True:
    try:
        listP.append(list(map(int,input().split())))
    except:
        break;

output = "Yes"

dxy=[0,0,0]
for t in range(N):
    for i in range(3):
        dxy[i] = listP[t+1][i]-listP[t][i]
    if (dxy[0] >= abs(dxy[1])+abs(dxy[2])) and ((dxy[0]-dxy[1]-dxy[2])%2 == 0) :
        continue
    else:
        output = "No"
        break

print(output)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


n = int(input())
c_now = [0, 0, 0]
for i in range(n):
    txy = list(map(int, input().split()))
    t = txy[0] - c_now[0]
    dis = abs(txy[1] - c_now[1]) + abs(txy[2] - c_now[2])
    if t < dis or (t - dis) % 2 != 0:
        print("No")
        sys.exit()
    c_now = txy
print("Yes")

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys



N = int(input())


def solve(l):
  td,xd,yd = [0,0,0]
  for i in range(N):
    t,x,y = l[i]
    td,xd,yd = [t-td, abs(x-xd), abs(y-yd)]
    if td < xd+yd:
      return False
    elif (td - xd - yd) & 1 > 0:
      return False
  return True


txy = [[0 for j in range(3)] for i in range(N)]
for i in range(N):
  txy[i] = list(map(int, input().split()))

if solve(txy):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
z_t = []*N
t0 = 0
x0 = 0
y0 = 0
ans = 'No'
for i in range(N):
    s = input().rstrip().split()
    z_t.append(s)

for i in range(N):
    dt = int(z_t[i][0]) - t0
    dx = abs(int(z_t[i][1]) - x0)
    dy = abs(int(z_t[i][2]) - y0)
    extra_t = dt - (dx+dy)
    if extra_t >=  0 and extra_t%2 == 0:
        t0 = int(z_t[i][0])
        x0 = int(z_t[i][1])
        y0 = int(z_t[i][2])
        if i == N-1:
            ans = 'Yes'
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
TXY = [list(map(int,input().split())) for _ in range(n)]
pret = 0
prex = 0
prey = 0
flag = True
for t,x,y in TXY:
    if t-pret < abs(x-prex)+abs(y-prey):
        flag = False
        break
    elif t-pret > abs(x-prex)+abs(y-prey)  and (abs(x-prex)+abs(y-prey))%2 != (t-pret)%2:
        flag = False
        break
    pret = t
    prex = x
    prey = y
if flag:
    print("Yes")
else:
    print("No")