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())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in l:
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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"


dict = [
    [1, 1, 0],
    [1, 0, 1],
    [1, -1, 0],
    [1, 0, -1]
]

def route (dis, current, goal):

    if dis < 0:
        return False

    new_current = [0, 0, 0]

    for d in dict:
        new_current[0] = current[0] + d[0]
        new_current[1] = current[1] + d[1]
        new_current[2] = current[2] + d[2]

        if goal[0] == new_current[0] and goal[1] == new_current[1] and goal[2] == new_current[2]:
            return True

        if route(dis-1, new_current, goal):
            return True

    return False

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

    current = [0, 0, 0]

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

    for i in range(num):
        t, x, y = map(int, input().split())
        goal_list.append([t, x, y])

    fail = False
    for i in range(num):

        t, x, y = goal_list[i][0], goal_list[i][1], goal_list[i][2]

        if route(dis=t, current=current, goal=[t, x, y]):
            current = [t, x, y]
            continue

        fail = True
        break

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

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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"


dict = [
    [1, 1, 0],
    [1, 0, 1],
    [1, -1, 0],
    [1, 0, -1]
]

def route (dis, current, goal):

    if dis < 0:
        return False

    new_current = [0, 0, 0]

    for d in dict:
        new_current[0] = current[0] + d[0]
        new_current[1] = current[1] + d[1]
        new_current[2] = current[2] + d[2]

        if goal[0] == new_current[0] and goal[1] == new_current[1] and goal[2] == new_current[2]:
            return True

        if route(dis-1, new_current, goal):
            return True

    return False

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

    current = [0, 0, 0]

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

    for i in range(num):
        t, x, y = map(int, input().split())
        goal_list.append([t, x, y])

    fail = False
    for i in range(num):

        t, x, y = goal_list[i][0], goal_list[i][1], goal_list[i][2]

        if route(dis=t, current=current, goal=[t, x, y]):
            current = [t, x, y]
            continue

        fail = True
        break

    if fail:
        print("NO")
    else:
        print("YES")

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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"


dict = [
    [1, 1, 0],
    [1, 0, 1],
    [1, -1, 0],
    [1, 0, -1]
]

def route (dis, current, goal):

    if dis < 0:
        return False

    new_current = [0, 0, 0]

    for d in dict:
        new_current[0] = current[0] + d[0]
        new_current[1] = current[1] + d[1]
        new_current[2] = current[2] + d[2]

        if goal[0] == new_current[0] and goal[1] == new_current[1] and goal[2] == new_current[2]:
            return True

        if route(dis-1, new_current, goal):
            return True

    return False

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

    current = [0, 0, 0]

    # 整数の入力
    num = int(input())
    goal_list = []
    for i in range(num):
        t, x, y = map(int, input().split())
        goal_list.append([t, x, y])

    fail = False
    for i in range(num):

        t, x, y = goal_list[i][0], goal_list[i][1], goal_list[i][2]

        if route(dis=t, current=current, goal=[t, x, y]):
            continue

        fail = True
        break

    if fail:
        print("NO")
    else:
        print("YES")

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = input()
x = 0
y = 0
for i in range(n):
    t, X, Y = map(int, input().split())
    if X == x + 1 or X == x - 1:
        if Y == y + 1 or Y == y - 1:
            x = X
            y = Y
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n = input()
x = 0
y = 0
for i in range(n):
    t, X, Y = map(int, input().split())
    if X == x + 1 or X == x - 1:
        if Y == y + 1 or Y == y - 1:
            x = X
            y = Y
        else:
            print("No")
    else:
        print("No")
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
a=[0]+list(map(int,input().split()))
a+=[0]

cost=0
pre=0
for i in range(n+2):
    cost+=abs(a[i]-pre)
    pre=a[i]
#print(a,cost)
for i in range(n):
    if (a[i]-a[i+1])*(a[i+1]-a[i+2])<0:
        print(cost-2*(min(abs(a[i]-a[i+1]),abs(a[i+1]-a[i+2]))))
    else:
        print(cost)

Submission status: Runtime Error

Solution code:
n=int(input())
p=(0,0)
now=0
for _ in range(2):
    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
else:print("Yes")

Submission status: Runtime Error

Solution code:
import math
N = int(input())

now = 0
p = [0, 0]

for line in (map(int, input().split()) for _ in range(N)):
  t, x, y = line
  d = abs(p[0] - x) + abs(p[1] - y)
  now += d
  if now < t:
    now += math.ceil((t - now)/2)*2
  if now != t:
    print("No")
    break
  *p = x, y
else:
  print("Yes")

Submission status: Runtime Error

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())
  
def traveling(t,x,y):
  time_i=0
  for i,time in enumerate(t):
    time_i=time-time_i
    z=x[i]+y[i]
    if (t-z)%2==0:
      return "Yes"
    else:
      return "No"
    time_i=time
    
print("{}".format(traveling(t,x,y)))

Submission status: Runtime Error

Solution code:
n=int(input())

def CanReach(t,x,y,now_t,now_x,now_y):
    if now_x<0 or now_y<0 or now_x>10**5 or now_y>10**5:
        return False

    if t==now_t:
        if x==now_x and y==now_y:
            return True
        else:
            return False

    if CanReach(t,x,y,now_t+1,now_x+1,now_y) or \
       CanReach(t,x,y,now_t+1,now_x-1,now_y) or \
       CanReach(t,x,y,now_t+1,now_x,now_y+1) or \
       CanReach(t,x,y,now_t+1,now_x,now_y-1):
        return True
    return False

now_t,last_x,last_y=0,0,0
for _ in range(n):
    ti,xi,yi=map(int,input().split())
    if CanReach(ti,xi,yi,now_t,last_x,last_y)==False:
        print('No')
        exit()
    now_t,last_x,last_y=ti,xi,yi
print('Yes')

Submission status: Runtime Error

Solution code:
n=int(input())

def CanReach(t,x,y,now_t,now_x,now_y):
    if now_x<0 or now_y<0 or now_x>10^5 or now_y>10^5:
        return False

    if t==now_t:
        if x==now_x and y==now_y:
            return True
        else:
            return False

    if CanReach(t,x,y,now_t+1,now_x+1,now_y) or \
       CanReach(t,x,y,now_t+1,now_x-1,now_y) or \
       CanReach(t,x,y,now_t+1,now_x,now_y+1) or \
       CanReach(t,x,y,now_t+1,now_x,now_y-1):
        return True
    return False

now_t,last_x,last_y=0,0,0
for _ in range(n):
    ti,xi,yi=map(int,input().split())
    if CanReach(ti,xi,yi,now_t,last_x,last_y)==False:
        print('No')
        exit()
    now_t,last_x,last_y=ti,xi,yi
print('Yes')

Submission status: Runtime Error

Solution code:
n=int(input())

def CanReach(t,x,y,now_t,now_x,now_y):
    if now_x<0 or now_y<0:
        return False

    if t==now_t:
        if x==now_x and y==now_y:
            return True
        else:
            return False

    if CanReach(t,x,y,now_t+1,now_x+1,now_y) or \
       CanReach(t,x,y,now_t+1,now_x-1,now_y) or \
       CanReach(t,x,y,now_t+1,now_x,now_y+1) or \
       CanReach(t,x,y,now_t+1,now_x,now_y-1):
        return True
    return False

now_t,last_x,last_y=0,0,0
for _ in range(n):
    ti,xi,yi=map(int,input().split())
    if CanReach(ti,xi,yi,now_t,last_x,last_y)==False:
        print('No')
        exit()
    now_t,last_x,last_y=ti,xi,yi
print('Yes')

Submission status: Runtime Error

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

if li[1][1] - abs(li[1][2]) - abs(li[1][3]) < 0:
  print("NO")
  exit()
elif li[1][1] - abs(li[1][2]) - abs(li[1][3]) > 0:
  if (li[1][1] - abs(li[1][2]) - abs(li[1][3])) % 2 != 0:
    print("NO")
    exit()
else:
  for k in range(1,n):
    t = li[k][1]
    x = li[k][2]
    y = li[k][3]
    tt = li[k-1][1]
    xx = li[k-1][2]
    yy = li[k-1][3]
    if t - tt - abs(x - xx) - abs(y - yy) <0:
      print("NO")
      exit()
    elif t - tt - abs(x - xx) - abs(y - yy) <0:
      (t - tt - abs(x - xx) - abs(y - yy)) % 2 != 0:
        print("NO")
        exit()
print("YES")

Submission status: Runtime Error

Solution code:
def main():
  size = int(input())
  array = []
  for i in range(size):
    array.append(list(map(int, input().split()))
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = array[i][0]
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Submission status: Runtime Error

Solution code:
def main():
  size = int(input())
  array[0] = list(map(int, "3 1 2".split())
  array[1] = list(map(int, "6 1 1".split())
                    
  flg = "Yes"           
  now = [0, 0, 0]
  for i in range (size):
    time = array[i][0] - now[0]
    distance = abs(array[i][1]-now[1]) + abs(array[i][2]-now[2])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      now = array[i]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Submission status: Runtime Error

Solution code:
def main():
  size = int(input())
  for i in range(size):
    array[i] = list(map(int, input().split())
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = array[i][0]
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Submission status: Runtime Error

Solution code:
def main():
  size = int(input())
  for i in range(size):
    array[i] = list(map(int, input().split())
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = time
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Submission status: Runtime Error

Solution code:
def main():
  size = int(input())
  for i in range(size):
    array[i] = list(map(int, input().split())
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0]- pre_time
    distance = array[i][1]-pos[0] + array[i][2]-pos[1]
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = time
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Submission status: Runtime Error

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")
    	break
print("Yes")

Submission status: Runtime Error

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

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")
    	break
print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
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):
    if t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]):
        print('No')
        exit()
    elif t[i] % 2 != (x[i] + y[i]) % 2:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
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):
    if t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]):
        print('No')
        exit()
    elif t[i] % 2 != (x[i] + y[i]) % 2:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

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

is_able = True

for i in range(N-1):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if dt < dist:
    is_able = False
  if dt % 2 != dist % 2:
    is_able = False
  
if is_able:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n = int(input())
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

def travel(t, x, y, k):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    time_dist = t1-t
    
    if dist <= time_dist and dist%2 == time_dist%2:
        if k+1 == n:
            return "Yes"
        else:
            return travel(t1, x1, y1, k+1)
    else:
        return "No"

print(travel(0, 0, 0, 0))

Submission status: Runtime Error

Solution code:
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = abs(T[i + 1] - T[i])
  dx = abs(X[i + 1] - X[i])
  dy = abs(Y[i + 1] - Y[i])
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = res and True
  else:
    res = False

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

Submission status: Runtime Error

Solution code:
n = int(input())
T = [0] + [None] * n
X = [0] + [None] * n
Y = [0] + [None] * n
for i in range(1, n + 1):
  T[i], X[i], Y[i] = map(int, input().split())

for i in range(len(T) - 1):
  dt = T[i + 1] - T[i]
  dx = X[i + 1] - X[i]
  dy = Y[i + 1] - Y[i]
  if (dt % 2 == (dx + dy) % 2 and (dx + dy) <= dt):
    res = res and True
  else:
    res = False

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

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
import sys
N = int(input())
lis = []
for i in range(N):
    s_raw = input().split()
    s = [int(j) for j in s_raw]
    lis.append(s)

def travel(t, x, y, count):
    if t > lis[N-1][0]:
        print("Yes")
        sys.exit()
    if t == lis[count][0]:
        if x == lis[count][1] and y == lis[count][2]:
            count += 1
        else:
            return
    travel(t+1, x+1, y, count)
    travel(t+1, x-1, y, count)
    travel(t+1, x, y+1, count)
    travel(t+1, x, y-1, count)

travel(0, 0, 0, 0)
print("No")

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
import sys
N = int(input())
lis = []
for i in range(N):
    s_raw = input().split()
    s = [int(j) for j in s_raw]
    lis.append(s)

def travel(t, x, y, count):
    if t > lis[N-1][0]:
        print("YES")
        sys.exit()
    if t == lis[count][0]:
        if x == lis[count][1] and y == lis[count][2]:
            count += 1
        else:
            return
    travel(t+1, x+1, y, count)
    travel(t+1, x-1, y, count)
    travel(t+1, x, y+1, count)
    travel(t+1, x, y-1, count)

travel(0, 0, 0, 0)
print("NO")

Submission status: Runtime Error

Solution code:
2
5 1 1
100 1 1

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(range(n))
for i in range(n):
    a[i] = list(map(int, input().split()))
tmpx = 0
tmpy = 0
for s in range(n):
    tmpx = a[s][1] - tmpx
    tmpy = a[s][2] - tmpy
    if((dx+dy)>a[s][0]):
        print("NO")
        break
    if(((dx+dy)%2) == (a[s][0]%2)):
        print("YES")
        break
    else:
        print("NO")
        break

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
travels = np.array([input().split() for _ in range(N)], dtype=int)
travels = np.insert(travels, 0, [0, 0, 0], axis=0)
travels = travels[travels[:,0].argsort(), :]
able = True
for i in range(np.shape(travels)[1]-1):
    dist = travels[i+1,:] - travels[i,:]
    time = dist[0]
    x = abs(dist[1])
    y = abs(dist[2])
    if x+y>time:
        able = False
        break
    elif x+y%2==0 and time%2!=0:
        able = False
        break
    elif x+y%2!=0 and time%2==0:
        able = False
        break
if able:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

point_a, point_b = 0, 0
for i in range(N):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N):
    if point_a == 0 and (TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2) :
        point_b += 1

if point_a == 0 and point_b == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

point = 0
for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] < abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]):
        point += 1

for i in range(N+1):
    if TXY[i+1][0] - TXY[i][0] % 2 != abs(TXY[i+1][1] - TXY[i][1]) + abs(TXY[i+1][2] - TXY[i][2]) %2 :
        point += 1

if point == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  return (t-t0-minT)>=0 and (t-t0-minT)%2==0
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
num=0;bool=False
while num<=n-1:
  t,x,y=lst[num]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    t,x,y=lst[num+1]
    num+=1
    bool=True
  else:
    bool=False
    break
if bool:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  return (t-t0-minT)>=0 and (t-t0-minT)%2==0
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
num=0;bool=False
while num<=n:
  t,x,y=lst[num]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    num+=1
    bool=True
  else:
    bool=False
    break
if bool:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  return (t-t0-minT)>=0 and (t-t0-minT)%2==0
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
num=0;bool=False
while num<=n:
  t,x,y=lst[num]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    t,x,y=lst[num+1]
    num+=1
    bool=True
  else:
    bool=False
    break
if bool:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

def travel(x, y, t, k):
    x1, y1 = schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    
    if dist <= schd[k][0]-t and (schd[k][0]-t-dist)%2 == 0:
        if k+1 == n:
            return "Yes"
        else:
            return travel(x1, y1, schd[k][0], k+1)
    else:
        return "No"

print(travel(0, 0, 0, 0))

Submission status: Runtime Error

Solution code:
# C
n = int(input())
preX = [0,0,0]
ans = True
for i in range(n):
    curX = list(map(int, input().split()))
    time = 
    if not curX[0] - preX[0] >= (abs(curX[1] - preX[1]) + abs(curX[2] - preX[2])) and curX[0] - preX[0] % 2 == (abs(curX[1] - preX[1]) + abs(curX[2] - preX[2])) % 2:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
a = [list(map(int,input().split()))]

h,j,k = 0,0,0

for i in range(n):
    t = abs(h - a[i][0])
    dx = abs(j - a[i][1])
    dy = abs(k - a[i][2])
    if t >= dx + dy:
        if t % 2 != (dx + dy % 2):
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()

print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
routes = [(0,0,0)]
append = routes.append
for _ in range(0, N):
    t, x, y = map(int, input().split())
    append((t, x, y))
for i in range(1, N+2):
    bt, bx, by = routes[i-1]
    t, x, y = routes[i]
    ct = t - bt
    # xだけで考える。yとxは独立させて考えて問題ない。両方が成立しなければ成立しないため。
    cx = x - bx
    cy = y - by
    if cx > ct or cy > ct:
        print ("No")
        exit()
    if (cx+cy) % 2 != ct % 2:
        print ("No")
        exit()
print ("Yes")

Submission status: Runtime Error

Solution code:
n = int(input())
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2==1:
        flag = False


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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向
const int MAX_N = 100001;

int n;
int t[MAX_N],x[MAX_N],y[MAX_N];

void input(){
    cin >> n;
    for(int i=0;i<n;i++) cin >> t[i] >> x[i] >> y[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    bool flg = true;
    for(int i=0;i<n;i++){
        if (t[i] < x[i] + y[i]){
            flg = false;
            break;
        }
        else if((x[i]+y[i]-t[i])%2){
            flg = false;
            break;
        }
    }
    if(flg) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())

p = [None]*n

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

plan = [[0,0,0]]
plan.extend(p)

print('plan')
print(plan)

for i in range(n+1):
    diff = [plan[i+1][k] - plan[i][k] for k in range(len(plan[0]))]
    print(diff)
    if abs(diff[1])+abs(diff[2])>diff[0]:
        print('No')
        break
    elif (diff[0]-(abs(diff[1])+abs(diff[2])))%2==1:
        print('No')
        break
    elif i==n-1:
        print('YES')

Submission status: Runtime Error

Solution code:
def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


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

# print(route)

reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

print(reachable)

Submission status: Runtime Error

Solution code:
import math

def solve():
    n = int(input())
    success_trip = True
    now_t, now_x, now_y = 0, 0, 0
    for i in range(n):
        next_t, next_x, next_y = map(int, input().split(' '))
        if success_trip:
            if not find_path(now_t, now_x, now_y, next_t, next_x, next_y):
                success_trip = False
            now_t, now_x, now_y = next_t, next_x, next_y
    
    if success_trip:
        print("Yes")
    else:
        print("No")

def find_path(now_t, now_x, now_y, next_t, next_x, next_y):
    time = next_t - now_t
    return recursion_find(time, now_x, now_y, next_x, next_y)
    
def recursion_find(time, now_x, now_y, target_x, target_y):
    # print("-----------")
    # print("time:", time)
    # print("now_x:", now_x)
    # print("now_y:", now_y)
    # print("target_x:", target_x)
    # print("target_y:", target_y)
    # print("-----------")

    if (abs(target_x - now_x) + abs(target_y - now_y) - time) % 2 == 1:
        # cant
        return False

    if time == 0:
        if now_x == target_x or now_y == target_y:
            return True
        else:
            return False
    else:
        # distant
        if time < abs(target_x - now_x) + abs(target_y - now_y):
            # cant
            return False
            
        if recursion_find(time-1, now_x-1, now_y, target_x, target_y):
            return True
        elif recursion_find(time-1, now_x, now_y-1, target_x, target_y):
            return True
        elif recursion_find(time-1, now_x+1, now_y, target_x, target_y):
            return True
        elif recursion_find(time-1, now_x, now_y+1, target_x, target_y):
            return True
        else: 
            return False

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import sys
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# S = str(input())
# T = str(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t[i],x[i],y[i] = [int(n) for n in input().split()]
dt = t[0]
d = x[0] + y[0]
if(dt < d || dt%2 != d%2):
    print("No")
    sys.exit()
for i in range(1,N):
    dt = t[i] - t[i-1]
    d = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if(dt < d || dt%2 != d%2):
        print("No")
        sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= [0]
l = [0]
m=[]
co = range(1,10**5,2)
ce = range(0,10**5,2)
f = 1
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
#def rep(i):return for i in range()
def addarray(k,l):
    for i in range(n+1):
        a ,b,c = map(int,input().split())
        k.append(a)
        l.append(b+c)
n = ai()
addarray(k,l)
for i in range(1,n):
    t = k[i]-k[i-1]
    if not t%2==1 and abs(l[i]-l[i-1]) in ce[:t//2+1]:
        f = 0
        break
    elif not t%2!=1 and abs(l[i]-l[i-1]) in co[:t//2+1]:
        f = 0
        break
say(f)

Submission status: Runtime Error

Solution code:
n = int(input())
coordinate = {0: [0, 0, 0]}
i = 1
while True:
    coordinate[i] = input().split()
    coordinate[i]  = [int(j) for j in coordinate[i]]
    if not coordinate[i]:
        coordinate.pop(i)
        break
    i += 1
k = 0
for k in range(n):
    time_reminder = coordinate[k+1][0] - coordinate[k][0]
    x_reminder = abs(coordinate[k+1][1] - coordinate[k][1])
    y_reminder = abs(coordinate[k+1][2] - coordinate[k][2])
    z = time_reminder - (x_reminder + y_reminder)
    if z < 0 or z % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
coordinate = {0: [0, 0, 0]}

    
i = 1
while True:
    coordinate[i] = input().split()
    coordinate[i]  = [int(j) for j in coordinate[i]]
    if not coordinate[i]:
        coordinate.pop(i)
        break
    i += 1
k = 1

for k in range(len(coordinate) - 1):
    time_reminder = coordinate[k+1][0] - coordinate[k][0]
    x_reminder = abs(coordinate[k+1][1] - coordinate[k][1])
    y_reminder = abs(coordinate[k+1][2] - coordinate[k][2])
    z = time_reminder - (x_reminder + y_reminder)
    if z < 0 or z % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
coordinate = {0: [0, 0, 0]}

    
i = 0
while True:
    coordinate[i] = input().split()
    coordinate[i]  = [int(j) for j in coordinate[i]]
    if not coordinate[i]:
        coordinate.pop(i)
        break
    i += 1
k = 0

for k in range(len(coordinate) - 1):
    time_reminder = coordinate[k][0] - coordinate[k+1][0]
    x_reminder = abs(coordinate[k][1] - coordinate[k+1][1])
    y_reminder = abs(coordinate[k][2] - coordinate[k+1][2])
    z = time_reminder - (x_reminder + y_reminder)
    if z < 0 or z % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
coordinate = {0: [0, 0, 0]}

    
i = 0
while True:
    coordinate[i] = input().split()
    coordinate[i]  = [int(j) for j in coordinate[i]]
    if not coordinate[i]:
        coordinate.pop(i)
        break
    i += 1
k = 0

for k in range(len(coordinate)):
    time_reminder = coordinate[k][0] - coordinate[k+1][0]
    x_reminder = abs(coordinate[k][1] - coordinate[k+1][1])
    y_reminder = abs(coordinate[k][2] - coordinate[k+1][2])
    z = time_reminder - (x_reminder + y_reminder)
    if z < 0 or z % 2 == 1:
        print("No")
        break
else:
    print("Yes")