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())
txy = []
for _ in range(n):
    t, x, y = map(int, input().split())
    txy.append((t, x, y))
pt = px = py = 0
for t, x, y in txy:
    l = abs(x-px)+abs(y-py)
    if l>t-pt or (t-pt-l)%2==1:
        print('No')
        break
    pt, px, py = t, x, y
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

ans = 'Yes'
nt = 0; nx = 0; ny = 0

for i in range(N):
    t, x, y = map(int, input().split())
    dt = t - nt; dx = abs(x - nx); dy = abs(y - ny)
    if dx + dy > dt or (dx + dy - dt)%2 == 1:
        ans = 'No'
        break
    nt = t; nx = x; ny = y

print(ans)

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

ok = True

for i in range(n):
    delta_t = t[i+1] - t[i]
    delta_x = x[i+1] - x[i]
    delta_y = y[i+1] - y[i]
    if delta_t < delta_x + delta_y:
        ok = False
    else:
        if abs(delta_x + delta_y - delta_t)%2 != 0:
            ok = False

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

Submission status: Accepted

Solution code:
N = int(input())

prev_t, prev_x, prev_y = 0, 0, 0
flag = 'Yes'

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

  t = next_t - prev_t
  x = next_x - prev_x
  y = next_y - prev_y
  
  if x+y > t or (t-(x+y))%2 != 0:
    flag = 'No'
    break
  prev_t, prev_x, prev_y = next_t, next_x, next_y

print(flag)

Submission status: Accepted

Solution code:
N = int(input())
x = 0
y = 0
t = 0
for _ in range(N):
    ti, xi, yi = map(int, input().split())
    dist = abs(x-xi) + abs(y-yi)
    flag = False
    if dist % 2 == 0 and not t % 2 == ti % 2:
        flag = True
    elif not dist % 2 == 0 and t % 2 == ti % 2:
        flag = True
    if dist > ti - t or flag:
        print('No')
        exit()
    x = xi
    y = yi
    t = ti

print('Yes')

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def judge(s, g):
    t = g[0] - s[0]
    x = g[1] - s[1]
    y = g[2] - s[2]
    if (abs(x)+abs(y)) % 2 == t % 2 and (abs(x)+abs(y)) <= t:
        return True
    else:
        return False


def main():
    # inputs
    n = int(input().strip())
    txy = [(0, 0, 0)]
    for i in range(n):
        tmp1, tmp2, tmp3 = map(int, input().strip().split())
        txy.append((tmp1, tmp2, tmp3))
    txy.sort()
    n += 1

    # procedure and output
    for i in range(0, n-1):
        if judge(txy[i], txy[i+1]) != True:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def judge(s,g):
    t=g[0] - s[0]
    x=g[1] - s[1]
    y=g[2] - s[2]
    eprint('x,y,t ',end=':\n')
    eprint(x,y,t)
    if (abs(x)+abs(y))%2 == t%2 and (abs(x)+abs(y))<=t:
        return True
    else:
        return False


def main():
    n = int(input().strip())
    txy=[(0,0,0)]
    for i in range(n):
        tmp1, tmp2, tmp3 = map(int,input().strip().split())
        txy.append((tmp1,tmp2,tmp3))
    txy.sort()
    n+=1

    for i in range(0,n-1):
        if judge(txy[i], txy[i+1]) != True:
            print("No")
            return
    print("Yes")

        




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
pt, px, py = 0, 0, 0
for _ in range(N):
    ct, cx, cy = map(int, input().split())
    diff_t = ct - pt
    diff_x = cx - px
    diff_y = cy - py

    diff_xy = abs(diff_x+diff_y)
    if diff_xy > diff_t:
        print('No')
        exit()
    if (diff_xy + diff_t) % 2 != 0:
        print('No')
        exit()

    px = cx
    py = cy
    pt = ct

print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
pt = 0
px = 0
py = 0
tmp = []
can = True

for i in range(n):
    tmp = list(map(int, input().split()))
    t = tmp[0]
    x = tmp[1]
    y = tmp[2]
    dist = abs(x-px) + abs(y-py)
    if dist > t-pt or (px+py+t-pt)%2 != (x+y)%2:
        can = False
        break

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

Submission status: Accepted

Solution code:
N=int(input())

p=[0,0]
time=0
for i in range(N):
    t,x,y=map(int,input().split())
    cost=abs(x-p[0])+abs(y-p[1])
    if t<time+cost:
        print("No")
        exit()
    else:
        if (t-time-cost)%2!=0:
            print("No")
            exit()
        else:
            p=[x,y]
            time=t
print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
a = [0]*3 + a
for i in range(n):
    i *= 3
    t, x, y = map(lambda j:abs(a[i+3+j]-a[i+j]), [0,1,2])
    d = x+y
    if d>t or d%2-t%2: print("No"); exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    T = [0] * (N+1)
    XY = [[0,0] for _ in range(N+1)]
    ans = 'Yes'
    for i in range(1,N+1):
        T[i],XY[i][0],XY[i][1] = map(int, input().split())
    for i in range(N):
        t = T[i+1] - T[i]
        d = abs(XY[i+1][0]-XY[i][0]) + abs(XY[i+1][1]-XY[i][1])
        if t<d or (t-d)%2==1:
            ans = 'No'

    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 'Yes'
for t, x, y in P:
    if x + y > t:
        ans = 'No'
        break
    if (x + y) % 2 != t % 2:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
dia = [[0,0,0] for _ in range(n)]
for i in range(n):
    t, x, y = map(int, input().split())
    dia[i][0] = t
    dia[i][1] = x
    dia[i][2] = y
t = 0
x = 0
y = 0
ans = "Yes"
for i in range(n):
    r = abs(dia[i][1] - x) + abs(dia[i][2] - y)
    if (dia[i][0] - t < r) or (dia[i][0] - t >= r and (dia[i][0] - t - r) & 1) :
        ans = "No"
        break
    t = dia[i][0]
    x = dia[i][1]
    y = dia[i][2]
print(ans)

Submission status: Accepted

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

def distance(x1,y1,x2,y2):
    return (abs(x2 - x1) + abs(y2 - y1))

now = [0,0,0]
flg = True
for i in range(n):
    next = grid[i]
    time = next[0] - now[0]
    if time >= distance(now[1],now[2],next[1],next[2]) and (time - distance(now[1],now[2],next[1],next[2])) % 2 == 0:
        now = next
    else:
        flg = False
        break
        
if flg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def myAnswer(N:int, txy:list) -> str:
   time = 0
   now = [0,0]
   ans = "Yes"
   for t,x,y in txy:
      counter = t - time
      dx = abs(x - now[0])
      dy = abs(y - now[1])
      if(counter % (dx + dy) != 0):
         ans = "No"
         break
      else:
         time = t
         now =[x,y]
   return ans


def modelAnswer():
   return
def main():
   N = int(input())
   txy = []
   for _ in range(N):
      txy.append(list(map(int,input().split())))
   print(myAnswer(N,txy[:]))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
N = int(input())
# 文字列の入力
oldest_t = 0
oldest_x = 0
oldest_y = 0
for i in range(N):
    t, x, y = map(int, input().split())
    #print(t, x, y)
    distans_t=t-oldest_t
    distans_x=abs(x - oldest_x)
    distans_y=abs(y - oldest_y)
    #print(oldest_t, oldest_x, oldest_y)
    #print(distans_t, distans_x, distans_y)
    distans =  distans_t - distans_x - distans_y
    #print(distans)
    #print()
    if distans >= 0 and distans % 2==0:
        oldest_x = x
        oldest_y = y
        oldest_t = t
        continue
    else:
        print("No")
        exit()


#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

print("Yes")

Submission status: Accepted

Solution code:
import sys
N = int(input())
turn = 0
x, y = 0, 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0]%2 == 0 and (a[1]+a[2])%2 == 1:
        print("No")
        sys.exit()
    if a[0]%2 == 1 and (a[1]+a[2])%2 == 0:
        print("No")
        sys.exit()
    if (a[0] - turn) < abs(x - a[1]) + abs(y - a[2]):
        print("No")
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

tprev = 0
xprev = 0
yprev = 0

result = 'Yes'

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

    xlen = abs(x - xprev)
    ylen = abs(y - yprev)
    
    time = t - tprev

    length = xlen + ylen

    if time%2 == length%2 and time >= length:
        tprev = t
        xprev = x
        yprev = y

    else:
        result = 'No'
        break
print(result)

Submission status: Accepted

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

ans = "Yes"
before = [0, 0, 0]
for plan in plans:
    #print(plan)
    dt = plan[0] - before[0]
    dx = abs(plan[1] - before[1])
    dy = abs(plan[2] - before[2])

    if dt >= (dx+dy) and ((dt % 2 == 0 and (dx+dy) % 2 == 0) or (dt % 2 == 1 and (dx+dy) % 2 == 1)):
        pass
    else:
        ans = "No"
        break
    before = plan[:]
    
print(ans)

Submission status: Accepted

Solution code:
import sys
n = int(input())
t1 , x1 , y1 = 0 , 0 , 0
for i in range(n):
    t2,x2,y2=map(int,input().split())
    if t2-t1<abs(x1-x2)+abs(y1-y2) or (t2-t1-abs(x1-x2)-abs(y1-y2))%2==1:
        print('No')
        sys.exit()
    t1,x1,y1=t2,x2,y2
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

t = x = y = 0
for _ in range(n):
    t_, x_, y_ = map(int, input().split())
    dt, dx, dy = (t_ - t), abs(x_ - x), abs(y_ - y)

    if dx + dy > dt:
        print("No")
        exit()

    if dt % 2 != (dx + dy) % 2:
        print("No")
        exit()

    t, x, y = t_, x_, y_

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    t_1, x_1, y_1 = map(int, input().split())
    distance = abs(x - x_1) + abs(y - y_1)
    if distance > t_1 - t or (t_1 - t - distance) % 2 != 0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit

n = int(input())

ans = 0
for q in range(n):
    limit, x, y = map(int, input().split())
    if (limit < x + y) or (limit - x - y) % 2:
        print("No")
        exit(0)


print("Yes")

Submission status: Accepted

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

def main():
    # 整数の入力
    n = int(input())
    # スペース区切りの整数の入力
    plans = []
    for i in range(n):
        a, b, c = map(int, input().split())
        plans.append((a, b, c))

    # 各点がそもそも妥当な場所かどうか
    for x in plans:
        if (x[0] + x[1] + x[2]) % 2 == 1:
            print("No")
            return

    # その時刻に各点に移動可能かどうか
    pre_p = (0, 0, 0)
    for p in plans:
        time_diff = p[0] - pre_p[0]
        x_diff = abs(p[1] - pre_p[1])
        y_diff = abs(p[2] - pre_p[2])
        if time_diff < x_diff + y_diff:
            print("No")
            return
        pre_p = p

    print("Yes")


main()

Submission status: Accepted

Solution code:
n = int(input())
bx = 0
by = 0
bt = 0
def p(t,x,y):
  if abs(x)+abs(y) > t:
    return True
  elif (t-abs(x)-abs(y))%2 == 1:
    return True
  else:
    return False
for _ in range(n):
  at,ax,ay = map(int,input().split())
  if p(at-bt,bx-ax,by-ay):
    print("No")
    exit()
  bx = ax
  by = ay
  bt = at
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
a=[list(map(int,input().split())) for _ in range(N)]
dp=[[0,0] for _ in range(N+1)]
f=True
for i in range(N):
  t=a[i][0]-dp[i][1]
  x=a[i][1]
  y=a[i][2]
  if t>=x+y-dp[i][0] and t%2==(x+y+dp[i][1])%2:
    dp[i+1][0]=x+y
    dp[i+1][1]=a[i][0]
  else:
    f=False
    break
if f:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
N=int(input())
a=[list(map(int,input().split())) for _ in range(N)]
dp=[[0,0] for _ in range(N+1)]
dp[0][0]=1
f=True
for i in range(1,N+1):
  t=a[i-1][0]-dp[i-1][1]
  x=a[i-1][1]
  y=a[i-1][2]
  if t>=x+y-dp[i-1][0] and t%2==(x+y+dp[i-1][1])%2:
    dp[i][0]=x+y
    dp[i][1]=a[i-1][0]
  else:
    f=False
    break
if f:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
n = int(input())
TXY = [list(map(int,input().split())) for i in range(n)]
t = 0
x = 0
y = 0
ok = 0
            
for i in range(n):
    time = TXY[i][0]-t
    distance = abs(TXY[i][1]-x) + abs(TXY[i][2]-y)
    if time >= distance:
        if time%2 == distance%2:
            ok += 1
            
print("YNeos"[ok<n::2])

Submission status: Accepted

Solution code:
n = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
for _ in range(n):
    data = input().split(' ')
    t_list.append(int(data[0]))
    x_list.append(int(data[1]))
    y_list.append(int(data[2]))
for i in range(n):
    t_diff = t_list[i + 1] - t_list[i]
    x_diff = abs(x_list[i + 1] - x_list[i])
    y_diff = abs(y_list[i + 1] - y_list[i])
    manhattan_dist = x_diff + y_diff
    if t_diff < manhattan_dist or (manhattan_dist - t_diff) % 2 == 1:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    chp = [[int(item) for item in input().split()] for _ in range(N)]

    def root_chk(a, b):

        delta_t = b[0] - a[0]
        shortest_path = abs(a[1] - b[1]) + abs(a[2] - b[2])

        if shortest_path > delta_t:
            return False

        elif (delta_t - shortest_path) % 2 == 1:
            return False
        else:
            return True
    


    for i in range(N):

        if i == 0:
            # print(root_chk([0,0,0], chp[0]))
            if root_chk([0,0,0], chp[0]):
                pass
            else:
                print('No')
                break
        else:
            # print(root_chk(chp[i-1], chp[i]))
            if root_chk(chp[i-1], chp[i]):
                pass
            else:
                print('No')
                break
    else:
        print('Yes')


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
def func(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)

n = int(input())
LL = [list(map(int,input().split())) for _ in range(n)]
t0,x0,y0 = 0,0,0
ans = "Yes"
for l in LL:
    t,x,y = l[0],l[1],l[2]
    dist = func(x0,y0,x,y)
    time = t-t0
    if dist-time > 0 or (dist-time <= 0 and (dist-time)%2 == 1):
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    plan = [[int(a) for a in input().split()] for i in range(N)]
    possible = True

    for i in range(N):
        d = 0
        dt = 0

        if i == 0:
            d = abs(plan[i][1] - 0) + abs(plan[i][2] - 0)
            dt = plan[i][0] - 0
        else:
            d =  abs(plan[i][1] - plan[i-1][1]) + abs(plan[i][2] - plan[i-1][2])
            dt = plan[i][0] - plan[i-1][0]

        if d == dt or ( d < dt and d % 2 == dt % 2 ):
            pass
        else:
            possible = False
            break

    if possible:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

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())
    
yn=""
for i in range(n):
    ti=t[i+1]-t[i]
    d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if d>ti or ti%2!=d%2:
        yn="No"
        break
    
if yn=="No":
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
plan = [[0]*3 for i in range(N+1)]
for i in range(1,N+1):
    plan[i][0],plan[i][1],plan[i][2] = map(int,input().split())

flag = 0

for i in range(N):
    dt = plan[i+1][0] - plan[i][0]
    dist =  abs(plan[i+1][1]-plan[i][1]) + abs(plan[i+1][2]-plan[i][2])
    if dt < dist or dt%2 != dist%2:
        print("No")
        flag = 0
        break
    else:
        flag = 1

if flag == 1:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
a=[[int(i) for i in input().split()] for l in range(n)]
nx=0
ny=0
day=0
for x in a:
    tx=abs(x[1]-nx)
    ty=abs(x[2]-ny)
    tday=x[0]-day
    if (tx+ty-tday)%2==0 and tx+ty<=tday:
        nx=x[1]
        ny=x[2]
        day=x[0]
    else:
        print("No")
        break
else:print("Yes")

Submission status: Accepted

Solution code:
judge = 'Yes'
n = int(input())
txy_l = [[0,0,0]]
for _ in range(n):
    txy_l.append(list(map(int,input().split())))

for i in range(n):
    t_dif = txy_l[i+1][0] - txy_l[i][0]
    x_dif = txy_l[i+1][1] - txy_l[i][1]
    y_dif = txy_l[i+1][2] - txy_l[i][2]
    spare_time = t_dif - (abs(x_dif)+abs(y_dif))
    if spare_time < 0 or spare_time%2 != 0:
        judge = 'No'

print(judge)

Submission status: Accepted

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

flag = True
txy.insert(0,[0,0,0])
for i in range(n):
    t = txy[i+1][0] - txy[i][0]
    d = abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2]-txy[i][2])
    if t < d:
        flag = False
    elif t == d:
        continue
    elif (t-d) % 2 != 0:
        flag = False

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

Submission status: Accepted

Solution code:
class Traveling:
    def calculate(self, N: int, T: list) -> bool:
        for t in T:
            n = int(t[1]) + int(t[2])
            if n % 2 !=0:
                n_is = "odd"
            else: 
                n_is = "even"
            if int(t[0]) % 2 != 0:
                t0_is = "odd"
            else:
                t0_is = "even"
            
            if int(t[0]) < n or n_is != t0_is:
                return False
        return True

if __name__ == '__main__':
    N = int(input())
    T = [input().split() for i in range(N)]
    t = Traveling()
    res = t. calculate(N, T)
    if res:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
N=int(input())
flag=0

x=[list(map(int,input().split())) for _ in range(N)]
x.insert(0,[0,0,0])



for i in range(N):
  if abs(x[i][0]-x[i+1][0])<(abs(x[i][1]-x[i+1][1])+abs(x[i][2]-x[i+1][2])):
    flag=1
  if x[i][1]==x[i+1][1] and x[i][2]==x[i+1][2]:
    flag=1
  if abs(x[i][0]-x[i+1][0])%2!=(abs(x[i][1]-x[i+1][1])+abs(x[i][2]-x[i+1][2]))%2:
    flag=1

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

Submission status: Accepted

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

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

ans='Yes'
for i in range(1,N+1):
    if T[i][0]-T[i-1][0]<abs(T[i][1]-T[i-1][1])+abs(T[i][2]-T[i-1][2]):
        ans='No'
    
for j in range(1,N+1):
    if (T[j][1]+T[j][2])%2!=T[j][0]%2:
        ans='No'

print(ans)

Submission status: Accepted

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

n = int(input())

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

for i in range(1,n+1):
    dist = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    if dist > t[i] -t[i-1] or dist % 2 !=  (t[i] -t[i-1])%2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
mt,mx,my=0,0,0
p=True
for i in range(n):
    t,x,y=map(int,input().split())
    #print(abs(mx-x),abs(my-y),t-mt)
    if abs(mx-x)+abs(my-y)<=t-mt and (t-mt)%2==(abs(mx-x)+abs(my-y))%2:
        mt,mx,my=t,x,y
    else:
        p=False
        print('No')
        break
        
if p:
    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())
    t.append(ti)
    x.append(xi)
    y.append(yi)

can = True
for i in range(n):
    dt=t[i+1]-t[i]
    dist=(x[i+1]-x[i])+(y[i+1]-y[i])
    if(dt<dist):
        can=False
    if(dist%2 != dt%2):
        can=False
if(can):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
point_list = [{'t_0':0, 'x_0':0, 'y_0':0}]
cnt = 0

for i in range(1, N + 1):
    time, x, y = list(map(int, input().split()))
    point_dict = {}
    point_dict['t_{}'.format(i)] = time
    point_dict['x_{}'.format(i)] = x
    point_dict['y_{}'.format(i)] = y
    point_list.append(point_dict)

for i in range(N):
    time = point_list[i + 1]['t_{}'.format(i + 1)] - point_list[i]['t_{}'.format(i)]
    xdist = abs(point_list[i + 1]['x_{}'.format(i + 1)] - point_list[i]['x_{}'.format(i)])
    ydist = abs(point_list[i + 1]['y_{}'.format(i + 1)] - point_list[i]['y_{}'.format(i)])
    if time >= xdist + ydist and time % 2 == (xdist + ydist) % 2:
        continue
    else:
        print('No')
        cnt += 1
        break

if cnt == 0:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

#1行ずつ読んでやる方がスマートだけど、とりあえず見た目わかりやすい方で

t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

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

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

aFlg = True #ダメとなるまでは見なしOK

for i,tm in enumerate(t):
  xm = 0
  ym = 0
  if i > 0:
    if x[i] > x[i-1]:
      xm = x[i] - x[i-1]
    else:
      xm = x[i-1] - x[i]

    if y[i] > y[i-1]:
      ym = y[i] - y[i-1]
    else:
      ym = y[i-1] - y[i]

    if xm + ym > (t[i] - t[i-1]):  #動きすぎ
      aFlg = False
      break
    elif ((t[i] - t[i-1]) - (xm+ym))%2 == 1:  #そこには止まれない
      aFlg = False
      break

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

Submission status: Accepted

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

for i in range(1,n+1):
    dt = grid[i][0] - grid[i-1][0]
    dx = abs(grid[i][1] - grid[i-1][1])
    dy = abs(grid[i][2] - grid[i-1][2])
    #print(dt,dx,dy)
    if dt < dx + dy:
        print('No')
        break
    elif (dt - dx - dy) % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

for i in range(N):
  d = abs(Sorted[i+1][1] - Sorted[i][1]) + abs(Sorted[i+1][2] - Sorted[i][2])
  t = Sorted[i+1][0] - Sorted[i][0]
  if  d > t or d % 2 != t % 2:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
X, Y, T = 0, 0, 0
flag = True

for _ in range(N):
    t, x, y = map(int, input().split())
    duration = t - T
    x_diff = x - X
    y_diff = y - Y
    if abs(x_diff) + abs(y_diff) > duration:
        flag = False
    if (x_diff + y_diff + duration)%2:
        flag = False
    X = x
    Y = y
    T = t
        
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

old_t = 0
old_x = 0
old_y = 0

for _ in range(N):
    t, x, y = list(map(int, input().split()))
    rest_t = t - old_x
    diff = abs(x - old_x) + abs(y - old_y)
    if (rest_t < diff) or (old_t - t + old_x - x + old_y -y) % 2 != 0:
        print("No")
        exit()
    old_t = t
    old_x = x
    old_y = y

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
rows = [list(map(int,input().split())) for _ in range(N)]

pos = [0,0]
time = 0
for row in rows:
    t,x,y = row
    tt = t - time
    xx = abs(x-pos[0])
    yy = abs(y-pos[1])
    num = tt-(xx+yy)
    if num>=0 and num%2==0:
        pos = [x,y]
        time = t
    else:
        print("No")
        exit()

print("Yes")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

for t, x, y in txy:
    dist = x + y
    if t < dist or t % 2 != dist % 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def myAnswer(N:int, txy:list) -> str:
   prex = 0
   prey = 0
   pret = 0
   for t,x,y in txy:
      xy =abs(x - prex)+abs(y - prey)
      if(xy > (t -pret) or  xy % 2 != (t - pret) % 2):
         return "No"
      else:
         prex = x
         prey = y
         pret = t
   return "Yes"

def modelAnswer():
   return
def main():
   N = int(input())
   txy = []
   for _ in range(N):
      txy.append(list(map(int,input().split())))
   print(myAnswer(N,txy[:]))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
num_list=int(input())
a=[0,0,0]
for i in range(num_list):
  b=[int(x) for x in input().split()]
  dt=(b[0]-a[0])
  d=(abs(b[1]-a[1])+abs(b[2]-a[2]))
  if d<=dt and dt%2==d%2:
    if i == num_list-1:
      print("Yes")
      break
    a=b
  else:
    print("No")
    break

Submission status: Accepted

Solution code:
n = int(input())
location = [[0]*3]*n

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

# print(location) -> [[3, 1, 2], [6, 1, 1]]
# 合計値と同じ奇数or偶数になっていればいい
for i in range(n):
    if location[i][1] + location[i][2] > location[i][0]:
        print("No")
        flag = False
        break
    elif location[i][0] % 2 != (location[i][1] + location[i][2]) % 2:
        print("No")
        flag = False
        break
    else:
        flag = True

if flag:
    print("Yes")

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
flag = True
for i in range(n):
    t,x,y = iim()
    if x+y > t or t%2 != (x+y)%2:
        flag = False

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

Submission status: Accepted

Solution code:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1,d2,d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    n = II()
    now_t = 0
    now_x = now_y = 0
    for i in range(n):
        t, x, y = MII()
        dt = t - now_t
        dx = x - now_x
        dy = y - now_y
        if dx+dy > dt: print('No'); return None
        if (dx+dy)%2 != dt%2: print('No'); return None
    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
route = [[int(i) for i in input().split()] for j in range(N)]

arrive = True
pre_spot = [0, 0, 0]
for spot in route:
    cost = abs(spot[1] - pre_spot[1]) + abs(spot[2] - pre_spot[2])
    time = spot[0] - pre_spot[0]
    if (time - cost < 0) or ((time - cost) % 2 != 0):
        arrive = False
        break

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