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 = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
    #    print(str(s_x)+' '+str(s_y))

        if ((s_x != 0 or s_y !=0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
        elif  ((s_x == 0 and s_y == 0) )and (c!=count):
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1



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

Submission status: Accepted

Solution code:
n=int(input())

start=[0,0,0]

ans=0

for i in range(n):
    
    cont=list(map(int,input().split()))
    
    x=abs(start[0]-cont[0])
    
    y=abs(start[1]-cont[1])+abs(start[2]-cont[2])
    
    
    if x<y:
        ans=1
        
    else:
        if x%2==0:
            if y%2!=0:
                ans=1
                
        else:
            if y%2!=1:
                ans=1
                

        
    start=cont
        
if ans==0:
    print('Yes')
    
else:
    print('No')

Submission status: Accepted

Solution code:
import math
N = int(input())
T = [0]*110000
X = [0]*110000
Y = [0]*110000

for n in range(N):
    T[n+1], X[n+1], Y[n+1] = map(int, input().split())

res = True
for n in range(N):
    dt   = T[n+1] - T[n]
    dist = abs(X[n+1] - X[n]) + abs(Y[n+1] - Y[n])
    if dt < dist:
        res = False
    if dt % 2 != dist % 2:
        res = False

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

Submission status: Accepted

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

# In[40]:


N = int(input())
data = []
for i in range(N):
    tmp = list(map(int, input().split()))
    data.append(tmp)
# print(data)


# In[44]:


import numpy as np


# In[45]:


data = np.array(data)
diff = data[1:] - data[:-1]
diff = diff.tolist()
diff.insert(0, data[0].tolist())
# print(diff)


# In[46]:


flag = True
for idx,item in enumerate(diff):
#     print(idx, item)
    dist = abs(item[1]) + abs(item[2])
    if dist > item[0]:
        flag = False # "No"
    else:
        if (item[0] - dist)%2 != 0:
            flag = False 

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


# In[ ]:

Submission status: Accepted

Solution code:
N = int(input())

ans = 'Yes'

tt, tx, ty = 0, 0, 0,
for _ in range(N):
    t, x, y = map(int, input().split())
    ct = t-tt
    cx = abs(x-tx)
    cy = abs(y-ty)
    if ct < (cx+cy):
        ans = 'No'
        break
    if cx+cy == 0:
        ans = 'No'
        break
    if ct%2 != (cx+cy)%2:
        ans = 'No'
        break
    tt, tx, ty = t, x, y

print(ans)

Submission status: Accepted

Solution code:
# ABC086 C

def main():
    n = int(input())
    
    res = 'Yes'

    for i in range(n):
        t, x, y = map(int, input().split())
        
        if i != 0:
            t, x, y = t - t_prev, x - x_prev, y - y_prev

        if abs(x) + abs(y) > t:
            res = 'No'
            break
        elif (not t%2 and (x+y)%2) or (t%2 and not ((x+y)%2)):
            res = 'No'
            break
        
        t_prev, x_prev, y_prev = t, x, y
    
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
places = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
can_move = True
for i in range(1, n + 1):
  _t = places[i][0] - places[i - 1][0]
  _x = abs(places[i][1] - places[i - 1][1])
  _y = abs(places[i][2] - places[i - 1][2])

  if not _t >= _x + _y or not _t % 2 == (_x + _y) % 2:
    can_move = False
    break

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

Submission status: Accepted

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#from itertools import groupby as gb
#from itertools import permutations as perm
#from itertools import combinations as comb
#from fractions import gcd
#import numpy as np

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

n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]

nx = 0
ny = 0
nt = 0
for number in numbers:
    t=number[0]
    x = number[1]
    y = number[2]
    sa = abs(x-nx) + abs(y-ny)
    if sa%2 == (t-nt)%2 and sa <= (t-nt):
        nx = x
        ny = y
        nt = t
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
def can_not_realize(N, t_list, x_list, y_list) -> bool:
    # t_n と t_n+1 間 での移動判定
    for i in range(N):
        diff_t = t_list[i + 1] - t_list[i]
        diff_x = abs(x_list[i + 1] - x_list[i])
        diff_y = abs(y_list[i + 1] - y_list[i])

        sum_of_moving = diff_x + diff_y

        # 時刻t >= sum_of_moving でないと実現不可能
        if diff_t < sum_of_moving:
            return True

        # 偶奇が一致しないと実現不可能
        if not (diff_t % 2 == sum_of_moving % 2):
            return True

    return False

def actual(N, t_list, x_list, y_list):
    # t=0 で (0,0) を追加する
    t_list = [0] + t_list
    x_list = [0] + x_list
    y_list = [0] + y_list

    if can_not_realize(N, t_list, x_list, y_list):
        return 'No'

    return 'Yes'

N = int(input())

t_list, x_list, y_list = [], [], []

for _ in range(N):
  t, x, y = list(map(int, input().split()))
  t_list.append(t)
  x_list.append(x)
  y_list.append(y)
  
print(actual(N, t_list, x_list, y_list))

Submission status: Accepted

Solution code:
N = int(input())

tmp = [tuple(map(int,input().split())) for i in range(N)]

ct = cx = cy = 0
for t,x,y in tmp:
    dst = abs(cx - x) + abs(cy - y)
    if dst > t-ct or dst%2 != (t-ct)%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y
print('Yes')

Submission status: Accepted

Solution code:
import unittest


def is_ある時刻での判定(t, d):
    # 時刻t >= d でないと実現不可能
    if t < d:
        return True

    # 偶奇が一致しないと実現不可能
    if not (t % 2 == d % 2):
        return True

    return False


def can_not_realize(N, t_list, x_list, y_list) -> bool:
    # 各時刻ごとの判定
    for t, x, y in zip(t_list, x_list, y_list):
        d = x + y

        if is_ある時刻での判定(t, d):
            return True

    # t_n と t_n+1 間 での移動判定
    for i in range(N):
        if i + 1 >= N:
            break

        t = t_list[i + 1] - t_list[i]
        diff_x = abs(x_list[i + 1] - x_list[i])
        diff_y = abs(y_list[i + 1] - y_list[i])

        d = diff_x + diff_y

        if is_ある時刻での判定(t, d):
            return True

    return False


def actual(N, t_list, x_list, y_list):
    if can_not_realize(N, t_list, x_list, y_list):
        return 'No'

    return 'Yes'

N = int(input())

t_list, x_list, y_list = [], [], []
for _ in range(N):
  t, x, y = list(map(int, input().split()))
  t_list.append(t)
  x_list.append(x)
  y_list.append(y)
  
print(actual(N, t_list, x_list, y_list))

Submission status: Accepted

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

flag = True
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])

    if not t >= x + y or not t % 2 == (x + y) % 2:
        flag = False
        break

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

Submission status: Accepted

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

def main():
    n = int(input())
    t = 0
    x = 0
    y = 0

    l = [tuple(map(int, input().split())) for _ in range(n)]

    for t1, x1, y1 in l:
        if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1:
            print("No")
            exit()
        if (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
            print("No")
            exit()
        x = x1
        y = y1
        t = t1

    print("Yes")
main()

Submission status: Accepted

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

n = int(input())
t = 0
x = 0
y = 0

l = [tuple(map(int, input().split())) for _ in range(n)]

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1:
        print("No")
        exit()
    if (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

Submission status: Accepted

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

l = [tuple(map(int, input().split())) for _ in range(n)]

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

Submission status: Accepted

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

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

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

Submission status: Accepted

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

for i in range(n):
    t1, x1, y1 = map(int, input().split())
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        judge = False
    x = x1
    y = y1
    t = t1

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

Submission status: Accepted

Solution code:
n = int(input())
t = 0
x = 0
y = 0
judge = True

for i in range(n):
    t1, x1, y1 = map(int, input().split())
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        judge = False
    x = x1
    y = y1
    t = t1

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

Submission status: Accepted

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

def main():
    N = int(readline())
    res = 'Yes'
    pre_x, pre_y = 0, 0
    pre = 0
    for _ in range(N):
        t, x, y = map(int, readline().rstrip().split())
        cost = abs(x - pre_x) + abs(y - pre_y)
        if (t - pre) - cost >= 0 and ((t - pre) - cost) % 2 == 0:
            pre, pre_x, pre_y = t, x, y
        else:
            res = 'No'
            break

    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ct, cx, cy = 0, 0, 0 
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(ct-t) < abs(cx-x) + abs(cy-y) or (abs(ct-t) + abs(cx-x) + abs(cy - y)) % 2 != 0:
        print('No')
        break
    else:
        ct = t 
        cx = x
        cy = y
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

T = []
X = []
Y = []
T.append(0)
X.append(0)
Y.append(0)

for _ in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

for i in range(1, N+1, 1):
    dt = T[i]-T[i-1]
    dl = abs((X[i]+Y[i])-(X[i-1]+Y[i-1]))
    if dt<dl:
        print("No")
        exit()
    if dt%2!=dl%2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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


def read():
    N =int(input().strip())
    TXY = []
    for i in range(N):
        t, x, y = map(int, input().strip().split())
        TXY.append((t, x, y))
    return N, TXY


def solve(N, TXY):
    t0 = 0
    x0, y0 = 0, 0
    for t1, x1, y1 in TXY:
        dt = t1 - t0
        du = abs(x1-x0) + abs(y1-y0)
        if du > dt:
            return "No"
        elif (du - dt) % 2 == 1:
            return "No"
        t0, x0, y0 = t1, x1, y1
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Submission status: Accepted

Solution code:
N = int(input())
A = [[int(x) for x in input().split()]for i in range(N)]
T = 0            ####現在時刻
place = (0,0)    ####現在地
for i in range(N):
  if ((A[i][0]-T) + abs(A[i][1]-place[0]) + abs(A[i][2]-place[1]))%2 == 1 or (A[i][0]-T) < abs(A[i][1]-place[0]) + abs(A[i][2]-place[1]):
    print("No")
    exit()
  else:
    T = A[i][0]
    place = (A[i][1], A[i][2])
print("Yes")

Submission status: Accepted

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

ans=1
for i in range(n):
    t,x,y = map(int,input_line[i])
    dist = abs(point[0]-x)+abs(point[1]-y)
    limit = t-time
    if dist>limit:
        ans=0
        break
    if (limit-dist)%2!=0:
        ans=0
        break
    time=t
    point=[x,y]
print('Yes' if ans==1 else 'No')

Submission status: Accepted

Solution code:
n = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if abs(prev_x - x) + abs(prev_y - y) > abs(prev_t - t) or (
            abs(prev_x - x) + abs(prev_y - y) + abs(prev_t - t)) % 2:
        print('No')
        exit()
    prev_t, prev_x, prev_y = t, x, y
print('Yes')

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())
    if abs(prev_x - x) + abs(prev_y - y) > (t - prev_t) or (abs(prev_x - x) + abs(prev_y - y) + (t - prev_t)) % 2:
        print("No")
        exit()
    prev_t = t
    prev_x = x
    prev_y = y
print("Yes")

Submission status: Accepted

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

j = True

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


for d in range(0, n+1) :
    if t[d] % 2 == 1 and (x[d] + y[d]) %2 != 1 :
        j = False
    if t[d] % 2 == 0 and (x[d] + y[d]) %2 != 0 :
        j = False

for k in range(0, n) :
    a = t[k+1] - t[k]
    b = abs(x[k+1] - x[k]) + abs(y[k+1] - y[k])
    if a < b :
        j = False

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

Submission status: Accepted

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

x = 0
y = 0
t = 0
for i in range(n):
    sub = abs(txy[i][1] - x) + abs(txy[i][2] - y)
    if txy[i][0] - t < sub:
        print("No")
        exit()
    if txy[i][0] - t != sub:
        if (txy[i][0] - t) % 2 == 0:
            if sub % 2 != 0:
                print("No")
                exit()
        else:
            if sub % 2 != 1:
                print("No")
                exit()

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

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

tp = 0
xp = 0
yp = 0
flag = [0]*n
for i in range(n):
  t, x, y = map(int,input().split())
  dt = t-tp
  dx = abs(xp-x)
  dy = abs(yp-y)
  if dt==dx+dy:
    flag[i]=1
  elif dt>dx+dy and dt%2==0 and dx%2==0 and dy%2==0:
    flag[i]=1
  elif dt>dx+dy and dt%2==0 and dx%2==1 and dy%2==1:
    flag[i]=1
  elif dt>dx+dy and dt%2==1 and dx%2==0 and dy%2==1:
    flag[i]=1
  elif dt>dx+dy and dt%2==1 and dx%2==1 and dy%2==0:
    flag[i]=1
  tp=t
  xp=x
  yp=y

f=1
for i in range(n):
  f *= flag[i]
  
if f==1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

now = (0,0)
now_t = 0
ok = True
for t,x,y in TXY:
  d = abs(x-now[0]) + abs(y-now[1])
  if d <= (t-now_t) and ((t - now_t) - d) % 2 == 0:
    now = (x,y)
    now_t = t
    continue
  ok = False
  break
  
if ok:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    t_x_y_arr = [[0,0,0]]
    for i in range(N):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        t_x_y_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'Yes'
    for i in range(N):
        dt = t_x_y_arr[i+1][0]-t_x_y_arr[i][0]
        dist = abs(t_x_y_arr[i+1][1]-t_x_y_arr[i][1]) + abs(t_x_y_arr[i+1][2]-t_x_y_arr[i][2])
        if dt<dist or dist%2!=dt%2:
            TF = 'No'
            break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)

Submission status: Accepted

Solution code:
def main():
    n, *t = map(int, open(0).read().split())
    l = [(0, 0, 0)] + list(zip(*[iter(t)] * 3))
    for x, y in zip(l, l[1:]):
        dt = y[0] - x[0]
        dd = abs(y[1] - x[1]) + abs(y[2] - x[2])
        f = dd <= dt
        g = dt % dd == 0 or dt % dd == 2
        h = f and g
        if not h:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

pt, px, py = [0, 0, 0]
for _ in range(N):
    t, x, y = map(int, input().split())
    ts = abs(t - pt)
    xys = abs(x - px) + abs(y - py)
    if ts < xys:
        print('No')
        break

    if ts % 2 != xys % 2:
        print('No')
        break
    
    pt, px, py = t, x, y
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
now = [0, 0]

for i in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x - now[0]) + abs(y - now[1])
    if t < dist or (t % 2 != dist %2):
        print('No')
        quit()
 
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

now = [0, 0]
for i in range(N):
  t, x, y = map(int, input().split())
  time = abs(x - now[0]) + abs(y - now[1])
  if t >= time and (t - time)%2==0:
    continue
  print('No')
  quit()

print('Yes')

Submission status: Accepted

Solution code:
def solve(N):
    x, y = 0, 0
    for _ in range(N):
        ti, xi, yi = [int(n) for n in input().split()]
        diff_x = abs(xi - x)
        diff_y = abs(yi - y)
        distance = diff_x + diff_y
        left = abs(ti - distance)

        if ti >= distance and left % 2 == 0:
            continue
        else:
            return False
    return True


N = int(input())
if solve(N):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    t, x, y = [], [], []

    for _ in range(N):
        T, X, Y = map(int, input().split())
        t.append(T)
        x.append(X)
        y.append(Y)

    px = 0
    py = 0
    pt = 0
    for T, X, Y in zip(t, x, y):
        if (T-pt) % 2 == 0:
            if T-pt < X-px + Y-py or (X-px + Y-py) % 2 != 0:
                print('No')
                return
        else:
            if T-pt < X-px + Y-py or (X-px + Y-py) % 2 == 0:
                print('No')
                return
        pt = T
        px = X
        py = Y
    print('Yes')
    
main()

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    t=[0]*N
    x=[0]*N
    y=[0]*N
    for i in range(N):
        t[i],x[i],y[i]=map(int,readline().split())

    nt=[]
    nx=[]
    ny=[]
    for i in range(N):
        if i==0:
            nt.append(t[0])
            nx.append(x[0])
            ny.append(y[0])
        else:
            nt.append(t[i]-t[i-1])
            nx.append(x[i]-x[i-1])
            ny.append(y[i]-y[i-1])

    for i in range(N):
        if nt[i]<abs(nx[i])+abs(ny[i]):
            print("No")
            break
        elif nt[i]%2!=(abs(nx[i])+abs(ny[i]))%2:
            print("No")
            break
    else:
        print("Yes")
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def readinput():
    n = int(input())
    txy = []
    for i in range(n):
        t,x,y = list(map(int,input().split()))
        txy.append((t,x,y))
    return n, txy

def canmove(current, next):
    (t0,x0,y0) = current
    (t1,x1,y1) = next
    dist = abs(x1-x0) + abs(y1-y0)
    tdiff = t1-t0
    if(dist > tdiff):
        return False
    if( tdiff%2 != dist%2 ):
        return False
    return True

def main(n,txy):
    current = (0,0,0)
    for i in range(n):
        next = txy[i]
        ans = canmove(current, next )
        if (ans == False):
            return False
        current = next
    return True

if __name__=='__main__':
    n,txy = readinput()
    ans = main(n,txy)
    if (ans == True):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())

flag = 0
for _ in range(n):
  t, x, y = map(int, input().split())
  if t%2 == (x+y)%2 and t >= (x+y):
    continue
  else:
    flag = 1
    
print('Yes') if not flag else print('No')

Submission status: Accepted

Solution code:
n=int(input())
l=[[] for i in range(n+1)]
l[0]=[0,0,0]
for i in range(1,n+1):
    l[i]=list(map(int,input().split()))
for i in range(n):
    flag=False
    t=l[i+1][0]-l[i][0]
    x=l[i+1][1]-l[i][1]
    y=l[i+1][2]-l[i][2]
    for a in range(t+1):
        for b in range(t+1-a):
            c=a-x
            d=b-y
            if a+b+c+d==t:
                flag=True
                break
        if flag: break
    if not flag:
        print("No")
        break
if flag: 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())
now = 0
ans = 1
x0 = 0
y0 = 0
for i in range(n):
    if i == 0:
        if x[i]+y[i] > t[i]:
            ans = 0
            break
        elif (x[i]+y[i]-t[i])%2 == 1:
            ans = 0
            break
    else:
        if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i]-t[i-1]:
            ans = 0
            break
        elif (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])-t[i]+t[i-1])%2 == 1:
            ans = 0
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
t_pre, x_pre, y_pre = 0, 0, 0
flag = True
for i in range(N):
    t, x, y = map(int, input().split())
    delta_t = t - t_pre
    delta_x = abs(x - x_pre)
    delta_y = abs(y - y_pre)
    if t % 2 != (x + y) %2:
        flag = False
        break
    if delta_x + delta_y > delta_t:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

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

    pre_ti, pre_x, pre_y = 0,0,0
    for tx in tx_list:
        ti,x,y = tx[0],tx[1],tx[2]
        tmp_ti,tmp_x,tmp_y = ti-pre_ti,x-pre_x,y-pre_y
        pre_ti,pre_x,pre_y = ti,x,y
        for i in range(tmp_ti+1):
            if ((tmp_ti-i)-i) == (abs(tmp_x)+abs(tmp_y)):
                break
        else:
            print("No")
            exit()
    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())
    if abs(prev_x - x) + abs(prev_y - y) > (t - prev_t) or (abs(prev_x - x) + abs(prev_y - y) + (t - prev_t)) % 2:
        print("No")
        exit()
    prev_t = t
    prev_x = x
    prev_y = y
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
t1, x1, y1 = 0, 0, 0
p = False
for i in range(n):
	t, x, y = t1, x1, y1
	t1, x1, y1 = map(int, input().split())
	s = t1 - t
	d = x1 + y1 - x - y
	p = x >= 0 and y >= 0 and (abs(s) >= abs(d)) and ((s - d) % 2 == 0)
	# print("{},{}".format(s, d))
	if p == False:
		break
print("Yes" if p else "No")

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    t = 0
    x = 0
    y = 0

    ans = True

    for _ in range(n):
        next_t, next_x, next_y = map(int, input().split())

        dist = abs(next_x - x) + abs(next_y - y)

        if next_t - t == dist:
            t, x, y = next_t, next_x, next_y
        elif next_t - t > dist and ((next_t - t) - dist) % 2 == 0:
            t, x, y = next_t, next_x, next_y
        else:
            ans = False
            break

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




class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2
3 1 2
6 1 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1
2 100 100"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
5 1 1
100 1 1"""
        output = """No"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
ans = 'Yes'
n = int(input())
for _ in range(n):
    t, x, y = map(int, input().split())
    if t < x + y:
        ans = 'No'
        break
    if  t % 2 != 0 and (x - y) % 2 == 0:
        ans = 'No'
        break
    elif t % 2 == 0 and (x - y) % 2 != 0:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
x = 0
y = 0
t = 0
ans = 'Yes'

for _ in range(n):
    ti, xi, yi = map(int, input().split())
    elapsed_time = ti - t
    if abs(x - xi) + abs(y - yi) > elapsed_time:
        ans = 'No'
        break
    dist_odd_even = (abs(x - xi) + abs(y - yi)) % 2
    time_odd_even = elapsed_time % 2
    if dist_odd_even != time_odd_even:
        ans = 'No'
        break
    x = xi
    y = yi
    t = ti

print(ans)

Submission status: Accepted

Solution code:
def difference(two_lists):
    return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]


n = int(input())

txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
dtxy = list(map(difference, zip(txy, txy[1:])))

for i in range(n):
    dt, dx, dy = dtxy[i]
    if  dx + dy > dt or (dt - dx - dy) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t1 = 0
x1 = 0
y1 = 0
count = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    t = abs(t - t1)
    x = abs(x - x1)
    y = abs(y - y1)
    if x + y <= t and (x+y) % 2 == t % 2:
        t1 = t
        x1 = x
        y1 = y
        count += 1
if count == n:
    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(N):
    t[i + 1], x[i + 1], y[i + 1] = 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 dt < dist:
        print("No")
        exit(0)

    if dist % 2 != dt % 2:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
t=[list(map(int,input().split())) for _ in range(n)]
ans=[0,0,0]
for i in t:
    if (i[0]-ans[0])%2==((i[1]-ans[1])+(i[2]-ans[2]))%2 and i[0]-ans[0]>=(i[1]-ans[1])+(i[2]-ans[2]):
        ans=i
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
# -*- coding: utf-8 -*-
# 	入力
n=int(input())
t=0
x=0
y=0
s="Yes"
for i in range(n):
  t1,x1,y1=map(int,sys.stdin.readline().split())
  if abs(x1-x)+abs(y1-y) > (t1-t):
    s="No"
    break
  if ((x1 + y1) % 2) == (t1 % 2):
    x=x1
    y=y1
    t=t1
  else:
    s="No"
    break
# 出力
print(s)

Submission status: Accepted

Solution code:
n = int(input())
pre_t, pre_x, pre_y = 0, 0, 0
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)
    if dist > dt or (dist+dt)%2 != 0:

        print("\nNo") 
        exit()
    pre_t, pre_x, pre_y = t, x, y
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
# n = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
t = []
xy = []
for i in range(n):
    a, b, c = map(int, input().split())
    t.append(a)
    xy.append([b, c])

point = xy[0][0]+xy[0][1]
if n == 1:
    if point == t[0]:
        print("Yes")
    elif point < t[0] and (t[0]-point) % 2 == 0:
        print("Yes")
    else:
        print("No")
else:

    if point > t[0] or (point < t[0] and (t[0]-point) % 2 == 1):
        print("No")
        exit()

    for i in range(1, n):
        point += abs(xy[i][0]-xy[i-1][0]) + abs(xy[i][1]-xy[i-1][1])
        if point > t[i] or (point < t[i] and (t[i]-point) % 2 == 1):
            print("No")
            exit()
    print("Yes")