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())
t, x, y = 0, 0, 0

for i in range(0, n):
    t_next, x_next, y_next = map(int, input().split())
    xy_diff = abs(x_next-x)+abs(y_next-y)
    t_diff = t_next - t
    if(xy_diff > t_diff or (xy_diff - t_diff)%2!=0):
        print('No')
        exit(0)
    else:
        t, x, y = t_next, x_next, y_next

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

t1, x1, y1 = 0, 0, 0
for _ in range(N):
    t2, x2, y2 = list(map(lambda x: int(x), input().split(' ')))
    dist = abs(x1 - x2) + abs(y1 - y2)
    t_diff = t2 - t1

    # print(dist, t_diff)
    if t_diff < dist:
        print('No')
        exit()

    elif (t_diff - dist) % 2 == 1:
        print('No')
        exit()

    else:
        t1, x1, y1 = t2, x2, y2

print('Yes')

Submission status: Accepted

Solution code:
import sys
N=int(input())
for i in range(N):
    t,x,y=map(int,input().split())
    if (x+y)%2==t%2 and x+y<=t:
        pass
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
N=int(input())
for i in range(N):
  t,x,y=map(int,input().split())
  if (x+y)%2==t%2 and x+y<=t:
    pass
  else:
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

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

flag = 1
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)
    time = abs(t[i+1] - t[i])
    d = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])#移動した距離の合計を求める
    if d > time or (d % 2) != (time%2): #timeは距離の最大値なのでdより小さいとアウト、パリティ条件があるのでmod 2があってないとアウト
        flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = int(input())
l = []
for i in range(a):
    dist = [int(i) for i in input().split()]
    l.append(dist)
 
start = [0,0,0]
flg = True
for i in l:
    i[0] = i[0] -start[0]
    i[1] = i[1] -start[1]
    i[2] = i[2] -start[2]
    if (i[1]+ i[2])%2 != i[0]%2:
        print('No')
        flg = False
        break
    elif i[0] < abs(i[1]) + abs(i[2]):
        print('No')
        flg = False
        break
    else:
        start = [i[0],i[1],i[2]]
if flg:
    print('Yes')

Submission status: Accepted

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

flag=1
for i in range(1,N+1):
  t_tmp,x_tmp,y_tmp=map(int,input().split())
  t.append(t_tmp)
  x.append(x_tmp)
  y.append(y_tmp)
  time=abs(t[i-1]-t[i])
  d=abs(x[i-1]-x[i])+abs(y[i-1]-y[i])
  if d>time or (d%2)!=(time%2):
    print("No")
    flag=0
    break
    
if flag==1:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for i in range(N):
  a = list(map(int, input().split()))
  if a[0] < sum(a) - a[0]:
    print("No")
    exit()
  if (sum(a) - a[0] - a[0])%2 != 0:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
prv = [0,0,0]
for _ in range(N):
  t, x, y = map(int,input().split())
  n = 0
  dif = (t- prv[2]) - (abs(prv[0]-x) + abs(prv[1]-y))
  if dif >= 0 and dif%2 == 0:
    prv = [x,y,t]
  else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
pre_x = 0
pre_y = 0
pre_t = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    way_min = x-pre_x+y-pre_y
    if (t-pre_t-way_min) % 2 == 0 and t-pre_t>=way_min:
        pre_x=x
        pre_y=y
        pre_t=t
    else :
        flag=False
        break
if(flag):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
manhattan = lambda x,y: abs(x[0] - y[0]) + abs(x[1] - y[1])

def solve():
    n = int(input())
    table = [[0, 0, 0]] + [list(map(int, input().rstrip("\n").split())) for i in range(n)]

    for i in range(1, len(table)):
        t = (table[i][0] - table[i - 1][0] - manhattan(table[i - 1][1:], table[i][1:]))
        if t < 0 or t % 2 != 0:
            return "No"
    return "Yes"

print(solve())

Submission status: Accepted

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

Next=TXY.pop(0)
Flag=1

for i in range(N):
    D=Next[0]-abs(Next[1])-abs(Next[2])
    if D<0 or D%2!=0:
        Flag=0
        break
    else:
        if TXY==[]:
            break
        else:
            Next2=TXY.pop(0)
            Next=[Next2[0]-Next[0],Next2[1]-Next[1],Next2[2]-Next[2]]

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

Submission status: Accepted

Solution code:
def fun():

  x = int(input())
  y = [input().split() for i in range(x)]

  place = [0,0]
  time = 0
  
  for i in y:
    move = abs(int(i[1]) - place[0]) + abs(int(i[2]) - place[1])
    if (int(i[0]) - time) >= move and ((int(i[0]) - time) - move) % 2 == 0:
      place[0] = int(i[1])
      place[1] = int(i[2])
      time = int(i[0])
    else:
      return "No"
  return "Yes"

print(fun())

Submission status: Accepted

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

t0,x0,y0 = 0,0,0

for i in range(N):
    t,x,y = TXY[i][0],TXY[i][1],TXY[i][2]
    if t-t0 >= abs(x-x0)+abs(y-y0) and (t-t0)%2 == abs(x-x0+y-y0)%2:
        t0,x0,y0 = t,x,y
        continue
    else:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

t = []
x = []
y = []

# 旅行プランが実行可能か
can = True

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

    if x[i] + y[i] <= t[i]:
        if (t[i] - x[i] - y[i]) % 2 == 1:
            can = False
    else:
        can = False

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

Submission status: Accepted

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

r = 'Yes'

cur = [0, 0]
now = 0
for t, x, y in X:
    td = t - now
    d = abs(x - cur[0]) + abs(y - cur[1])
    # print(td, d)
    if d > td or d % 2 != td % 2:
        r = 'No'

    cur[0], cur[1] = x, y
    now = t

print(r)

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())
txy = []
for i in range(n):
    t,x,y = map(int, input().split())
    txy.append([t, x, y])
txy.sort()
if n==1:
    if txy[0][1]+txy[0][2]!=txy[0][0]:
        print("No")
    else:
        print("Yes")
    exit()
for i in range(n-1):
    a = txy[i+1][0] - txy[i][0]
    ds = abs(txy[i+1][1]-txy[i][1]) + abs(txy[i+1][2]-txy[i][2])
    if a >= ds and (a-ds)%2==0:
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
px=0 
py=0 
f=1 
pt=0 
n=int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    z=abs(x-px)+abs(y-py)
    px=x 
    py=y  
  #  pt=t   
   # print(z,t-pt )
    if z<=(t-pt) and z%2==(t-pt)%2:
        pass 
    else:
       # print(i)
        f=0 
    pt=t  
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
n=int(input())
x0=0
y0=0
t0=0
ans='Yes'
for i in range(n):
    t1,x1,y1=map(lambda x: int(x), input().split())
    dt=t1-t0
    dx=x1-x0
    dy=y1-y0
    if dt<abs(dx)+abs(dy):
        ans='No'
    if dt%2!=(abs(dx)+abs(dy))%2:
        ans='No'
    t0=t1
    x0=x1
    y0=y1
print(ans)

Submission status: Accepted

Solution code:

n = int(input())
routes = []
for _ in range(n):
	time,x,y = map(int,input().split())
	routes.append((time,x,y))

now_x = 0
now_y = 0
time_now = 0
res = "Yes"
for time,x,y in routes :
	dist = abs(now_x - x) + (abs(now_y - y))
	t = time - time_now
	if t-dist < 0 or (t-dist)%2 != 0:
		res = "No"
		break
	now_x = x
	now_y = y
	time_now = time
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
for i in range(N):
  t,x,y=map(int,input().split())
  if (x+y)%2==t%2 and x+y<=t:
    pass
  else:
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
def odd_even_same(p):
  t,x,y=p[0],p[1],p[2]
  if (x+y)%2==t%2:
    return 1
  else:
    return 0
def dist_judge(p):
  t,x,y=p[0],p[1],p[2]
  if t >= x+y:
    return 1
  else:
    return 0
N=int(input())
p=[]
for i in range(N):
  p.append(list(map(int,input().split())))
for i in p:
  if odd_even_same(i)*dist_judge(i):
    pass
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
# C
n = int(input())
plan = []
for _ in range(n):
    t, x, y = map(int, input().split())
    plan.append((t, x, y))

flag = 'Yes'
elapsed = 0
now = (0, 0)
for p in plan:
    t, x, y = p[0], p[1], p[2]
    nx, ny = now[0], now[1]

    time = t - elapsed
    distance = abs(x - nx) + abs(y - ny)
    buff = time - distance
    if (buff>=0) and (buff%2 == 0):
        elapsed = t
        now = (x, y)
    else:
        flag = 'No'
        break
print(flag)

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
 
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
    break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
  
  if ans == "No":
    break
 
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0 # current, default(0, 0, 0)
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  dist = abs((xi - x) + (yi - y))
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi  # update
  else:
    ans = "No"
    break
 
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t0, x0, y0 = 0, 0, 0
t, x, y = t0, x0, y0 # current
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacement = (xi - x) + (yi - y)
  distance = abs(displacement)
  dt = ti - t
  # 時間差が移動距離より大きく、時間差-距離がeven_numberだったら
  # 寄り道しても往復してたどり着ける
  if dt >= distance and (dt - distance) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
    break
 
print(ans)

Submission status: Accepted

Solution code:
import sys
n = int(input())
T, X, Y = [], [], []

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):
    t = T[i]
    x = X[i]
    y = Y[i]

    if x + y > t:
        print('No')
        sys.exit()
    if t % 2 != (x + y) % 2:
        print('No')
        sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
def checkGo(x,y,t):
    if abs(x) + abs(y) > t or (t - (abs(x) + abs(y)) ) % 2 == 1:
        return False
    return True
count = int(input())
data = []
for i in range(count):
    data.append(list(map(int,input().split())))
passTime = 0
beforeX = 0
beforeY = 0
for i in data:
    time = i[0]
    x = i[1]
    y = i[2]
    if not checkGo(x - beforeX, y - beforeY, time - passTime):
        print("No")
        exit()
    passTime = i[0]
    beforeX = i[1]
    beforeY = i[2]
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for _ 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:
def test():
    n = int(input())
    t = [0]*(n+1)
    x = [0]*(n+1)
    y = [0]*(n+1)
    ans = True
    for i in range(n):
        a = list(map(int,input().split()))
        t[i+1] = a[0]
        x[i+1] = a[1]
        y[i+1] = a[2]
    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 or dist%2 != dt%2:
            ans = False
    print("Yes" if ans else "No")


if __name__ == "__main__":
    test()

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())
t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)

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

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

Submission status: Accepted

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

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


def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    t.insert(0,0)
    x.insert(0,0)
    y.insert(0,0)
    for i in range(1,N+1):
        if t[i]%2 != (x[i]+y[i])%2:
            print("No")
            return 
        if t[i]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1]):
            print("No")
            return 
    print("Yes")
    

    return


# Generated by 1.1.6 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:
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())

    t_before, x_before, y_before = 0, 0, 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        diff_t = t - t_before
        diff_d = abs(x - x_before) + abs(y - y_before)
        if diff_t >= diff_d and (diff_t - diff_d) % 2 == 0:
            t_before, x_before, y_before = t, x, y
            pass
        else:
            print("No")
            break
    else:
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
T,X,Y=[],[],[]
for i in range(N):
  TT,XX,YY=map(int,input().split())
  T.append(TT)
  X.append(XX)
  Y.append(YY)
ans=1
if(X[0]+Y[0]>T[0] or (T[0]-X[0]+Y[0])%2):
  ans=0
for i in range(N-1):
  Z=abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])
  if(Z>T[i+1]-T[i] or (T[i+1]-T[i]-Z)%2):
    ans=0
if(ans):
  print("Yes")
else:
  print("No")

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())
tb=0
xb=0
yb=0
c=0
for n in range(N):
  ta,xa,ya=map(int,input().split())
  td=ta-tb
  xd=abs(xa-xb)
  yd=abs(ya-yb)
  if td>=xd+yd and (td-xd-yd)%2==0:
    tb=ta
    xb=xa
    yb=ya
  else:
    c=1
    break

if c==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

count = 0

for i in range(0,N):
	x = A[i+1][0] - A[i][0] + A[i+1][1] - A[i][1] + A[i+1][2] - A[i][2]
	y = A[i+1][0] - A[i][0]
	if x%2==0 and x <= 2*y:
		count += 1

if count == N:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
# 整数 (縦 H 横 W の行列)
l=[list(map(int, input().split())) for i in range(n)]
l=[[0,0,0]]+l
#print(l)
for i in range(n):
    if abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])>l[i+1][0]-l[i][0]:
        print('No')
        break
    elif abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])==0:
        if (l[i+1][0]-l[i][0])%2!=0:
            print('No')
            break
    elif (l[i+1][0]-l[i][0])%(abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2]))!=0:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

L = [[0, 0, 0]] + L
ans = "Yes"
for i in range(N):
    t = L[i+1][0]-L[i][0]
    l = abs(L[i+1][1]-L[i][1]) + abs(L[i+1][2]-L[i][2])
    if t < l or (t-l)%2 == 1:
        ans = "No"
        break
        
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t,x,y = 0,0,0

for i in range(N):
  next_t,next_x,next_y = map(int,input().split())
  interval = next_t - t
  distant_x = int(next_x - x)
  distant_y = int(next_y - y)
  distant = distant_x + distant_y
  
  if(distant > interval):
    print('No')
    break
  elif( (interval - distant) % 2 == 1 ):
    print('No')
    break
  elif(i == N - 1):
    print('Yes')
    
    
  
  t , x , y = next_t , next_x , next_y

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
l=[[0,0,0]]

for _ in range(N):
    l.append(list(map(int,input().split())))
   
for i in range(N):
    temp=[l[i+1][0]-l[i][0],l[i+1][1]-l[i][1],l[i+1][2]-l[i][2]]
    
    if temp[0]<temp[1]+temp[2] or temp[0]%2!=(temp[1]+temp[2])%2:
        print("No")
        exit()
    else:
        continue
    print(temp)

print("Yes")

Submission status: Accepted

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

x=y=0
flg = False
for t,dx,dy in T:
    if abs(x-dx) + abs(y-dy) <= t and (t-dx-dy)%2==0:
        x,y = dx,dy
    else:
        break
else:
    flg = True

print("NYoe s"[flg::2])

Submission status: Accepted

Solution code:
import os
import math

n = int(input())
t,x,y = 0,0,0
for i in range(n):
    ti,xi,yi = (int(x) for x in input().split())
    dt = ti-t
    dist = abs(xi-x) + abs(yi-y)
    if dist>dt:
        print("No")
        exit()
    if dist%2!=dt%2:
        print("No")
        exit()
    t,x,y = ti,xi,yi
print("Yes")

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())
    move = abs(xi-x) + abs(yi-y)
    time = ti - t
    if (time < move) or (time-move)%2==1:
        print('No')
        exit()
    t,x,y = ti,xi,yi
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
l = []
for _ in range(n):
    l.append([int(x) for x in input().split()])
for j in range(n):
    if j == 0:
        i = l[0][1] + l[0][2]
        c = l[0][0]
    else:
        i = (l[j][1] - l[j-1][1]) + (l[j][2] - l[j-1][2])
        c = l[j][0] - l[j-1][0]
    if i > c:
        print("No")
        break
    elif i == c or (c - i) % 2 == 0:
        if j == n-1:
            print("Yes")
            break
        else: continue
    else:
        print("No")
        break

Submission status: Accepted

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

flag = True
i = 0
while(flag and i < n):
    if i == 0:
        dif = l[i][1] + l[i][2]
        t = 0
    else:
        dif = abs(l[i][1] - l[i-1][1]) + abs(l[i][2] - l[i-1][2])
        t = l[i-1][0]
    if l[i][0] - t < dif:
        flag = False
    elif (l[i][0] - t) % 2 != dif % 2:
        flag = False
    i += 1

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

Submission status: Accepted

Solution code:
N = int(input())
t_prev, x_prev, y_prev = 0,0,0

flag = True
for _ in range(N):
    t,x,y = map(int,input().split())
    k = abs(x-x_prev) + abs(y-y_prev)
    t_diff = t-t_prev
    
    if k > t_diff:
        flag = False
        break
    else:
        if (t_diff - k)%2 != 0:
            flag = False
            break
    t_prev, x_prev, y_prev = t,x,y

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

Submission status: Accepted

Solution code:
N = int(input())
ta = 0
xa = 0
ya = 0
for i in range(N):
  t,x,y = [int(x) for x in input().split()]
  tb = t-ta
  xb = abs(x-xa)
  yb = abs(y-ya)
  if tb-xb-yb<0 or (tb-xb-yb)%2!=0:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0,0])
ind = 0
for i in range(1,N+1):
    t2,x2,y2 = A[i][0],A[i][1],A[i][2]
    t1,x1,y1 = A[i-1][0],A[i-1][1],A[i-1][2]
    d = dist((x2,y2),(x1,y1))
    if not(t2-t1>=d and (t2-t1-d)%2==0):
        ind = 1
        break
if ind==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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


def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    pre_t, pre_x, pre_y = [0] * 3
    for i in range(N):
        dt = t[i] - pre_t
        move = x[i] - pre_x + y[i] - pre_y
        if dt < move or dt % 2 != move % 2: 
            print(NO)
            return
        pre_t = t[i]
        pre_x = x[i]
        pre_y = y[i]

    print(YES)
    return


# Generated by 1.1.5 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())
a=[list(map(int,input().split())) for _ in range(n)]
t,x,y=0,0,0
for T,X,Y in a:
    if T-t<X-x+Y-y or (T+X+Y)%2==1:
        print("No")
        exit()
    t,x,y=T,X,Y    
print("Yes")

Submission status: Accepted

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

t =[i[0] for i in txy]
x =[i[1] for i in txy]
y =[i[2] for i in txy]

t.insert(0,0)
x.insert(0,0)
y.insert(0,0)

ans ="Yes"
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 and dt%2 ==dist%2:
        continue
    else :
        ans ="No"
        break

print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc086/tasks/arc089_a
t0 = 0
x0 = 0
y0 = 0
n = int(input())
result = "Yes"

for i in range(n):
    t1, x1, y1 = list(map(int, input().split()))
    dt = t1 - t0
    dx = x1 - x0
    dy = y1 - y0
    if ((dx + dy)%2 == dt % 2) and (dx + dy) <= dt:
        t0 = t1
        x0 = x1
        y0 = y1
    else:
        result = "No"

print(result)

Submission status: Accepted

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

prev_x = 0
prev_y = 0
prev_t = 0
for i in range(N):

    x_i = abs(txy[i][1] - prev_x)
    y_i = abs(txy[i][2] - prev_y)
    t_i = (txy[i][0] - prev_t) - x_i - y_i

    if t_i == 0 or (t_i > 0 and t_i % 2 == 0):
        prev_t, prev_x, prev_y = txy[i][0], txy[i][1], txy[i][2]
    else:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
t1,x1,y1=[0,0,0]
for i in range(N):
  t2,x2,y2=[int(s) for s in input().split()]
  if t2-t1<abs(x2-x1)+abs(y2-y1) or (t2-t1)%2!=(x2+y2-x1-y1)%2:
    print("No")
    break
  else:
    t1,x1,y1==[t2,x2,y2]
else:
  print("Yes")

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    routes = list(map(string_to_int, inputs))
    current = [0, 0]
    t = 0
    for r in routes:
        diff_t = r[0] - t
        diff = abs(r[1] - current[0]) + abs(r[2] - current[1])

        if diff_t >= diff and (diff_t % 2) == (diff % 2):
            current = [r[1], r[2]]
            t = r[0]
        else:
            return 'No'
    return 'Yes'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Accepted

Solution code:
n=int(input())
t0,x0,y0=0,0,0
ans=True
for i in range(n):
    t,x,y = map(int, input().split())
    if (abs(x-x0)+ abs(y-y0)-(t-t0)) %2 !=0 or abs(x-x0)+abs(y-y0)>(t-t0):
        ans=False
    else:
        t0,x0,y0=t,x,y
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
t = 0
x = 0
y = 0
d = 0
ans = 'No'
for i in range(0, n):
    t_p = t
    x_p = x
    y_p = y
    t, x, y = [int(_) for _ in input().split()]
    d = abs(x-x_p) + abs(y-y_p)
    delta_t = t - t_p
    if delta_t < d:
        break;
    if delta_t >= d and (delta_t-d)%2 != 0:
        break;
    if i == n-1:
        ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
T = 0
X, Y = 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  d = abs(X-x) + abs(Y-y)
  if t-T < d or (d - (t-T)) % 2 == 1:
    print ("No")
    break
  else:
    X, Y = x, y
    T = t    
else:
  print ("Yes")

Submission status: Accepted

Solution code:
n = int(input())
ary = [list(map(int,input().split())) for _ in range(n)]
nv = [0,0]
count = 0
for i in range(n):
    a,b = abs(nv[0]-ary[i][1]),abs(nv[1]-ary[i][2])
    c = ary[i][0] - count
    if c < a+b:print("No");exit()
    elif (c - (a+b)) % 2 == 1:print("No");exit()
    nv = [ary[i][1],ary[i][2]]
    count += c
else:print("Yes")

Submission status: Accepted

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

for k in range(n):
    o = int(t[k+1])-int(t[k])
    p = int(x[k+1])-int(x[k])
    q = int(y[k+1])-int(y[k])
    if (o >= p+q) and ((o - (p+q))%2 == 0):
        b += 1
    else:
        b = b

if b == n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n=int(input())
TXY=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]

for i in range(1,n+1):
  dift=abs(TXY[i][0]-TXY[i-1][0])
  difx=abs(TXY[i][1]-TXY[i-1][1])
  dify=abs(TXY[i][2]-TXY[i-1][2])
  if (dift-(difx-dify))%2!=0 or dift<(difx+dify):
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=[input().split() for i in range(n)]
ans=0
for j in s:
    a=int(j[0])
    b=int(j[1])
    c=int(j[2])
    if a>=b+c:
        if a%2==0 and (b+c)%2==0 or a%2!=0 and (b+c)%2!=0:
            ans+=1
if ans==n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
lis =list()
lis.append([0, 0, 0])
sys.stdin.readline()
for e in sys.stdin:
  lis.append(list(map(int, e.split())))
for i in range(len(lis) - 1):
  d_t = lis[i + 1][0] - lis[i][0]
  man_dis = abs(lis[i + 1][1] - lis[i][1]) + abs(lis[i + 1][2] - lis[i][2])
  if d_t < man_dis or d_t % 2 - man_dis % 2 != 0:
    print("No")
    sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    txy = [[0,0,0]] + [[int(i) for i in input().split()] for j in range(N)]
    for i in range(1,N+1):
        cur_distance = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
        t_diff = txy[i][0] - txy[i-1][0]
        if t_diff < cur_distance or t_diff%2 != cur_distance%2:
            print("No")
            break
    else:
        print("Yes")
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def c_traveling():
    N = int(input())
    P = [[int(i) for i in input().split()] for j in range(N)]
    t = x = y = 0  # 初期時刻には原点にいる
    for t_next, x_next, y_next in P:
        dt = t_next - t
        dd = abs(x_next - x) + abs(y_next - y)
        if not (dt >= dd and (dt - dd) % 2 == 0):
            # 次の座標へのマンハッタン距離以上に制限時間がないと到達できない
            # 制限時間と距離の偶奇が一致していないと次の座標で止まるれない
            return 'No'
        t, x, y = t_next, x_next, y_next
    return 'Yes'

print(c_traveling())