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:
import sys
n = int(input())
t_1=0
t_2=0
x_1=0
x_2=0
y_1=0
y_2=0

for i in range (n):
    t_1,x_1,y_1=t_2,x_2,y_2
    t_2,x_2,y_2=map(int,input().split())
    if (t_2-t_1) >= abs(x_2-x_1)+abs(y_2-y_1) and (t_2-t_1)%2 == (abs(x_2-x_1)+abs(y_2-y_1))%2:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = [[0, 0, 0]] + LIR(n)
for i in range(n):
    t, x, y = L[i]
    nxt_t, nxt_x, nxt_y = L[i+1]
    if nxt_t - t < abs(nxt_x - x) + abs(nxt_y - y) or (abs(nxt_x - x) + abs(nxt_y - y) - nxt_t - t) % 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

for i in range(1, n + 1):
    t = txy[i][0] - txy[i-1][0]
    x = txy[i][1] - txy[i-1][1]
    y = txy[i][2] - txy[i-1][2]
    mv = abs(x) + abs(y)
    if mv > t or (mv - t) % 2 == 1:
        print("No")
        break

else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
cnt = 0
for i in range(1,n+1):
  t[i],x[i],y[i] = list(map(int,input().split()))
  dt = t[i]-t[i-1]
  dr = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if dt%2==dr%2 and dt >= dr:
    continue
  else:
    print('No')
    cnt = 1
    break
if cnt==0:
  print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

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

count = 0
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dist > dt:
        break
    elif dt%2 != dist%2:
        break
    else:
        count += 1

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

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N = int(sys.stdin.readline())
list_travel=  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

x_now = 0
y_now = 0
time_now = 0

ans = 'Yes'

for i in range(N):
    # time_next = list_travel[i][0]
    # x_next = list_travel[i][1]
    # y_next = list_travel[i][2]
    time_next, x_next, y_next = list_travel[i]
    dis_delta = abs(x_next - x_now) + abs(y_next - y_now)
    time_delta = time_next - time_now
    if(dis_delta <= time_delta
    and (dis_delta - time_delta)%2 == 0):
        x_now = x_next
        y_now = y_next
        time_now = time_next
    else:
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N = int(sys.stdin.readline())
list_travel=  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

x_now = 0
y_now = 0
time_now = 0

ans = 'Yes'

for i in range(N):
    time_next = list_travel[i][0]
    x_next = list_travel[i][1]
    y_next = list_travel[i][2]
    #time_next, x_next, y_next = i for i in range(list_num[i])
    dis_delta = abs(x_next - x_now) + abs(y_next - y_now)
    time_delta = time_next - time_now
    if(dis_delta <= time_delta
    and (dis_delta - time_delta)%2 == 0):
        x_now = x_next
        y_now = y_next
        time_now = time_next
    else:
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

t, x, y = [0]*(N+1), [0]*(N+1), [0]*(N+1)
t[0] = 0
x[0] = 0
y[0] = 0
result = "Yes"

def is_even(num):
    return num % 2 == 0

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

for i in range(1, N+1):
    time = t[i] - t[i-1]
    xlen = abs(x[i] - x[i-1])
    ylen = abs(y[i] - y[i-1])
    distance = xlen+ylen
    if is_even(time) == is_even(distance) and distance <= time:
        continue
    result = "No"
    break
    
print(result)

Submission status: Accepted

Solution code:
n = int(input())
list_plan = []
for i in range(n):
    t, x, y = map(int, input().split())
    list_plan.append([t, x, y])

for i in list_plan:
    t, x, y = i[0], i[1], i[2]
    if x + y <= t and (t - x - y)%2 == 0:
        pass
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
T=[0]
X=[0]
Y=[0]
cnt=0

N=int(input())
for i in range(N):
	t_,x_,y_=[int(i) for i in input().split()]
	T.append(t_)
	X.append(x_)
	Y.append(y_)

def delta_p(l):
	return abs(X[l]-X[l-1])+abs(Y[l]-Y[l-1])
def delta_t(l):
	return T[l]-T[l-1]
	
for t in range(1,N+1):

	if cnt !=0:
		break
	if delta_p(t)>delta_t(t) or delta_p(t)%2!=delta_t(t)%2:
			cnt+=1
	else:
		continue

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
txy=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N):
    t,x,y=txy[i][0],txy[i][1],txy[i][2]
    if x+y<=t and t%2==(x+y)%2:ans+=1
print("Yes" if ans==N else "No")

Submission status: Accepted

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

x=0
y=0
ans=True
for i in range(n):
    if abs(txy[i][1]-x)+abs(txy[i][2]-y)<=txy[i][0] and (txy[i][0]-(abs(txy[i][1]-x)+abs(txy[i][2]-y)))%2==0:
        ans=True
    else:
        ans=False
        break
print('Yes' if ans else 'No')

Submission status: Accepted

Solution code:
import numpy as np

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())
if t[0] >= x[0]+y[0]:
    pass
else:
    print('No')
    exit()
if (t[0]+x[0]+y[0]) % 2 == 0:
    pass
else:
    print('No')
    exit()
t = np.diff(t)
x = np.diff(x)
y = np.diff(y)

for a,b,c in zip(t,x,y):
    if a >= abs(b)+abs(c):
        pass
    else:
        print('No')
        exit()
    if (abs(a)+abs(b)+abs(c)) % 2 == 0:
        pass
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import math
import sys

n = int(input())

for i in range(n):
	t,x,y = map(int, sys.stdin.readline().split())
	d = abs(x)+abs(y)

	if d > t or (d - t) % 2 != 0:
		print('No')
		exit()

print('Yes')

Submission status: Accepted

Solution code:
import math
import sys

n = int(input())

for i in range(n):
	t,x,y = map(int, input().split())
	d = abs(x)+abs(y)

	if d > t or (d - t) % 2 != 0:
		print('No')
		exit()

print('Yes')

Submission status: Accepted

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

for i in range(N):
	t, x, y = map(int, input().split())
	d = abs(X - x) + abs(Y - y)
	if t - T < d or (t - T) % 2 != d % 2:
		flag = False
		break
	else:
		T = t
		X = x
		Y = y

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

Submission status: Accepted

Solution code:
N = int(input())

current = 0, 0, 0
for _ in range(N):
	t, x, y = map(int, input().split())
	t_diff = t - current[0]
	d_diff = abs(x-current[1]) + abs(y-current[2])
	if t_diff < d_diff:
		print('No')
		break
	elif (d_diff - t_diff)%2 != 0:
		print('No')
		break
	current = t, x, y
else:
	print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
L=[0]*3
f=True
for i in range(n):
  S=list(map(int,input().split()))
  if S[0]-L[0]<abs(S[1]-L[1])+abs(S[2]-L[2]):
    f=False
    break
  elif (S[0]-L[0]-(abs(S[1]-L[1])+abs(S[2]-L[2])))%2!=0:
    f=False
    break
  L=S
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# たぶんマンハッタン距離使うやつ
N =  int(sys.stdin.readline())
L =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

current = [0, 0, 0]
for l in L:
    if l[0] < abs(current[1] - l[1]) + abs(current[2] - l[2]):
        print("No")
        exit()
    if (l[0] - current[0]) % 2 != (abs(current[1] - l[1]) + abs(current[2] - l[2])) % 2:
        print("No")
        exit()
    current = l[:]
print("Yes")

Submission status: Accepted

Solution code:
class AtCoDeer:
    def __init__(self):
        self.pos = {"x": 0, "y": 0}
        self.time = 0

    def move(self, to_x, to_y):
        self.pos = {"x": to_x, "y": to_y}
        return self.pos

    def can_move(self, t, to_x, to_y):
        dx = abs(to_x-self.pos.get("x"))
        dy = abs(to_y-self.pos.get("y"))
        total_move = dx + dy
        dt = t - self.time

        if dt < total_move:
            return False
        elif (dt-total_move) % 2 != 0:
            return False
        else:
            self.move(to_x, to_y)
            self.time = t
            return True


def main():
    n = int(input())
    at_co_deer = AtCoDeer()

    while(at_co_deer.can_move(*[int(x) for x in input().split()])):
        n -= 1
        if n == 0:
            break
    
    # 計画破綻判明後のデータ読み捨て
    for i in range(n-1):
        input()

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    ok = True
    pt, px, py = 0, 0, 0
    for i in range(N):
        t, x, y = txy[i]
        dt = t - pt
        dxy = abs(px - x) + abs(py - y)
        if dt < dxy:
            ok = False
            break
        elif dt&1 != dxy&1:
            ok = False
            break
        pt, px, py = t, x, y
    
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

current_time = 0
current_state = (0, 0)

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

    # distance check
    distance = abs(current_state[0] - x) + abs(current_state[1] - y)
    time_gap = t - current_time
    if time_gap < distance:
        print("No")  # 遠すぎて時間内で移動できない
        exit()

    # possibility check (時間差に)
    # 偶数時間で行ける位置は、偶数距離に存在する必要がある
    # (同様に) 奇数時間で行ける位置は、奇数距離に存在する必要がある
    if time_gap % 2 == 0:
        if not (distance % 2 == 0):
            print("No")
            exit()
    else:
        if distance % 2 == 0:
            print("No")
            exit()

    current_time = t
    current_state = (x, y)

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
All = [list(map(int, input().split())) for _ in range(N)]
pre_x = 0
pre_y = 0
pre_t = 0

can = True
for n in range(N):
    can2 = False
    T = All[n][0] - pre_t
    d = abs(All[n][1] - pre_x) + abs(All[n][2] - pre_y)
    # print(T, d)
    if d <= T and T % 2 ==  d % 2:
        can2 = True

    if can2 == False:
        can = False
        break

    pre_t = All[n][0]
    pre_x = All[n][1]
    pre_y = All[n][2]

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

Submission status: Accepted

Solution code:
N = int(input())
All = [list(map(int, input().split())) for _ in range(N)]
t = [row[0] for row in All]
x = [row[1] for row in All]
y = [row[2] for row in All]
pre_x = 0
pre_y = 0
pre_t = 0

can = True
for n in range(N):
    can2 = False
    T  = abs(t[n] - pre_t)
    dx = abs(x[n] - pre_x)
    dy = abs(y[n] - pre_y)
    # print(T,dx,dy)
    if dx + dy == 0 and T % 2 == 0:
        can2 = True
        # print("成功")
    elif dx + dy == 0 and T % 2 != 0:
        can2 = False
        # print("失敗")
        break

    if (T % (dx + dy)) == 0:
        can2 = True
        # print("成功")

    if can2 == False:
        can = False
        # print("失敗")
        break

    pre_t = t[n]
    pre_x = x[n]
    pre_y = y[n]

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

Submission status: Accepted

Solution code:
# ti+1 - ti >= abs(xi+1 - xi) + abs(yi+1 - yi)
# かつ ti+1 - ti + abs(xi+1 - xi) + abs(yi+1 - yi) % 2 == 0
N = int(input())
after = [0, 0, 0]
flag = True
for i in range(N):
    before = after
    after = list(map(int, input().split()))
    if after[0] - before[0] < abs(after[1] - before[1]) + abs(after[2] - before[2]) or (
            after[0] - before[0] + abs(after[1] - before[1]) + abs(after[2] - before[2])) % 2 == 1:
        print("No")
        flag = False
        break
    else:
        continue
if flag:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
k=["t","x","y"]
c=[dict(zip(k,[0,0,0]))]
ans="Yes"
for i in range(1,n+1):
    c.append(dict(zip(k,list(map(int, input().split())))))

    if ((c[i]["x"]+c[i]["y"])%2==0) != (c[i]["t"]%2==0):
        ans="No"

    if abs(c[i]["x"]-c[i-1]["x"])+abs(c[i]["y"]-c[i-1]["y"]) > (c[i]["t"]-c[i-1]["t"]):
        ans="No"

print(ans)

Submission status: Accepted

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

target = [0, 0, 0]
for i in range(n):
  target = [a[i][0] - target[0], a[i][1] - target[1], a[i][2] - target[2]]
  if target[0] % 2 == (target[1] + target[2]) % 2 and target[0] >= (target[1] + target[2]):
    continue
  else:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
s=p=q=0
for i in range(int(input())):
 t,x,y=map(int,input().split())
 l=abs(x-p)+abs(y-q)
 if(l-t-s)%2or l>t-s:print("No");break
 s,p,q=t,x,y
else:print("Yes")

Submission status: Accepted

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

for t, x, y in points:
    dt = t
    dist = x + y
    if dt < dist or dt % 2 != dist % 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
from sys import exit
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
t = 0
x = 0
y = 0
for d in data:
  duration = d[0] - t
  distance = abs(x - d[1]) + abs(y - d[2])
  if (distance > duration) or ((duration - distance) % 2 == 1):
    print('No')
    exit()
  t = d[0]
  x = d[1]
  y = d[2]
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txy_init = [[0, 0, 0]]
txy = txy_init + [[int(i) for i in input().split(" ")] for i in range(N)]
t, x, y = 0, 1, 2

checker = True
for i in range(N):
    dt = txy[i+1][t] - txy[i][t]
    dxy = abs(txy[i+1][x] - txy[i][x]) + abs(txy[i+1][y] - txy[i][y])
    
    if dt < dxy:
        checker = False
    else:
        if (dt - dxy) % 2 == 0:
            continue
        else:
            checker = False
    
    if checker:
        continue
    else:
        break

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

Submission status: Accepted

Solution code:
n = int(input())

l = []
for i in range(n):
    l.append(input().split())

judge = 1
#e = [int(i) for i in l[0]]
t = x = y = 0
for i in l:
    t = int(i[0]) - t
    x = abs(int(i[1]) - x)
    y = abs(int(i[2]) - y)
    d = x + y
    if (t < d):
        judge = 0
        break
    elif (t % 2 != d % 2):
        judge = 0
        break

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

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
t,x,y = Line(N)

t0 = 0
x0 = 0
y0 = 0

for i in range(N):
    d = abs(x[i]-x0) + abs(y[i]-y0)
    a = t[i]-t0-d
    if a>=0 and a%2==0:
        t0 = t[i]
        x0 = x[i]
        y0 = y[i]
    else:
        print('No')
        exit()

print('Yes')