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: Runtime Error

Solution code:
n = int(input())
nums = [[0,0,0]]
ans = False

for v in range(n):
    t, x, y = map(int,input().split())
    nums.append([t,x,y])

# print(nums)
# print(nums[1][1])

for x in range(n+1):
    p = nums[x+1][0] - nums[x][0]
    px = nums[x+1][1] - nums[x][1]
    py = nums[x+1][2] - nums[x][2]
    ps = px + py
    # print(p,px,py,ps)

    for w in range(p+1):
        pp = w
        mp = p - pp
        # print(pp,mp)
        if pp-mp==ps:
            ans = True

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

Submission status: Runtime Error

Solution code:
import math

def check(xs, ys, xe, ye, tm):
    #print(xs, ys, xe, ye, tm)
    xc=xs
    yc=ys
    flag=False
    for tmc in range(1,tm+1,1):
        if xc==xe and yc==ye:
            xx=1
            yy=0
        else:
            
            xx=(xe-xc)/(abs(xe-xc) if abs(xe-xc)>0 else 1)
            yy=(ye-yc)/(abs(ye-yc) if abs(ye-yc)>0 else 1)
        if xx!=0:
          xc=xc+xx
        elif yy!=0:
          yc=yc+yy
        #print(tmc,":",xc,yc,xe,ye,)
        if xc==xe and yc==ye and tmc==tm:
            flag=True
            break
    return flag        

N=int(input().rstrip())
lst=[]

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

result=True
bf=lst[0]
for i in range(1,N+1,1):
    cr=lst[1]
    # 時間の差は？
    tmSa=cr[0]-bf[0]
    if check(bf[1],bf[2],cr[1],cr[2],tmSa)==False:
        result=False
        break
print("Yes" if result==True else "No",flush=True)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
S = []
for i in range(N):
    S.append(list(map(int,input().split())))
now = [0,0]
flag = True
for i in range(N):
    dis = abs(S[i][1]-now[0])+abs(S[i][2]-now[1])
    if(dis > S[i][0] or (S[i][0]-time)%2 != dis%2):
        flag = False
        break
    now[0] = S[i][1]
    now[1] = S[i][2]
    time = S[i][0]
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
k = {}
max_x = 0
max_y = 0
for i in range(n):
    t, x, y = map(int, input().split(" "))
    if x > max_x:
        max_x = x + 1
    if y > max_y:
        max_y = y + 1
    k[t] = [x, y]
last = list(k.keys())[-1]

def a(t, x, y):
    if x < 0 or x > max_x:
        return False
    if y < 0 or x > max_y:
        return False
    if k.get(t) != None:
        rx, ry = k[t]
        if rx != x or ry != y:
            return False
    if t >= last:
        return True
    t += 1
    return a(t, x+1, y) or a(t, x-1, y) or a(t, x, y+1) or a(t, x, y-1)
if a(-1, 0, 0):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = input()
list=[]
flg = 0 
for i in range(N):
    list.append(map(int, raw_input().split()))
if N == 1:
	rem = abs(list[0][1]) + abs(list[0][2])
	if rem == 1:
		print("Yes")
	else:
		print("No")
else:
	for i in range(N-1):
		rem = abs(list[i][1]-list[i+1][1]) + abs(list[i][2]-list[i+1][2])
		time = list[i][0]-list[i+1][0]
		if (time-rem) <= 0:
			flg = 1
			break
		elif (time-rem) % 2 ==1:
			flg = 1
		            break
	if flg == 0:
		print("Yes")
	else:
		print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
k = {}
max_x = 0
max_y = 0
for i in range(n):
    t, x, y = map(int, input().split(" "))
    if x > max_x:
        max_x = x
    if y > max_y:
        max_y = y
    k[t] = [x, y]
last = list(k.keys())[-1]

def a(t, x, y):
    if x < 0 or x > max_x:
        return False
    if y < 0 or x > max_y:
        return False
    if k.get(t) != None:
        rx, ry = k[t]
        if rx != x or ry != y:
            return False
    if t >= last:
        return True
    t += 1
    return a(t, x+1, y) or a(t, x-1, y) or a(t, x, y+1) or a(t, x, y-1)
if a(0, 0, 0):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
k = {}
for i in range(n):
    t, x, y = map(int, input().split(" "))
    k[t] = [x, y]
last = list(k.keys())[-1]

def a(t, x, y):
    if x < 0:
        return False
    if y < 0:
        return False
    if k.get(t) != None:
        rx, ry = k[t]
        if rx != x or ry != y:
            return False
    if t >= last:
        return True
    t += 1
    return a(t, x+1, y) or a(t, x-1, y) or a(t, x, y+1) or a(t, x, y-1)
if a(0, 0, 0):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
k = {}
for i in range(n):
    t, x, y = map(int, input().split(" "))
    k[t] = [x, y]
last = list(k.keys())[-1]

def a(t, x, y):
    print(t, x, y)
    if x < 0:
        return False
    if y < 0:
        return False
    if k.get(t) != None:
        rx, ry = k[t]
        print("chk", t, rx, ry, x, y)
        if rx != x or ry != y:
            return False
    if t >= last:
        return True
    t += 1
    return a(t, x+1, y) or a(t, x-1, y) or a(t, x, y+1) or a(t, x, y-1)
if a(0, 0, 0):
    print("Yes")
else:
    print("No")