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:
#!/usr/bin/env python3
import sys

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

def get_distance(a,b):
    return abs(a[1]-b[1])+abs(a[2]-b[2])


def solve(N: int, T: "List[int]", X: "List[int]", Y: "List[int]"):

    prev = (0,0,0)
    for cur in zip(T,X,Y): 
        dist = get_distance(prev,cur)
        deltaT = cur[0] - prev[0]
        if dist > deltaT or (dist-deltaT) % 2 == 1:
            print(NO)
            return

        prev = cur

    print(YES)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, t, x, y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [[0,0,0]]
for i in range(N):
    A.append(list(map(int,input().split())))
for i in range(1,N+1):
    t,x,y = A[i][0],A[i][1],A[i][2]
    pt,px,py = A[i-1][0],A[i-1][1],A[i-1][2]
    #print(t,x,y,pt,px,py)
    if (abs(x-px)+abs(y-py)) > t-pt or (abs(x-px)+abs(y-py))%2 != (t-pt)%2:
        print("No")
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t = []
x = []
y = []
nowx = 0
nowy = 0
time = 0
for i in range(n):
    T,X,Y = (int(x) for x in input().split())
    t.append(T)
    x.append(X)
    y.append(Y)

for i in range(n):
    distance = abs(nowx - x[i]) + abs(nowy - y[i])
    time = t[i] - time
    # matrix.append([t,x,y])
    if (time - distance) % 2 == 0 and time >= distance:
        nowx = x[i]
        nowy = y[i]
        time = t[i]
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

p.sort()

flag = True
for i in range(n):
    dt = abs(p[i+1][0]-p[i][0])
    dxy = abs(p[i+1][1]-p[i][1])+abs(p[i+1][2]-p[i][2])
    if dt >= dxy and (dt-dxy)%2==0:
        pass
    else:
        flag = False

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

Submission status: Accepted

Solution code:
import re  # 正規表現, findall('正規表現', 文字列), search('正規表現', 文字列)
import sys # プログラム終了：sys.exit()
# sys.setrecursionlimit(10**6) # 再帰呼び出しの上限を上げる

def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
# 文字列のまま受け取りたいときはinput()

def main():
    N = i_input()
    T, X, Y = [], [], []
    for _ in range(N):
        t, x, y = s_input()
        T.append(t)
        X.append(x)
        Y.append(y)

    pre_t, pre_x, pre_y = 0, 0, 0
    for i in range(N):
        now_t, now_x, now_y = T[i], X[i], Y[i]
        time = now_t - pre_t
        x_diff = abs(now_x - pre_x)
        y_diff = abs(now_y - pre_y)

        if time >= x_diff + y_diff and\
            (time - x_diff - y_diff) % 2 == 0:
            pre_t, pre_x, pre_y = now_t, now_x, now_y
        else:
            print('No')
            sys.exit()
    
    print('Yes')

if __name__ == "__main__":
    main()

Submission status: Accepted

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


ans = 'Yes'
for i in range(n):
    t = lst_p[i+1][0] - lst_p[i][0]
    x = abs(lst_p[i+1][1] - lst_p[i][1])
    y = abs(lst_p[i+1][2] - lst_p[i][2])
    if t >= x + y and (x+y)%2 == t%2:
        continue
    else:
        ans = 'No'
        break


print(ans)

Submission status: Accepted

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

def can_travel(p1, p2):
    t = p2[0] - p1[0]
    x = abs(p1[1]-p2[1])
    y = abs(p1[2]-p2[2])
    if (t-x-y)>=0 and (t-x-y)%2 == 0:
        return True
    else:
        return False


for i in range(N):
    ans = can_travel(loc[i], loc[i+1])
    if ans==False:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

rx = 0
ry = 0
rt = 0
for t, x, y in txy:
  d = abs(x - rx) + abs(y - ry)
  dt = t - rt
  if dt < d or dt % 2 != d % 2:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

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

n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if t == x+y:
        continue
    elif t > x+y and (t-(x+y))%2 == 0:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

travel = [[0, 0, 0] for i in range(N+1)]

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


for i in range(N):
    x = abs(travel[i+1][1] - travel[i][1])
    y = abs(travel[i+1][2] - travel[i][2])
    t = travel[i+1][0] - travel[i][0]
    if not( x + y  <= t and (t % 2) == ((x + y) % 2)):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:

def distance(p1,p2):
	return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])

n = int(input())
anslist = [None for i in range(n)]
point = [0, 0]
t = 0

for i in range(n):
	tn, nx, ny =  [ int(v) for v in input().split() ]
	dt = tn - t
	t = tn
	next_point = [nx, ny]
	
	anslist[i] =  distance(point,next_point) <= dt and (dt - distance(point,next_point)) % 2 == 0
	point = next_point

if all(anslist):
	ans = "Yes"
else:
	ans = "No"

print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input()) + 1
    P = [list(map(int, input().split())) for x in range(N-1)]
    P.insert(0, [0,0,0])
    #print(N, P)
    for i in range(1, N):
        t = abs(P[i-1][0] - P[i][0])
        
        if t%2 == 0:
            if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 0:
                pass
            else:
                break
        
        else:
            if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 1:
                pass
            else:
                break
    else:
        print('Yes')
        exit()
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

T = 0
X = 0
Y = 0
for i in range(n):
  t, x, y = map(int, input().split())
  dt = t - T
  dist = abs(X - x) + abs(Y - y)
  if dt < dist:
    print("No")
    exit()
  
  if dt % 2 == 0:
    if dist % 2 != 0:
      print("No")
      exit()
  else:
    if dist % 2 == 0:
      print("No")
      exit()

print("Yes")

Submission status: Accepted

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

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

dis = 0
flag = True
for i in range(1,N+1):
    time = t[i] - t[i-1]
    dis = abs(x[i] -x[i-1])+abs(y[i] - y[i-1])
    #print(time)
    #print(dis)
    if time != dis :
        if time < dis:
            #print("time<dis")
            flag = False
        elif time - dis > 0 and (time-dis) %2 == 1:
            #print("time%2")
            flag = False

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

Submission status: Accepted

Solution code:
N = int(input())

TXY = []
for i in range(N):
    txy = [int(x) for x in input().split()]
    TXY.append(txy)


def solve(TXY):
    px, py, pt = 0, 0, 0
    for t, x, y in TXY:
        dt = abs(x - px) + abs(y - py) - (t - pt)
        if dt > 0 or dt % 2 == 1:
            return "No"
        px, py, pt = x - px, y - py, t - pt
    return "Yes"

print(solve(TXY))

Submission status: Accepted

Solution code:
from collections import namedtuple

Point = namedtuple('Point', 't x y')

def canMove(p1, p2):
  dt = p2.t - p1.t
  dx = p2.x - p1.x
  dy = p2.y - p1.y
  if dx + dy > dt:
    return False
  if (dt - (dx + dy)) % 2 == 0:
    return True
  return False

N = int(input())
prev = Point(0, 0, 0)
for _ in range(N):
  t, x, y = map(int, input().split())
  next = Point(t, x, y)
  if not canMove(prev, next):
    print('No')
    break
  prev = next
else:
  print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t, x, y = map(int, input().split())
    if ((x+y)%2) != (t%2):
        print('No')
        exit()
    if t < x+y:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t = 0
x = 0
y = 0
for _ in range(n):
    tt, xt, yt = map(int, input().split())
    tt -= t
    m = abs(xt - x) + abs(yt - y)
    if m > tt:
        print('No')
        exit()
    elif m < tt:
        if m%2 != tt%2:
            print('No')
            exit()
    t += tt
    x = xt
    y = yt
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

T = 0 #現在時間
X = 0 #現在位置X
Y = 0 #現在位置Y
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    a = abs(X-x) + abs(Y-y) #次の位置までの距離
    if a <= t-T and ((t-T)-a)%2 == 0:
        T = t
        X = x
        Y = y
    else:
        flag = False

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

Submission status: Accepted

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

t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = P[i]
    dt, dx, dy = (t - t0), (x - x0), (y - y0)
    dd = abs(dx) + abs(dy)
    if not (dd <= dt and dd % 2 == dt % 2):
        print('No')
        break
    t0, x0, y0 = t, x, y
else:
    print('Yes')

Submission status: Accepted

Solution code:
# 10
import sys
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if ((x + y) % 2) != (t % 2):
        print('No')
        sys.exit()
    if t < x + y:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

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

for i in range(1,N+1):
    t[i],x[i],y[i] = map(int, input().split())
    a = t[i] - t[i-1]
    b = abs(x[i] - x[i-1])
    c = abs(y[i] - y[i-1])
    if a % 2 == 0:
        if b + c <= a and (b + c) % 2 == 0:
            continue
        else:
            print('No')
            exit()
    else:
        if b + c <= a and (b + c) % 2 == 1:
            continue
        else:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()

  t=x=y=f=0
  for _ in range(n):
    _t,_x,_y=LI()
    
    _t-=t
    _t-=abs(x-_x)
    _t-=abs(y-_y)

    if _t<0:
      f=1
    elif _t%2!=0:
      f=1

  if f==1:
    return 'No'
  else:
    return 'Yes'

print(main())

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    t = []
    x = []
    y = []
    for i in range(N):
        s1,s2,s3 = (int(_) for _ in input().split())
        t.append(s1)
        x.append(s2)
        y.append(s3)

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

Submission status: Accepted

Solution code:
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# at_coder.ABC086C_Traveling
# Date: 2019/06/02
# Filename: ABC086C_Traveling 

__author__ = 'acto_mini'
__date__ = "2019/06/02"


def main():
    # 作業ディレクトリを自身のファイルのディレクトリに変更
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

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

    # 整数の入力
    num = int(input())

    for i in range(num):
        a, b, c = map(int, input().split())
        t.append(a)
        x.append(b)
        y.append(c)

    can = True
    for i in range(num):
        dt = t[i + 1] - t[i]
        dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
        if (dt < dist):
            can = False
        if (dt % 2 != dist % 2):
            can = False

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
t_list = [0]*(n+1)
x_list = [0]*(n+1)
y_list = [0]*(n+1)
for i in range(n):
    t_list[i+1], x_list[i+1], y_list[i+1] = map(int,input().split())
for i in range(n):
    d = abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i])
    t = t_list[i+1] - t_list[i]
    if  t<d or t%2 != d%2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

for i in range(N):
    dist = abs(a[i+1][1] - a[i][1]) + abs(a[i+1][2] - a[i][2])
    time = a[i+1][0] - a[i][0]
    if time < dist or (time - dist) % 2 != 0:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    txy_list = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]

    answer = "Yes"
    for i in range(1, len(txy_list)):
        before_t = txy_list[i-1][0]
        t = txy_list[i][0]
        before_x = txy_list[i-1][1]
        x = txy_list[i][1]
        before_y = txy_list[i-1][2]
        y = txy_list[i][2]

        if t - before_t < (x - before_x) + (y - before_y):
            answer = 'No'
            break
        elif ((t - before_t) - ((x - before_x) + (y - before_y)))%2 != 0:
            answer = 'No'
            break

    print(answer)

Submission status: Accepted

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

x = 0
y = 0
cur = 0
ans = "Yes"
for i in pos:
  maximum = abs((i[1] - x) + (i[2] - y))
  if maximum > i[0] - cur:
    ans = "No"
    break
  elif maximum % 2 != (i[0] - cur) % 2:
    ans = "No"
    break
  x = i[1]
  y = i[2]
  cur = i[0]
print(ans)

Submission status: Accepted

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

pt,px,py = 0,0,0

bl = True
for t,x,y in TXY:
  dt = abs(t-pt)
  dx = abs(x-px)
  dy = abs(y-py)
  px = x
  py = y
  pt = t
  if dt < dx+dy:
    bl = False
    break
  if (dt-(dx+dy))&1:
    bl = False
    break

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    prev = (0, 0, 0)
    for _ in range(N):
        T, X, Y = prev
        t, x, y = MI()
        if abs(x - X) + abs(y - Y) <= abs(T - t):
            if (abs(x - X) + abs(y - Y) - (T - t)) % 2 != 0:
                print("No")
                exit()
        else:
            print("No")
            exit()
        prev = (t, x, y)
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    ret = YES
    t = [0] + t
    x = [0] + x
    y = [0] + y
    for i in range(1, N + 1):
        #print(x[i], y[i], t[i])
        dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
        time = t[i] - t[i - 1]
        if dis > time or dis % 2 != time % 2:
            #print(x[i], y[i], t[i])
            ret = NO
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, t, x, y)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    way = abs(x_i - x) + abs(y_i - y)
    time = t_i - t

    if way <= time:
        if way % 2 == time % 2:
            count += 1
    x = x_i
    y = y_i
    t = t_i

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

Submission status: Accepted

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

Submission status: Accepted

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

info.insert(0, [0, 0, 0])
x_diff, y_diff = 0, 0

for i in range(n):
    dt = info[i+1][0] - info[i][0]
    x_diff = abs(info[i+1][1] - info[i][1])
    y_diff = abs(info[i+1][2] - info[i][2])
    if dt < x_diff + y_diff:
        print('No')
        exit()
    if dt%2 != (x_diff + y_diff)%2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
N =int(input())
L = [(list(map(int, input().split()))) for _ in range(N)]
ans = ('Yes')
L.insert(0, [0, 0, 0])
for i in range(N):
	if L[i+1][0]-L[i][0] < L[i+1][1]+L[i+1][2]-L[i][1]-L[i][2] or ((L[i+1][1]+L[i+1][2]-L[i][1]-L[i][2])+(L[i+1][0]-L[i][0]))%2==1:
		ans = ('No')
		break
print(ans)

Submission status: Accepted

Solution code:



def main():
    num = int(input())
    start = [0, 0, 0]
    flg = 1
    for i in range(num):
        data = list(map(int, input().split()))
        time_data = data[0] - start[0]
        kyori = abs(data[1] - start[1]) + abs(data[2] - start[2])
        # print(time_data, kyori)
        if time_data == kyori:
            start = data
        elif time_data < kyori:
            flg = 0
            break
        elif (time_data - kyori) % 2 == 0:
            start = data
        else:
            flg = 0
            break

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




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
txy=list(list(map(int,input().split())) for _ in range(N))
for i in range(N):
    if i!=0 and not((txy[i][0]-txy[i-1][0]>=(txy[i][1]+txy[i][2])-(txy[i-1][1]+txy[i-1][2]))\
            and ((txy[i][0]-txy[i-1][0])%2==((txy[i][1]+txy[i][2])-(txy[i-1][1]+txy[i-1][2]))%2)):
        print('No')
        exit()
    elif i==0 and 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:
n=int(input())
t,x,y=0,0,0
for i in range(n):
     t_,x_,y_=map(int,input().split())
     l=abs(x-x_)+abs(y-y_)
     if l<=t_-t and (t_-t-l)%2==0:
          t,x,y=t_,x_,y_
     else:
          print('No')
          break
else:
     print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

current = [0, 0]
time  = 0
is_valid = True

for _ in range(N):
    t, x, y = map(int, input().split())
    distance = t - time - (abs(current[0] - x) + abs(current[1] - y))
    if distance < 0 or distance % 2 != 0:
        is_valid = False
        break
    else:
        current = [x, y]
        time = t

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

Submission status: Accepted

Solution code:
n = int(input())
x = 0
y = 0
t = 0
a = 0
def trav(a,b,c,d,e,f):
    if abs(a-b) + abs(c-d) <= e - f and ((a-b) % 2 + (c-d) % 2)%2 == (e-f) % 2:
        return 0
    else:
        return 1
for i in range(n):
    tn,xn,yn = map(int,input().split())
    if trav(xn,x,yn,y,tn,t) == 0:
        x = xn
        y = yn
        t = tn
    else:
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n = ip()                                     #入力整数1つ
#n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.popは10^5あるときTLEしやすい!注意!
#これを消すとなぜかWAになる呪い
pt,px,py = 0,0,0
for i in range(n):
    t,x,y = (int(i) for i in input().split())
    time = t - pt
    dist = abs(x-px)+abs(y-py)
    if dist>time:j(0)
    if (time-dist)%2:j(0)
j(1)

Submission status: Accepted

Solution code:
n = int(input())
x = 0
y = 0
t = 0
a = 0
def trav(a,b,c,d,e,f):
    if abs(a-b) + abs(c-d) <= e - f and ((a-b) % 2 + (c-d) % 2)%2 == (e-f) % 2:
        return 0
    else:
        return 1
for i in range(n):
    tn,xn,yn = map(int,input().split())
    if trav(xn,x,yn,y,tn,t) == 0:
        x = xn
        y = yn
        t = tn
    else:
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
x = [0]
y = [0]
t = [0]
fl = True
def judge(a,b,c,d,e,f):
    if abs(b-a)+abs(d-c) <= f-e and abs(b+d-a-c)%2 == abs(f-e)%2:
        return False
    return True
for i in range(n):
    tt,xx,yy = map(int,input().split())
    x.append(xx)
    y.append(yy)
    t.append(tt)
    if judge(x[i],x[i+1],y[i],y[i+1],t[i],t[i+1]):
        fl = False
if(fl):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n,*t=map(int,open(0).read().split())
s=i=j=0
for t,x,y in zip(t[::3],t[1::3],t[2::3]):
  d=abs(y-i)+abs(x-j)
  if t-s<d or d%2!=(t-s)%2:
    print('No')
    exit()
  s,i,j=t,y,x
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())))


def solve():
    for i in range(1, len(txy)):
        if (
            txy[i][0] - txy[i - 1][0]
            < (abs(txy[i][1] - txy[i - 1][1]) + abs(txy[i][2] - txy[i - 1][2]))
        ) or (
            (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")
            return 0
    print("Yes")
    return 0


solve()

Submission status: Accepted

Solution code:
def get_distance(from_x, from_y, to_x, to_y) :
    distance_x = abs(from_x - to_x)
    distance_y = abs(from_y - to_y)
    return distance_x + distance_y

def main() :
    N = int(input())
    action_list = []
    for i in range(N) :
        action_list.append([int(i) for i in input().split()])
    
    from_x = 0
    from_y = 0
    now_t = 0

    for action in action_list :
        t = action[0]
        to_x = action[1]
        to_y = action[2]

        d = get_distance(from_x, from_y, to_x, to_y)
        if (d > (t - now_t) or (t-now_t) % 2 != d%2) :
            print("No")
            return
        
        from_x = to_x
        from_y = to_y
        now_t = t
    
    print("Yes")
    return


main()

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])
f=1
for i in range(n):
  ti=l[i+1][0]-l[i][0]
  dist=abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])
  if dist>ti:
    f=0
    break
  elif ti%2==0 and dist%2>0:
    f=0
    break
  elif ti%2>0 and dist%2==0:
    f=0
    break
if f==1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

    flag = "Yes"
    for i in range(N):
        dt = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])

        if dt < dist or dt%2 != dist%2:
            flag = "No"

    print(flag)
main()

Submission status: Accepted

Solution code:
n=input()
x1=0
y1=0
t1=0
success=True
for i in range(int(n)):
    t,x,y = map(int,input().split())
    w = abs(x - x1) + abs(y - y1)
    if w > abs(t - t1):
        success=False
        break
    if w % 2 != abs(t -t1) % 2:
        success=False
        break
    x1 = x
    y1 = y
    t1 = t
 
print("Yes") if success else print("No")

Submission status: Accepted

Solution code:
N = int(input())
X = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
  tme = X[i + 1][0] - X[i][0]
  cor = abs(X[i + 1][1] - X[i][1]) + abs(X[i + 1][2] - X[i][2])
  ans.append(tme >= cor and tme % 2 == cor % 2)
print('Yes' if all(ans) else 'No')

Submission status: Accepted

Solution code:
N = int(input())
X = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
  tme = X[i + 1][0] - X[i][0]
  cor = abs(X[i + 1][1] - X[i][1]) + abs(X[i + 1][2] - X[i][2])
  ans.append(max(tme - cor, -1) % 2 == 0)
print('Yes' if all(ans) else 'No')

Submission status: Accepted

Solution code:
N=int(input())
txy=[[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    dist=abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if dist>(txy[i+1][0]-txy[i][0]) or (txy[i+1][0]-txy[i][0]-dist)%2==1:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
prev = (0, 0, 0)
b = True
for n in range(N):
    next=[int(i) for i in input().split()]
    diff = abs(next[1] - prev[1]) + abs(next[2] - prev[2])
    c = next[0] - prev[0]
    if c - diff < 0 or (c - diff) % 2 != 0:
        print('No')
        b=False
        break
    prev = next
if b:
    print('Yes')

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0

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

Submission status: Accepted

Solution code:
#coding:utf-8

import sys

t,x,y = 0,0,0

N = int(input())


for _ in range(N):
    t1,x1,y1=[int(__) for __ in input().split()]
    delta_t = abs(t1-t)
    delta_x = abs(x1-x)
    delta_y = abs(y1-y)

    if delta_x + delta_y > delta_t:
        print("No")
        sys.exit()

    if (delta_x + delta_y - delta_t) % 2 != 0:
        print("No")
        sys.exit()

    t,x,y = t1,x1,y1

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

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

c = 0

for i in range(n):
    if l[i][0] < sum(l[i][1:]):
        print('No')
        break
    
    if (l[i][0] % 2) == sum(l[i][1:]) % 2:
        c += 1
    
    else:
        print('No')
        break

if c == n:
    print('Yes')

Submission status: Accepted

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

ans=0
for i in range(len(txy)-1):
    time=txy[i+1][0]-txy[i][0]
    dis=txy[i+1][1]-txy[i][1]+txy[i+1][2]-txy[i][2]
    if time>=dis and time%2==dis%2:
        ans+=0
    else:
        ans+=1

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