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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
now = nx = ny = 0
for i,z in enumerate(a):
    t,x,y = z
    nex = now + abs(nx-x) + abs(ny-y)
    if nex > t or (t-nex)%2:
        print('No')
        break
    now = t
    nx = x; ny = y
    # print(now)
else:
    print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
X=0
Y=0
T=0
f=1
for _ in range(n):
    t,x,y=map(int,input().split())
    dx=abs(x-X)
    dy=abs(y-Y)
    dt=t-T
    if dt>=dx+dy and dt%2==(dx+dy)%2:
        pass
    else:
        f=0
print("Yes" if f else "No")

Submission status: Accepted

Solution code:


def main():
    import sys

    input = sys.stdin.readline
    N = int(input())
    prev = 0
    x = 0
    y = 0

    for i in range(N):
        a, b, c = map(int, input().split())
        dis = abs(b - x) + abs(c - y)
        diff = a - prev
        if diff >= dis and diff % 2 == dis % 2:
            prev = a
            x = b
            y = c
        else:
            print("No")
            exit(0)
    print("Yes")


main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    TXY = [[int(i) for i in input().split()] for j in range(N)]
    time = 0
    px = 0
    py = 0
    for t, x, y in TXY:
        move = abs(py-y) + abs(px - x)
        if (t-time) < move or (t - time) % 2 != move % 2:
            return print("No")
        time = t
        px = x
        py = y
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
t0 = x0 = y0 = 0
for _ in range(N):
    t1, x1, y1 = map(int, input().split())
    d = abs(x1 - x0) + abs(y1 - y0)
    if d > t1 - t0 or d % 2 != (t1 - t0) % 2:
        print('No')
        exit()
    t0, x0, y0 = t1, x1, y1
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    time = abs(txy[i][0] - txy[i+1][0])
    dis = abs(txy[i][1] - txy[i+1][1]) + abs(txy[i][2] - txy[i+1][2])
    if time % 2 == dis % 2:
        if dis % 2 == 0:
            if dis == 0 or dis == time:
                continue
            else:
                ans = False
                break
        else:
            if dis == 1 or dis == time:
                continue
            else:
                ans = False
                break
    else:
        ans = False
        break
    
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
v = [0, 0]
c = 0
ans = 1
for _ in range(n):
    t, x, y = map(int, input().split())
    m = t - c
    d = abs(x - v[0]) + abs(y - v[1])
    if d > m:
        ans = 0
    if d % 2 != m % 2:
        ans = 0
    v = [x, y]
    c = t
print("Yes" if ans == 1 else "No")

Submission status: Accepted

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

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

    for i in range(N):
        dt = t[i + 1] - t[i]
        dist = abs((x[i + 1] - x[i])) + abs((y[i + 1] - y[i]))
        if dist > dt:
            print('No')
            return
        if ((dt % 2 == 0) != (dist % 2 == 0)):
            print('No')
            return
    
    print('Yes')


def main():
    solve()

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
t = [0]
x = [0]
y = [0]
count = 0
for i in range(n):
    val_list = input().split()
    if val_list:
        t.append(int(val_list[0]))
        x.append(int(val_list[1]))
        y.append(int(val_list[2]))
for i in range(n):
    distance = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if distance > t[i + 1] - t[i]:
        break
    elif distance == t[i + 1] - t[i]:
        count += 1
    elif distance - (t[i + 1] - t[i]) % 2 == 0:
        count += 1
    else:
        break
if count == n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(n):
    dt = plan[i+1][0] - plan[i][0]
    dx = plan[i+1][1] - plan[i][1]
    dy = plan[i+1][2] - plan[i][2]
    if (dx+dy)%2 == 0:
        if dt%2 == 0 and dt >= dx+dy:
            pass
        else:
            print('No')
            exit()
    else:
        if dt%2 == 1 and dt >= dx+dy:
            pass
        else:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

a, b = 0, 0
c = 0
ans = 0
for i in range(n):
    t, x, y = map(int, input().split())
    if (t - c) % 2 == (abs(x - a) + abs(y - b)) % 2 and abs(x - a) + abs(y - b) <= t - c:
        continue
    else:
        ans = 1
if ans == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
arr = [[0,0,0]]
flg = 0
for i in range(n):
  arr.append(list(map(int, input().split())))
  if arr[i+1][0]-arr[i][0] < arr[i+1][1] + arr[i+1][2] - arr[i][1] - arr[i][2] or (arr[i+1][0]-arr[i][0]) % 2 != (arr[i+1][1] + arr[i+1][2] - arr[i][1] - arr[i][2]) % 2:
    flg = 1
if flg == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())

p, sx, sy = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d, dx, dy = t - p, abs(x - sx), abs(y - sy)
    if (dx + dy) > d or (dx + dy - d) % 2 == 1:
        print("No")
        exit()
    p, sx, sy = t, x, y
else:
    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(1,n+1):
    t[i], x[i], y[i] = map(int, input().split())

for i in range(1, n+1):
    a = abs(t[i] - t[i-1])
    b = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if a>=b and a%2 == b%2:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
def ans():
    N = int(input())
    old_t, old_x, old_y = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())

        dt = t - old_t
        dx = x - old_x
        dy = y - old_y
        if abs(dx) + abs(dy) > dt or (abs(dx) + abs(dy)) % 2 != dt % 2:
            print('No')
            return
    
    print('Yes')
    return

ans()

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(list(map(int, input().split())))
tn = 0
xn = 0
yn = 0
isOk=True
for sl in S:
    ti = sl[0]
    xi = sl[1]
    yi = sl[2]
    t = ti-tn
    distance = abs(xi-xn)+abs(yi-yn)
    if (t>=distance)&((t-distance)%2==0):
        pass
    else:
        isOk=False
        break
if isOk:
    print('Yes')
else:
    print('No')

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())
flag=True
for i in range(1,n+1):
    d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    tt=t[i]-t[i-1]
    if d<=tt and d%2==tt%2:
        continue
    else:
        flag=False
        break
print('Yes') if flag else print('No')

Submission status: Accepted

Solution code:
N=int(input())
T=[]
X=[]
Y=[]
for i in range(N):
    t,x,y=map(int,input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
count=0
t,x,y=0,0,0
for i in range(N):
    # |x-X|+|y-Y|<=t-T
    # t%2=(x+y)%2
    if abs(X[i]-x)+abs(Y[i]-y)<=T[i]-t and T[i]%2==(X[i]+Y[i])%2:
        count+=1
    t,x,y=T[i],X[i],Y[i]
if count==N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c = input()
data = []
for s in range(0,int(c)):
  data.append(list(map(int, input().split())) )

nexttime = 0
nextx = 0
nexty = 0


for s in range(0, len(data)):
  nexttime = data[s][0]
  nextx = data[s][1]
  nexty = data[s][2]
  if ( (nexttime < nextx+nexty) or ((((nextx + nexty) ) % 2) != (nexttime % 2) ) ):
    print("No")
    exit()


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

cnt = 0

for l in range(len(L)-1):
    length = abs(L[l+1][1] - L[l][1]) + abs(L[l+1][2] - L[l][2]) - abs(L[l+1][0] - L[l][0]) 
    if not (length <= 0 and length % 2 == 0):
        print("No")
        break
    else:
        cnt += 1

if cnt == len(L) - 1:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = []
x = []
y = []
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)

t.append(0)
x.append(0)
y.append(0)

for i in range(N):
    if t[i] >= x[i] + y[i]:
        if t[i] % 2 == (x[i] + y[i]) % 2:
            t[i + 1] -= t[i]
            x[i + 1] -= x[i]
            y[i + 1] -= y[i]
        else:
            print('No')
            quit()
            #break
    else:
        print('No')
        quit()
        #break
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
ans = True
for _ in range(N):
  t, x, y = map(int, input().split())
  if t < x + y:
    ans = False
  if t % 2 != (x + y) % 2:
    ans = False
if ans:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())
Point = [tuple(map(int,input().split(" "))) for _ in range(N)]
# スタート地点(t,x,y)
Now = (0,0,0)
flag = 0
for Next in Point:
    # 次の点へのマンハッタン距離    
    dist = abs((Next[1]+Next[2]) - (Now[1]+Now[2]))
    # 移動に使える時間
    T = Next[0]-Now[0]
    if T<dist:
        flag=1
        break
    else:
        if T%2!=dist%2:
            flag=1
            break
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    l_c = int(input())
    trips = []
    for i in range(l_c):
        trips.append([int(v) for v in input().split(' ')])
    pos = [0, 0, 0]
    for t in trips:
        time = t[0] - pos[0]
        dist = abs(pos[1] - t[1]) + abs(pos[2] - t[2])
        e_or_o = [time % 2, dist % 2]
        if time < dist or e_or_o[0] != e_or_o[1]:
            print('No')
            exit(0)
        pos = t
    print('Yes')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    l_c = int(input())
    trips = []
    for i in range(l_c):
        trips.append([int(v) for v in input().split(' ')])
    pos = [0, 0, 0]
    for t in trips:
        time = t[0] - pos[0]
        n = pos[1] - t[1]
        if n < 0:
            n *= -1
        n2 = pos[2] - t[2]
        if n2 < 0:
            n2 *= -1
        dist = n + n2

        e_or_o = [time % 2, dist % 2]
        if time < dist or e_or_o[0] != e_or_o[1]:
            print('No')
            exit(0)
        pos = t
    print('Yes')

Submission status: Accepted

Solution code:

def resolve():
    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())

    def main():
        for i in range(N):
            if T[i+1]-T[i]==abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i]):
                continue
            else:
                if T[i + 1] - T[i] > abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])\
                and (T[i + 1] - T[i])%2==(abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i]))%2:

                    continue
                else:
                    return 'No'
        return 'Yes'

    print(main())



resolve()

Submission status: Accepted

Solution code:
import sys
import math

def main():
    def iterate_position():
        yield list(map(int, sys.stdin.readline().rstrip().split()))

    N = int(sys.stdin.readline().rstrip())
    now_position = [0, 0, 0]
    for x in range(N):
        try:
            next_position = next(iterate_position())
            dt = next_position[0] - now_position[0]
            dx = next_position[1] - now_position[1]
            dy = next_position[2] - now_position[2]
            if dt < abs(dx) + abs(dy):
                print("No")
                sys.exit()
            check = dt - (dx + dy)
            if check % 2 == 1:
                print("No")
                sys.exit()
            now_position = next_position
        except StopIteration:
            print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
now=[0,0,0]#t,x,y
f=True
for i in range(n):
    t,x,y=map(int,input().split())
    k=abs(x-now[1])+abs(y-now[2])
    l=abs(t-now[0])
    if not(k<=l and abs(k-l)%2==0):
        f=False
    now=[t,x,y]
print("Yes" if f else "No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    TXY = [[0, 0, 0]]
    TXY.extend([list(map(int, input().split())) for _ in range(N)])

    result = 'Yes'
    for i in range(N):
        t1, x1, y1 = TXY[i - 1]
        t2, x2, y2 = TXY[i]
        td = abs(t1 - t2)
        xyd = abs(x1 - x2) + abs(y1 - y2)
        if xyd <= td and xyd % 2 == td % 2:
            continue
        else:
            result = 'No'
            break
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = [[0, 0, 0]]
ans = "No"
for _ in range(n):
    l.append(list(map(int, input().split())))

for i in range(n):
    dt = abs(l[i + 1][0] - l[i][0])
    dx = abs(l[i + 1][1] - l[i][1])
    dy = abs(l[i+1][2]-l[i][2])
    if dt < dx + dy:
        break
    elif dt % 2 != (dx + dy) % 2:
        break
else:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
now = [0, 0, 0]
ans=True
for i in range(n):
    t, x, y = map(int, input().split())
    if t-now[0] < abs(x-now[1])+abs(y-now[2]):
        ans=False
        
    else:
        if ((t-now[0])-(abs(x-now[1])+abs(y-now[2]))) % 2 == 0:
            now = [t, x, y]
        else:
            ans=False
        
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

judge = True
for i in range(len(T)):
    if i == 0:
        time = T[i][0]
        distance = sum(T[i][1:])
    else:
        time = T[i][0] - T[i-1][0]
        distance = abs(sum(T[i][1:]) - sum(T[i-1][1:]))
    if time >= distance and (time - distance) % 2 == 0:
        continue
    else:
        judge = False
        break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
t=[]
x=[]
y=[]
flag=False
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):
    t[i]=t[i]-t[i-1]
    x[i]=x[i]-x[i-1]
    y[i]=y[i]-y[i-1]

for i in range(N):
  if((x[i]+y[i])%2==t[i]%2 and abs(x[i])+abs(y[i])<=t[i]):
    flag=True
  else:
    flag=False
    break

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

Submission status: Accepted

Solution code:
N=int(input())
t=[]
x=[]
y=[]
for i in range(N):
  t1,x1,y1=[int(i) for i in input().split()]
  t.append(t1)
  x.append(x1)
  y.append(y1)
flag=1
for i in range(N):
  if t[i]<x[i]+y[i]:
    flag=0
  if t[i]%2 != (x[i]+y[i])%2:
    flag=0
if flag==1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

ans = "Yes"
for i in range(N):
	norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])
	move = (P[i+1][0]-P[i][0]) - norm
	if ((move%2 != 0) or (move < 0)):
		ans = "No"
		break
	
print(ans)

Submission status: Accepted

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

for _ in range(n):
    t, x, y = map(int, input().split())
    dist = abs(x-p[0]) + abs(y-p[1])
    if dist > t-time:
        print('No')
        exit()
    else:
        if (t-time)%dist==0:
            time += dist
            p = [x, y]
        else:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
#abc086_c
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)
ans = "Yes"
for i in range(1,N+1):
    if X[i]-X[i-1]+Y[i]-Y[i-1]<=T[i]-T[i-1] and (T[i]-T[i-1])%2 == (X[i]-X[i-1]+Y[i]-Y[i-1])%2:
       continue
    else:
        ans="No"
        break
print(ans)

Submission status: Accepted

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

for i in range(n):
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]
    d = x + y
    if d <= t and (d - t) % 2 == 0:
        continue
    else:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

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

x = 0
y = 0
for i in range(n):
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]
    d = x + y
    if d <= t and (d - t) % 2 == 0:
        continue
    else:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

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

x = 0
y = 0
for i in range(n):
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]
    d = x + y
    if d <= t and (d - t) % 2 == 0:
        continue
    else:
        print('No')
        quit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
L = [[0,0,0]]
A = 0
for i in range(N):
    t,x,y = map(int, input().split())
    L.append([t,x,y])
for i in range(N):
    dx = abs(L[i+1][1])-abs(L[i][1])
    dy = abs(L[i+1][2])-abs(L[i][2])
    dt = L[i+1][0] - L[i][0]
    if dt < dx + dy or (dt - (dx + dy)) % 2 != 0:
        A += 1
        break
if A == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
pre_t=0
pre_x=0
pre_y=0
flg="Yes"
for i in range(N):
    t,x,y=map(int,input().split())
    dt=t-pre_t
    dist=abs(x-pre_x) + abs(y-pre_y)
    pre_t=t
    pre_x=x
    pre_y=y
    if(dist > dt ):
        flg="No"
        break
    if((dist)%2 != dt%2):
        flg="No"
        break
print(flg)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


N = int(input())
t, x, y = 0, 0, 0
ans = 'No'
for s in sys.stdin.readlines():
    nt, nx, ny = map(int, s.split())
    T = nt - t
    D = abs(nx - x) + abs(ny - y)
    if T < D or T % 2 != D % 2:
        break
    t, x, y = nt, nx, ny
else:
    ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    t,x,y = 0,0,0
    ans = 'Yes'
    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 dt < dist or dist%2 != dt%2:
            ans = 'No'
            break
        else:
            t,x,y = ti,xi,yi
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
TXY=[list(map(int,input().split(' '))) for i in range(N)]
t,x,y=0,0,0
for i,j,k in TXY:
    chk=(i-t-(abs(x-j)+abs(y+k)))
    if chk<0 or chk%2!=0:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
u=0
p=0
q=0
for _ in range(n):
  t,x,y=map(int,input().split())
  if abs(p-x)+abs(q-y)<=t-u and (t-u-abs(p-x)-abs(q-y))%2==0:
    u=t
    p=x
    q=y
  else:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

t0, x0, y0 = 0, 0, 0
cnt = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    diff_t = t-t0
    distance = abs(x0-x)+abs(y0-y)
    if diff_t >= distance and (diff_t - distance == 0 or (diff_t - distance) % 2 == 0):
        cnt += 1
    t0, x0, y0 = t, x, y

print('Yes' if cnt == n else 'No')

Submission status: Accepted

Solution code:
T, X, Y = 0, 0, 0
cnt = 0
for n in range(int(input())):
  t, x, y = map(int,input().split())
  dist = abs(x-X) + abs(y-Y)
  dt = t - T
  cnt += all([dist <= dt, (dist - dt) % 2 == 0])
  T, X, Y = t, x, y
print("YNeos"[n+1!=cnt::2])

Submission status: Accepted

Solution code:
for _ in range(int(input())):
  t, x, y = map(int,input().split())
  if (t+x+y)%2 + (t<x+y):
    s = 1
    break
  s = 0
print("YNeos"[s::2])

Submission status: Accepted

Solution code:
N = int(input())
T, X, Y = 0, 0, 0
cnt = 0
for _ in range(N):
  t, x, y = map(int,input().split())
  dist = abs(x-X) + abs(y-Y)
  dt = t - T
  cnt += all([dist <= dt, (dist - dt) % 2 == 0])
  T, X, Y = t, x, y
print("YNeos"[N!=cnt::2])

Submission status: Accepted

Solution code:
n = int(input())
travel_list = [[0,0,0]]
for i in range(n):
    travel_list.append([int(num) for num in input().split(" ")])
for i in range(1,n+1):
    t_step = travel_list[i][0]-travel_list[i-1][0]
    x_step = abs(travel_list[i][1]-travel_list[i-1][1])
    y_step = abs(travel_list[i][2]-travel_list[i-1][2])
    if x_step+y_step>t_step:
        print("No")
        exit()
    elif (t_step - (x_step + y_step))%2==1:
        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())
# x+y > t　No
# x+y とtの偶奇が違うならNo
# ここを思いつけば勝ち！
  if ((x+y) > t) or ((x+y +t)%2):
    print("No") 
    exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
nowt, nowx, nowy = 0, 0, 0
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())
    dift, difxy = t - nowt, abs(x - nowx) + abs(y - nowy)
    if dift < difxy or dift&1 != difxy&1:
        ans = 'No'
print(ans)

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

Submission status: Accepted

Solution code:
n=int(input())
txy = [list(map(int,input().split())) for _ in range(n)]
f=0
for i in range(n):
    if(txy[i][0]<txy[i][1]+txy[i][2] or txy[i][0]%2!=(txy[i][1]+txy[i][2])%2):
        f=1
        print("No")
        break
if f==0:
    print("Yes")

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

l = []
for i in range(N):
    if i == 0:
        before = list(map(int, input().split()))
        road = before[0] - before[1] - before[2]
        #print(road)
        if road < 0:
            ans = 'No'
            break
        elif road >= 0 and road%2 == 1:
            ans = 'No'
            break
        else:
            ans = 'Yes'
    else:
        after = list(map(int, input().split()))
        road = after[0] - before[0] - after[1] + before[1] - after[2] + before[2]
        #print(road)
        if road < 0:
            ans = 'No'
            break
        elif road >= 0 and road%2 == 1:
            ans = 'No'
            break
        else:
            ans = 'Yes'
            before = after

print(ans)

Submission status: Accepted

Solution code:
import sys

N = int(input())



#plan=list()
success = "Yes"

(t0,x0,y0)=(0,0,0)
for i in range(N):
    (t,x,y)=map(int, input().split())
    #plan.append([t,x,y])

    d=(x-x0)+(y-y0)
    dt=t-t0
    #print(d,dt)

    if d>dt or (d % 2 != dt %2):
        success = "No"
        break
 
    (t0,x0,y0)=(t,x,y)

print(success)

Submission status: Accepted

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

now = [0, 0]
for p in txy:
    d = abs(p[1] - now[0]) + abs(p[2] - now[1])
    if p[0] % 2 == d % 2 and p[0] >= d:
        continue
    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:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t=0
x=0
y=0
ans ="Yes"
for i in range(n):
  tt,xx,yy = map(int,input().split())
  dif = abs(x-xx)
  dif +=abs(y-yy)
  if dif>(tt-t) or dif%2 !=(tt-t)%2:
    ans = "No"
    break;
  t=tt
  x=xx
  y=yy
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=v=w=0
for _ in range(n):
  t,x,y=map(int,input().split())
  dt,dx,dy=t-s,x-v,y-w
  if (dt+dx+dy)%2>0 or dt<abs(dx)+abs(dy): print('No'); break
  s,v,w=t,x,y
else: print('Yes')

Submission status: Accepted

Solution code:
def ynf(dt,dx,dy):
#    print(dt,dx,dy)
    if (dx+dy)>dt:
        return 0
    if (dx+dy)%2 != dt%2:
        return 0
    return 1

icase=0
if icase==0:
    n=int(input())
    txy=[]
    for i in range(n):
        txy.append(list(map(int,input().split())))
elif icase==1:
    n=2
    txy=[]
    txy.append([3, 1, 2])
    txy.append([6, 1, 1])
elif icase==2:
    n=1
    txy=[]
    txy.append([2, 100, 100])
elif icase==3:
    n=2
    txy=[]
    txy.append([5, 1, 1])
    txy.append([100, 1, 1])

dt=txy[0][0]
dx=txy[0][1]
dy=txy[0][2]

yn=1
for i in range(n):
    if ynf(dt,dx,dy)==0:
        yn=0
        break
    elif i==n-1:
        break
    else:
        dt=txy[i+1][0]-txy[i][0]
        dx=txy[i+1][1]-txy[i][1]
        dy=txy[i+1][2]-txy[i][2]
        
if yn==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import math


def validate(src_point, tgt_point, duration):
    s_x, s_y = src_point
    t_x, t_y = tgt_point

    if not 0 <= s_x <= 1e5: return False
    if not 0 <= s_y <= 1e5: return False
    if not 0 <= t_x <= 1e5: return False
    if not 0 <= t_y <= 1e5: return False

    dist = math.fabs(t_x - s_x) + math.fabs(t_y - s_y)

    if duration % 2 == 1:
        if dist <= duration and dist % 2 == 1:
            return True
        else:
            return False
    else:
        if dist <= duration and dist % 2 == 0:
            return True
        else:
            return False

N = int(input())
# src_point = (0, 0)
prev_point = (0, 0)
prev_time = 0

flag = True
for i in range(N):
    cur_time, *cur_point = list(map(int, input().split()))

    if not validate(prev_point, cur_point, cur_time - prev_time):
        flag = False
        break

    prev_time = cur_time
    prev_point = cur_point
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
txy = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
         if i != 0:
                  if not (txy[i][0] - txy[i-1][0] >= abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2]) and (txy[i][0] - txy[i-1][0]) % 2 == (abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])) % 2):
                           print("No")
                           exit()
         else:
                  if not (txy[i][0]  >= txy[i][1]  + txy[i][2]  and txy[i][0]  % 2 == (txy[i][1] + txy[i][2]) % 2):
                           print("No")
                           exit()
print("Yes")

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
grid = []
grid.append([0,0,0])
ans = "Yes"
for i in range(1,n+1):
    array = list(map(int,input().split()))
    grid.append(array)
for i in range(n):
    if np.abs(grid[i+1][1]-grid[i][1])+np.abs(grid[i+1][2]-grid[i][2]) > grid[i+1][0]-grid[i][0]:
        ans="No"
    elif (grid[i+1][0] - grid[i][0] - np.abs(grid[i+1][1]-grid[i][1]) - np.abs(grid[i+1][2]-grid[i][2])) % 2 == 1:
        ans="No"
print(ans)

Submission status: Accepted

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

point = [0, 0, 0]

for i in range(N):
    time = trip[i][0]-point[0]
    x = abs(trip[i][1]-point[1])
    y = abs(trip[i][2]-point[2])
    if ((time-x-y) % 2) or (time < (x+y)):
        print('No')
        exit()
    point = trip[i]

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
ans = 'Yes'
t_before,x_before,y_before = 0,0,0
for _ in range(n):
    t,x,y = map(int, input().split())
    delta_x = abs(x-x_before)
    delta_y = abs(y-y_before)
    delta_t = t-t_before
    if ((delta_x+delta_y)%2 != delta_t%2) or (delta_x+delta_y>delta_t):
        ans = 'No'
        break
    t_before = t
    x_before = x
    y_before = y
print(ans)

Submission status: Accepted

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

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])


import math

def calculate(n,arr):

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

    result = True

    for i in range(1,n+1):

        diff = arr[i][0] - arr[i-1][0]

        distance = int(math.fabs(arr[i][1] - arr[i-1][1]) + math.fabs(arr[i][2] - arr[i-1][2]))

        if diff < distance:
            result = False
            break

        if (diff + distance) % 2 == 1:
            result = False
            break

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


calculate(N,ARR)

Submission status: Accepted

Solution code:
n=int(input())
txy=[list(map(int,input().split())) for _ in range(n)]
if abs(txy[0][1])+abs(txy[0][2])>abs(txy[0][0]) or (txy[0][0]+txy[0][1]-txy[0][2])%2!=0:
  print('No')
  exit()
for i in range(1,n):
  dx,dy,dt=txy[i][1]-txy[i-1][1],txy[i][2]-txy[i-1][2],txy[i][0]-txy[i-1][0]
  if abs(dx)+abs(dy)>abs(dt) or (dx+dy-dt)%2!=0:
    print('No')
    exit()
print('Yes')