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:
import sys
input()
e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]
for (t0, a0, b0), (t1, a1, b1) in zip(e, e[1:]):
    d = (t1 - t0) - abs(a1 - a0) - abs(b1 - b0)
    if d < 0 or t % 2 == 1:
        print('No')
        exit()
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
l = [input().split() for _ in range(n)]
ot = ox = oy = 0
for (t, x, y) in l:
    diff = int(t) - ot
    if abs(x - ox) + abs(y - oy) <= diff:
        ox = x
        oy = y
        ot = t
    else:
        print("No")
        exit(0)
print("Yes")

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
if ((a * b % 2) == 0:
    print('Even')
else:
    print('Odd')

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
A.append(list(a,b,c))
if n==1:
  print("Yes")
  exit()
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
  A.append(list(a,b,c))
if n==1:
  print("Yes")
  exit()
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
if n==1:
  print("Yes")
  exit()
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
if n==1:
  print("Yes")
  exit()
for i in range(n-2):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
for i in range(n-2):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
s = []
for i in range(n):#h:高さ
    s.append([int(m) for m in input().split()])

for i in range(n):
    if i == 0:
        if not(-s[i][1] - s[i][0] <= s[i][2] <= -s[i][1] + s[i][0] and s[i][1] - s[i][0] <= s[i][2] <= s[1][1] + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(-s[i][1] + s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= -s[i][1] + s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])\
            and s[i][1] + s[i - 1][1] - s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i][1] + s[i - 1][1] - s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())

flag = True
t0 = x0 = y0 = 0
for i in range(N):
    t1, x1, y1 = map(int, input().split())
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    if t % (abs(x) + abs(y)) != 0: flag = False
    t0 = t1
    x0 = x1
    y0 = y1

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

Submission status: Runtime Error

Solution code:
def mdist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

n = int(input())
data = [[0, 0, 0]] + [[int(d) for d in input().split(' ')] for _ in range(n)]

for d1, d2 in enumerate(data[:-1], data[1:]):
    dt = d2[0] - d1[0]
    dist = mdist(d1[1:], d2[1:])
    if not ((dt >= dist) and ((dt%2)==(dist%2))):
        print('No')
        break
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
def mdist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

n = int(input())
data = [[0, 0, 0]] + [[int(d) for d in input().split(' ')] for _ in range(n)]

for d1, d2 in enumerate(data[:-1], data[1:]):
    dt = d2[0] - d1[0]
    dist = mdist(d1[1:], d2[1:])
    if not ((dt >= dist) and ((dt%2)==(dist%2))):
        print('No')
        return
print('Yes')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
//#include <iostream>
#include <string>
#include <vector>
using namespace std;

int n;
int t[9999];
int x[9999];
int y[9999];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    bool can = 0;
    int dt, dist;
    for (int i = 1; i < n; i++) {
        can = 0;
        dt = t[i] - t[i - 1];
        dist = abs(x[i] - x[i - 1]) +abs(y[i] - y[i - 1]);
        if (dt >= dist && dt % 2 == dist % 2) {
            can = 1;
        }
        else {
            break;
        }
    }
    if (can) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Submission status: Runtime Error

Solution code:
N = int(input())
t = []
x = []
y = []
for i in range(N):
    n = list(map(int, input().split()))
    t.append(n[0])
    x.append(n[1])
    y.append(n[2])
    n.clear()

answer = "YES"

for i in range(len(N)-1):
    if t%2 != (abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))%2:
        answer = "NO"
    if t[i+1]-t[i] < abs(x[i+1]-x[i])+abs(y[i+1]-y[i]):
        answer = "NO"
print(answer)

Submission status: Runtime Error

Solution code:
N = int(input())
t = []
x = []
y = []
for i in range(N):
    n = list(map(int, input().split()))
    t.append(n[0])
    x.append(n[1])
    y.append(n[2])
    n.clear()

answer = "YES"

for i in range(N-1):
    if t%2 != (abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))%2:
        answer = "NO"
    if t[i+1]-t[i] < abs(x[i+1]-x[i])+abs(y[i+1]-y[i]):
        answer = "NO"
print(answer)

Submission status: Runtime Error

Solution code:
N = int(input())
t = []
x = []
y = []
for i in range(N):
    n = list(map(int, input().split()))
    t.append(n[0])
    x.append(n[1])
    y.append(n[2])
    n.clear()

answer = "YES"

for i in range(N):
    if i == 0:
        if t[i] > x[i]+y[i]:
            if t%2 != 0 and x[i]+y[i]%2 != 0 or t%2 == 0 and x[i]+y[i]%2 == 0:
                answer = "NO"
        if t[i] < x[i]+y[i]:
            answer = "NO"
    else:
        if t[i]-t[i-1] > abs(x[i]-x[i-1])+abs(y[i]-y[i-1]):
            if t%2 != 0 and (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 != 0 or t%2 == 0 and (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 == 0:
                answer = "NO"
        if t[i]-t[i-1] < abs(x[i]-x[i-1])+abs(y[i]-y[i-1]):
            answer = "NO"
print(answer)

Submission status: Runtime Error

Solution code:
N = int(input())
t = []
x = []
y = []
for i in range(N):
    n = list(map(int, input().split()))
    t.append(n[0])
    x.append(n[1])
    y.append(n[2])
    n.clear()

answer = "YES"

for i in range(N):
    if i == 0:
        if t[i] > x[i]+y[i]:
            if t%2 != 0 and x[i]+y[i]%2 == 0 or t%2 == 0 and x[i]+y[i]%2 != 0:
                answer = "NO"
        if t[i] < x[i]+y[i]:
            answer = "NO"
    else:
        if t[i]-t[i-1] > abs(x[i]-x[i-1])+abs(y[i]-y[i-1]):
            if t%2 != 0 and (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 == 0 or t%2 == 0 and (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 != 0:
                answer = "NO"
        if t[i]-t[i-1] < abs(x[i]-x[i-1])+abs(y[i]-y[i-1]):
            answer = "NO"
print(answer)

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

Submission status: Runtime Error

Solution code:

N = int(input())
Z=[]
for i in range(N):
	t, x, y = map(int, input().split())
	if t % 2 == 0:
		if x + y <= t and (x + y) % 2 == 0:
			Z.append(1)
		else:
			Z.append(0)
	else:
		if x + y <= t and (x + y) % 2 == 1:
			Z.append(1)
		else:
			Z.append(0)
	i += 1

if Z.index(0) >= 1:
	print('No')
else:
	print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
t1 = 0
x1 = 0
y1 = 0
boolean = True

for _ in range(n):
    t, x, y = [int(_) for _ in input().split()]
    if boolean:
        temp1 = x
        temp2 = t
        x = abs(x - x1) + abs(y - y1)
        t -= t1
        x1 = temp
        y1 = y
        t1 = temp2
        if x > t or (x + t) % 2 == 1:
            boolean = False
if boolean:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import itertools

a = int(input())
b = int(input())
c = int(input())
x = int(input())

ok = set()

for a_num in range(a + 1):
    for b_num in range(b + 1):
        for c_num in range(c + 1):
            price = a_num * 500 + b_num * 100 + c_num * 50
            if price == x:
                ok.add((a_num, b_num, c_num))

print(len(ok))

Submission status: Runtime Error

Solution code:
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i];flag=0;break if a>0 or a%2
print("Yes" if flag else "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 or (x+y-t)%2 /= 0:
        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 /= 0
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

for i in range(n):
    
    a, b = map(int, input().split())
    if abs(a) + abs(b) > n:
        print('No')
        break
    else:
        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) % 2 != 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")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
N = map(int , input())
for i in range(int(N)):
    t , x , y =map(str , input().split())
    tv=int(t)%2
    xy=int(x)+int(y)
    xyv=xy%2
    if int(t) >= int(xy):
        print("Yes")
    else :
        print("No")

Submission status: Runtime Error

Solution code:
N = map(int , input())
for i in range(int(N)):
    t , x , y =map(str , input().split())
    tv=int(t)%2
    xy=int(x)+int(y)
    xyv=xy%2
    if int(t) >= int(xy):
        print("Ok")
    else :
        print("No")

Submission status: Runtime Error

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

for i in range(n+1):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y < t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n = int(input())
travel_plan = list(tuple(map(int, input().split())))
travel_plan = [(0, 0, 0)] + travel_plan
for i in range(n+1):
    t1, x1, y1 = travel_plan[i][0] + travel_plan[i][1] + travel_plan[i][2]
    t2, x2, y2 = travel_plan[i+1][0] + travel_plan[i+1][1] + travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y < t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
# Relative rela
import sys

n = int(input())
txy_list = [[int(n) for n in input().split()] for i in range(n)]
times_list = [txy_list[i][0] - txy_list[i+1][0] for i in range(n-1)]

before_x, before_y = 0, 0
for i, txy in enumerate(txy_list):
	t, x, y = txy
	rela_x, rela_y = x - before_x, y - before_y
	remaining = times_list[i] - (abs(rela_x) + abs(rela_y))
	if 0 <= remaining and remaining % 2 == 0:
		before_x, before_y = x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
tmp = [0,0,0]
data=list(map(int,(input()).split()))
flag = True
for i in range(N):
  tmp = list(map(int,(input()).split()))
  if (tmp[0] - data[0])%2 == (tmp[1] + tmp[2] - data[1] - data[2]) % 2 + 1:
    flag = False
    break
  else:
    data = tmp

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

Submission status: Runtime Error

Solution code:
prev_t = 0
prev_x = 0
prev_y = 0

n = int(input())
for _ in range(n):
  t, x, y = map(int, input().split())
  dist = (x - prev_x) + (y - prev_y)
  time = t - prev_t
  if dist != time:
    ans = False
    break
  
  prev_x = x
  prev_y = y
  prev_t = t
    
if not ans:
  print('No')
else:
  print('Yes')

Submission status: Runtime Error

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

for i in range(N-1):
    if (arr[i+1][1] + arr[i+1][2]) - (arr[i][1] + arr[i][2]) < arr[i+1][0] - arr[i][0]:
        if((arr[i+1][1] + arr[i+1][2]) - (arr[i][1] + arr[i][2]) - (arr[i+1][0] + arr[i][0]))%2 == 0:
            res = 'Yes'
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)

Submission status: Runtime Error

Solution code:

N=int(input())
Destinations=[[0,0,0]]
for i in range(N):
    Destinations.append(list(map(int, input().split())))

for i in range(N-1):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destination[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] Destinations[i][0]

    if move_distance == 0:
        print("No")

    if move_distance > move_time*1:
        print("No")
    elif move_distance%2 == move_time%2:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

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

if N == 1:
    if list[0][0] - list[0][1] - list[0][2] < 0:
        print("No")
    elif (list[0] - list[1] - list[2]) % 2 == 0:
        print("Yes")
    else:
        print("No")
else:
    for i in range(N-1):
        if (list[i+1][0] - list[i][0]) < abs(list[i+1][1]+list[i+1][2]-list[i][1]-list[i][2]):
            print("No")
        elif ((list[i+1][0] - list[i][0]) - abs(list[i+1][1]+list[i+1][2]-list[i][1]-list[i][2]))%2 == 0:
            print("Yes")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n+1):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

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

flag = 1
for i in range(1,len(trv)+1):
    time = trv[i][0]-trv[i-1][0]
    dist = abs(trv[i][1]-trv[i-1][1]) + abs(trv[i][2]-trv[i-1][2])
    if time < dist:
        flag = 0
        break
    elif time >= dist and (time-dist) % 2 == 0:
        None
    else:
        flag = 0
        break
        
if flag == 0:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
plan = []

for j in range(0,N):
    t,x,y = map(int,input().split())
    plan.append(t,x,y)

if (plan[0] < plan[1] + plan[2]) or ((plan[0] % 2) != ((plan[1] + plan[2]) % 2)):
    print("No")
    exit()

for i in range(0,N-1):
    time_dis = plan[i*3 +3] - plan[i*3]
    x_dis = abs(plan[i*3+1] - plan[i*3+1 +3])
    y_dis = abs(plan[i*3+2] - plan[i*3+2 +3])
    
    if (time_dis < x_dis + y_dis) or ((time_dis % 2) != ((x_dis + y_dis) % 2)):
        print("No")
        exit()
        
print("Yes")

Submission status: Runtime Error

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

# 処理
ans = True
prev_loc = [0, 0, 0]
for loc in loc_list:
  # 現在の位置から次の位置へ移動可能かどうかを判定
  if not movable(prev_loc, loc):
    ans = False
    break
  prev_loc = loc

if ans:
  print("Yes")
else:
  print("No")
  
# 動けるかどうかの判定
def movable(prev_loc, loc):
  dt = loc[0] - prev_loc[0]
  dx = abs(loc[1] - prev_loc[1])
  dy = abs(loc[2] - prev_loc[2])
  # 時間内に届かない
  if dx + dy > dt:
    return False
  if dx + dy % 2 == dt % 2:
    return True
  else:
    return False

Submission status: Runtime Error

Solution code:
n = int(input())
t1,x1,y1 = map(int, input().split())

for p in [x1,y1]:
    if p < 0 or n < p:
        print('No')
        exit()

t2,x2,y2 = map(int, input().split())

for p in [x2,y2]:
    if p < 0 or n < p:
        print('No')
        exit()

dt = t2 - t1
d  = abs(x2 - x1) + abs(y2 - y1)

if (d < dt) and (dt%2 == d%2):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
t1,x1,y1 = map(int, input().split())
t2,x2,y2 = map(int, input().split())

dt = t2 - t1
d  = abs(x2 - x1) + abs(y2 - y1)

if (d < dt) and (dt%2 == d%2):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
t1,x1,y1 = map(int, input().split())
t2,x2,y2 = map(int, input().split())


for p in [x1,y1,x2,y2]:
    if p < 0 or n < p:
        print('No')
        exit()

dt = t2 - t1
d  = abs(x2 - x1) + abs(y2 - y1)

if (d < dt) and (dt%2 == d%2):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
def BlCannotGo(dt, dx, dy): ## 行けないならTrue
    dist = dx + dy
    if (dt % 2) != (dist % 2) or dist > dt:
        return True
    else:
        return False

def abs(x,y):
    return max(x,y) - min(x,y)

if __name__ == '__main__':
    n = int(input())
    t, x, y = list(), list(), list()
    t[0], x[0], y[0] = 0, 0, 0
    for i in range(n):
        t[i+1], x[i+1], y[i+1] = map(int, input().split())

    for i in range(1,n+1):
        dt = t[i] -  t[i-1]
        dx = abs(x[i] -  x[i-1])
        dy = abs(y[i] -  y[i-1])
        if BlCannotGo(dt, dx, dy):
            print('NO')    
            exit()

    print('YES')

Submission status: Runtime Error

Solution code:
def BlCannotGo(dt, dx, dy): ## 行けないならTrue
    dist = dx + dy
    if (dt % 2) != (dist % 2) or dist > dt:
        return True
    else:
        return False

if __name__ == '__main__':
    n = int(input())
    t, x, y = list(), list(), list()
    t[0], x[0], y[0] = 0, 0, 0
    for i in range(n):
        t[i+1], x[i+1], y[i+1] = map(int, input().split())

    for i in range(1,n+1):
        dt = t[i] -  t[i-1]
        dx = abs(x[i] -  x[i-1])
        dy = abs(y[i] -  y[i-1])
        if BlCannotGo(dt, dx, dy):
            print('NO')    
            exit()

    print('YES')

Submission status: Runtime Error

Solution code:
n = int(input())
st, sx, sy = list(map(int, input().split()))

is_reach = True

for i in range(0, n):
    gt, gx, gy = list(map(int, input().split()))
    t = gt - sy
    dist = abs(gx - sx) + abs(gy - sy)

    if not(t >= dist and (t - dist) % 2 == 0):
        is_reach = False
        break


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

Submission status: Runtime Error

Solution code:
def get_arounds(target):
    return [(target[0] + x, target[1] + y) for x, y in ((1, 0), (0, 1), (-1, 0), (0, -1))]

def search_path(step, start, end, limit):
    if step == limit:
        return start == end

    return any([search_path(step + 1, a, end, limit) for a in get_arounds(start)])


if __name__ == '__main__':
    n = int(input())

    path = [tuple(map(int, input().split())) for _ in range(n)]

    step = 0
    start = (0, 0)
    for p in path:
        goal = (p[1], p[2])
        if not search_path(step, start, goal, p[0]):
            print('No')
            break
        step = p[0]
        start = goal
    else:
        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 and (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
N = int(input())
flg = True
now,posx,posy=0,0,0
while flg==True:
  t,x,y=map(int,input().split())
  if abs(x-posx)+abs(y-posy) > (t-now):
    flg = False
    print('No')
  elif (t-now)%2==0 and ((abs(x-posx)+abs(y-posy))%2 ==1):
    flg =False
    print('No')
  elif (t-now)%2==1 and ((abs(x-posx)+abs(y-posy))%2 ==0):
    flg =False
    print('No')
  else:
    now = t
    posx = x
    posy = y
if flg:
  print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
flg = True
now,posx,posy=0,0,0
while flg==True:
  t,x,y=map(int,input().split())
  if abs(x-posx)+abs(y-posy) > (t-now):
    flg = False
    print('No')
  elif (t-now)%2==0 and ((abs(x-posx)+abs(y-posy))%2 ==1):
    flg =False
    print('No')
  elif (t-now)%2==1 and ((abs(x-posx)+abs(y-posy))%2 ==0):
    flg =False
    print('No')
  else:
    now = n
    posx = x
    posy = y
if flg:
  print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
flg = True
#start
now,posx,posy=0,0,0
while flg:
  t,x,y=map(int,input().split())
  if abs(x-posx)+abs(y-posy) > (t-now):
    flg = false
    print('No')
  elif (t-now)%2==0 and ((abs(x-posx)+abs(y-posy))%2 ==1):
    flg =false
    print('No')
  elif (t-now)%2==1 and ((abs(x-posx)+abs(y-posy))%2 ==0):
    flg =false
    print('No')
  else:
    now = n
    posx = x
    posy = y
if flg:
  print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
for i in range(N):
    cord_list.append(list(map(int, input().split())))

cord_list = [[0, 0, 0]]
flag = 0

for j in range(N):
    a = cord_list[j+1][0] - cord_list[j][0]
    b = abs(cord_list[j+1][1] - cord_list[j][1])
    c = abs(cord_list[j+1][2] - cord_list[j][2])
    if ((a - (b + c))%2 ==0) & ((b+c) <= a):
        pass
    else:
        print("No")
        flag += 1
        break
        
if flag == 0:
    print("Yes")

Submission status: Runtime Error

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

for i in range(n):
    time = p[i+1][0] - p[i][0]
    dist = abs(sum(p[i+1][1:]) - sum(p[i][1:]))

    if time % 2 != dist % 2 or dist > time:
        ans = False
        break

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

Submission status: Runtime Error

Solution code:
n = int(input())
G=[None for i in range(n)]
res = True

def dps(d):
    global res
    P=[0,0,0]   #Pはt,x,yのリスト
    for i in range(d):
        if G[i] != None:
            gt,gx,gy = G[i]
            pt,px, py = P
            if (gt-pt) >= (gx-px + gy-py):
                if (gt-pt - (gx-px + gy-py))%2 == 0:
                    res &=  True
                else:
                    res = False
                    break
            else:
                res = False
                break
            P=G[i]
        else:
            res &= True
            
    

for i in range(n):
    G[i] = map(int,input().split())
    dps(i+1)
    if res == False:
        break

        
print('Yes' if res==True else 'No')

Submission status: Runtime Error

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

message = "Yes"
for i in range(len(l)):
	t_delta = abs(l[i][0] - l[i + 1][0])
	x_delta = abs(l[i][1] - l[i + 1][1])
	y_delta = abs(l[i][2] - l[i + 1][2])
	t_minus_d = t_delta - x_delta - y_delta
	if (t_minus_d < 0) or (t_minus_d % 2 != 0):
		message = "No"
		break
print(message)

Submission status: Runtime Error

Solution code:
#-*- coding:utf-8 -*-
import math
import sys

t,x,y = [],[],[]
N = int(input())

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

for i in range(N):
	T = t[i+1]-t[i]
	Z = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
	if (T < Z) or ((T%2) != (Z%2)):
		print("No")
		sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
n=int(input())
t0=0
x0=0
y0=0
for i in range(n):
  t,x,y=[int(i) for i in input().split()]
  if (t-t0-(abs(x-x0)+abs(y-y0)))%2 == 1 or t-t0<(abs(x-x0)+abs(y-y0)):
    print('No')
    break
  t0,x0,y0=t,x,
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
N=int(input())
a=[]
a=[list(map(int,input().split())) for _ in range(N)]
if (c[0]-(c[1]+c[2]))%2==0:
    for i in range(1,(N-1)):
        c=a[i]-a[i-1]
        if (c[0]-(c[1]+c[2]))%2==0:
            print('Yes')
        else:
            print('No')
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[i]
    # 時間の差は？
    tmSa=cr[0]-bf[0]
    if check(bf[1],bf[2],cr[1],cr[2],tmSa)==False:
        result=False
        break
    bf=cr
print("Yes" if result==True else "No",flush=True)

Submission status: Runtime Error

Solution code:
N=int(input())

T=[]
X=[]
Y=[]
for i in range(N):
    t,x,y=map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

flag=0
for i in range(N):
    if i==0:
        if T[i]<X[i]+Y[i] or (X[i]!=0 and Y[i]!=0 and T[i]%(X[i]+Y[i])!=0):
            flag=1
            break
        if (X[i]==Y[i]==0 and T[i]%2!=0) or (((X[i]==1 and Y[i]==0) or (X[i]==0 and Y[i]==1)) and T[i]%2!=1):
            flag=1
            break
    else:
    if T[i]-T[i-1]<(X[i]-X[i-1])+(Y[i]-Y[i-1]) or (X[i]-X[i-1]!=0 and Y[i]-Y[i-1]!=0 and T[i]-T[i-1]%((X[i]-X[i-1])+(Y[i]-Y[i-1]))!=0):
        flag=1
        break
    if (X[i]-X[i-1]==Y[i]-Y[i-1]==0 and T[i]%2!=0) or (((X[i]-X[i-1]==1 and Y[i]-Y[i-1]==0) or (X[i]-X[i-1]==0 and Y[i]-Y[i-1]==1)) and T[i]-T[i-1]%2!=1):
        flag=1
        break

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

Submission status: Runtime Error

Solution code:
N=int(input())

T=[]
X=[]
Y=[]
for i in range(N):
    t,x,y=map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

flag=0
for i in range(N):
    # １回目はそのままの数
    if i==0:
    # 数的に無理
        if T[i]<X[i]+Y[i] or (X[i]!=0 and Y[i]!=0 and T[i]%(X[i]+Y[i])!=0):
            flag=1
            break
    # (0,0)にいれるのはt偶数の時だけ,(1,0)(0,1)にいれるのは奇数の時だけ
        if (X[i]==Y[i]==0 and T[i]%2!=0) or (((X[i]==1 and Y[i]==0) or (X[i]==0 and Y[i]==1)) and T[i]%2!=1):
            flag=1
            break
    # 数的に無理
    else:
    if T[i]-T[i-1]<(X[i]-X[i-1])+(Y[i]-Y[i-1]) or (X[i]-X[i-1]!=0 and Y[i]-Y[i-1]!=0 and T[i]-T[i-1]%((X[i]-X[i-1])+(Y[i]-Y[i-1]))!=0):
        flag=1
        break
    # 前回と同じとこにとどまれるのは偶数の時だけ
    if (X[i]-X[i-1]==Y[i]-Y[i-1]==0 and T[i]%2!=0) or (((X[i]-X[i-1]==1 and Y[i]-Y[i-1]==0) or (X[i]-X[i-1]==0 and Y[i]-Y[i-1]==1)) and T[i]-T[i-1]%2!=1):
        flag=1
        break

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n = int(input())
can_dict = set()

path = [(0, 0, 0)]
for i in range(n):
    t, x, y = input().split()
    path.append((t, int(x), int(y)))

def neighbours(start):
    x, y = start
    temp = [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]
    neighbours = []

    for n in temp:
        if n[0] < 0 or n[1] < 0 or n[0] > 100000 or n[1] > 100000:
            continue
        neighbours.append(n)
    return neighbours

def can_reach(start, dest, time):
    if time < 0:
        return False

    if time == 0 and start == dest:
        can_dict.add((start, dest, time))
        # print('Can reach', dest, 'via', start, 'in', time)
        
        return True


    for neighbour in neighbours(start):
        if (neighbour, dest, time - 1) in can_dict or (dest, neighbour, time - 1) in can_dict or can_reach(neighbour, dest, time - 1):
            return True
        elif can_reach(neighbour, dest, time - 1):
            # print('Can reach', dest, 'via', neighbour, 'in', time-1)
            can_dict.add((neighbour, dest, time - 1))
            return True
    return False

result = True
while len(path) >= 2:
    start_entry = path.pop(0)
    dest_entry = path[0]

    start = (int(start_entry[1]), int(start_entry[2]))
    dest = (int(dest_entry[1]), int(dest_entry[2]))
    time = int(dest_entry[0]) - int(start_entry[0])

    if not can_reach(start, dest, time):
        result = False
        break

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