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: Wrong Answer

Solution code:
import numpy as np
N=int(input())
s=np.array([0,0,0])
u=np.array([0,0,0])
X=True
for i in range(N):
    t=np.array(list(map(int,input().split())))
    u=t-s
    if u[1]+u[2]==u[0]:
        continue
    elif (abs(u[1]+u[2]-u[0]))%2==0 and u[0]>=u[1]+u[2]:
        continue
    else:
        X=False
        print('No')
if X==True:
    print('Yes')

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
n=input()
n=int(n)
now = 0
nowx=0
nowy=0
for i in range(n):
    temp=input().split(" ")
    
    t=int(temp[0])
    
    x=int(temp[1])
    y=int(temp[2])
    #終了条件

    if abs(nowx-x)+abs(nowy-y)>t-now  or (abs(nowx-x)+abs(nowy-y)%2==1 and  (t-now)%2==0) or (abs(nowx-x)+abs(nowy-y)%2==0 and  (t-now)%2==1):
        print("No")
        exit()
        
    else:
        now=t
        nowx=x
        nowy=y
        


print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
point = [0, 0]
current = 0
flag = False
for _ in range(N):
    t, x, y = map(int, input().split())
    tmp = abs(point[0]-x)+abs(point[1]-y)
    flag = False if t >= tmp else True
    if tmp % 2 == 0 and t-current % 2:
        flag = True
    elif t >= tmp:
        flag = False
    else:
        flag = True
    if flag:
        print("No")
        break
    point = [x, y]
    current = t
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
num = int(input())
n_now = 0
x_now = 0
y_now = 0
Flag = True

n_next, x_next, y_next = [int(i) for i in input().split()]

for i in range(num):
    time = n_next - n_now
    move = abs(x_next - x_now) + abs(y_next - y_now)
    if time < move:
        Flag = False
        break
    elif (time - move) % 2 != 0:
        Flag = False
        break

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

Submission status: Wrong Answer

Solution code:
n = int(input())
me = [0,0]
arr = []

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

for t in arr:
    for _ in range(t[0]):
        if me[0] < t[1]:
            me[0] += 1
        elif me[0] > t[1]:
            me[0] -= 1
        elif me[1] < t[2]:
            me[1] += 1
        elif me[1] > t[2]:
            me[1] -= 1
        else:
            me[0] += 1
    if me != t[1:]:
        break
if me == arr[-1][1:]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
t = []
x = []
y = []
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    t.append(ti)
    x.append(xi)
    y.append(yi)

canBePlanned = 'Yes'
xprev = 0
yprev = 0
tprev = 0
for i in range(N):
    xdiff = abs(x[i] - xprev)
    ydiff = abs(y[i] - yprev)
    tdiff = t[i] - tprev
    if (t[i] - (x[i] + y[i])) % 2 != 0 or (tdiff - (xdiff + ydiff)) % 2 != 0:
        canBePlanned = 'No'
        break
    xprev, yprev, tprev = x[i], y[i], t[i]

print(canBePlanned)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
ot, ox, oy = 0, 0, 0
flg = True

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

    if t < d or (t + d) % 2 != 0:
        flg = False
        break

    ot, ox, oy = t, x, y

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

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[0 for i in range(n)]
x=[0 for i in range(n)]
y=[0 for i in range(n)]
count=1
for i in range(n):
    t[i],x[i],y[i]=[int(i) for i in input().split()]

x_a=abs(x[0])
y_a=abs(y[0])

if t[0]%2==(x_a+y_a)%2 and t[0]>=(x_a+y_a):
    for i in range(n-1):
        x_a=abs(x[i+1]-x[i])
        y_a=abs(y[i+1]-y[i])
        if (t[i+1]-t[i])%2==(x_a+y_a)%2 and (t[+1]-t[i])>=(x_a+y_a):
            count=1
        else:
            count=0
            break
else:
    count=0


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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
t = []
x = []
y = []
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    t.append(ti)
    x.append(xi)
    y.append(yi)

canBePlanned = 'Yes'
xprev = 0
yprev = 0
tprev = 0
for i in range(N):
    xdiff = abs(x[i] - xprev)
    ydiff = abs(y[i] - yprev)
    tdiff = t[i] - tprev
    if (t[i] - (x[i] + y[i])) % 2 != 0 or (tdiff - (xdiff + ydiff)) % 2 != 0:
        canBePlanned = 'No'

print(canBePlanned)

Submission status: Wrong Answer

Solution code:
n=int(input())
t=[0 for i in range(n)]
x=[0 for i in range(n)]
y=[0 for i in range(n)]
count=1
for i in range(n):
    t[i],x[i],y[i]=[int(i) for i in input().split()]

x_a=abs(x[0])
y_a=abs(y[0])

if t[0]%2==(x_a+y_a)%2 and t[0]>=(x_a+y_a):
    for i in range(n-1):
        x_a=abs(x[i+1]-x[i])
        y_a=abs(y[i+1]-y[i])
        if (t[i+1]-t[i])%2==(x_a+y_a)%2 and (t[+1]-t[i])>=(x_a+y_a):
            count=1
        else:
            count=0
else:
    count=0


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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
t = []
x = []
y = []
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    t.append(ti)
    x.append(xi)
    y.append(yi)

canBePlanned = 'Yes'
xprev = 0
yprev = 0
tprev = 0
for i in range(N):
    xdiff = abs(x[i] - xprev)
    ydiff = abs(y[i] - yprev)
    tdiff = t[i] - tprev
    if (t[i] - (x[i] + y[i])) % 2 != 0 and (tdiff - (xdiff + ydiff)) % 2 != 0:
        canBePlanned = 'No'

print(canBePlanned)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    ans = ''
    for a in range(N):
        t, x, y = map(int, input().split())
        if t == 0:
            ans = 'No'
        elif t % (x+y) == 0 and ans != 'No':
            ans = 'Yes'
        else:
            ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
N = int(input())
txy = []
for _ in range(N):
    t, x, y = map(int, input().strip().split())
    txy.append((t, x, y))

for t, x, y in txy:
    if x + y > t:
        print("No")
        break
    elif (x + y) % 2 != t % 2:
        print("No")
        break
    else:
        print("Yes")
        break

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log
from itertools import *
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())


n=input()
l=[]
x1,y1=0,0
flag=1
t1=0
for i in range(n):
	z=list(mp())
	t=z[0]
	t-=t1
	x=z[1]
	y=z[2]
	if ((x-x1)+(y-y1))<=t:
		if ((x-x1)+(y-y1))%2==1:
			if t%2==0:
				flag=0
		else:
			if t%2==1:
				flag=0
	else:
		flag=0
	x1,y1=x,y
	t1=t

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

Submission status: Wrong Answer

Solution code:
N = int(input())
points_list = [list(map(int,input().split())) for _ in range(N)]
flag = True
for i in range(N):
    if i == 0:
        dis = points_list[i][1] + points_list[i][2]
        if points_list[i][0] % dis == 0:
            p = dis
        else:
            flag = False
            break
    else:
        dis = (points_list[i][1] + points_list[i][2]) - p
        if (points_list[i][0] - points_list[i-1][0]) % dis == 0:
            p = points_list[i][1] + points_list[i][2]
        else:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
# 偶数奇数が同じかつ和がt以下ならいける
cnt = 0

for i in range(n):
   t, x, y = map(int, input().split())
   if t >= x+y and t%2 == (x+y)%2:
      cnt += 1
   else:
      print("No")
      break

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    ans = ''
    for a in range(N):
        t, x, y = map(int, input().split())
        if t % (x+y) == 0 and ans != 'No':
            ans = 'Yes'
        elif t % (x+y) != 0:
            ans = 'No'
        else:
            ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
num = int(input())

base_t = 0
base_x = 0
base_y = 0
judge = True
for i in range(num):
    t, x, y = map(int, input().split())
    if (abs(base_t-t) - abs(base_x-x) +abs(base_y-y)) %2 == 0:
        base_x = x
        base_y = y
        base_t = t
    elif (abs(base_t-t) - abs(base_x-x) -abs(base_y-y)) < 0:
        judge = False
        break
    else:
        judge = False
        break
print("Yes" if judge else "No")

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log
from itertools import *
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())


n=input()
l=[]
x1,y1=0,0
flag=1
t1=0
for i in range(n):
	z=list(mp())
	t=z[0]
	t-=t1
	x=z[1]
	y=z[2]
	if (abs(x-x1)+abs(y-y1))<=t:
		if (abs(x-x1)+abs(y-y1))%2==1:
			if t%2==0:
				flag=0
		else:
			if t%2==1:
				flag=0
	else:
		flag=0
	x1,y1=x,y
	t1=t

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    ans = ''
    for a in range(N):
        t, x, y = map(int, input().split())
        if t % (x+y) == 0 and ans != 'No':
            ans = 'Yes'
        else:
            ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
t = []
x = []
y = []
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    t.append(ti)
    x.append(xi)
    y.append(yi)

canBePlanned = 'Yes'
for i in range(N):
    if (t[i] - (x[i] + y[i])) % 2 != 0:
        canBePlanned = 'No'

print(canBePlanned)

Submission status: Wrong Answer

Solution code:
import sys

t, x, y = 0, 0, 0
for _ in range(input()):
    [t2, x2, y2] = map(int, raw_input().split())
    d1 = abs(x2 - x) + abs(y2 - y)
    d2 = t2 - t
    if d1 > d2:
        print 'No'
        sys.exit(0)
    if d1 == d2 or (d1 - d2) % 2 == 0:
        t = t2
        x = x2
        y = y2
print 'Yes'

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log
from itertools import *
import string
import copy
import random
import bisect
from decimal import *
def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).split())


n=input()
l=[]
x1,y1=0,0
flag=1
t1=0
for i in range(n):
	z=list(mp())
	t=z[0]
	t-=t1
	x=z[1]
	y=z[2]
	if (abs(x-x1)+abs(y-y1))<=t:
		if (abs(x-x1)+abs(y-y1))%2==1:
			if t%2==1:
				flag=1
			else:
				flag=0
		else:
			if t%2==1:
				flag=0
			else:
				flag=1
	else:
		flag=0
	x1,y1=x,y
	t1=t

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1
    


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                c +=2
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1
        elif c>count:
            flag = 0
            end = 1


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                c +=2
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
        elif c>count and (x != X[n] or y !=Y[n]) :
                flag=0
                end =1


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                c +=2
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        break


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue

    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
        #print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
o_x = 0
o_y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    #print(n)
    if flag == 0:
        continue

    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        o_x = X[n-1]
        o_y = Y[n-1]
    c = 0
    x = o_x
    y = o_y

    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
    #    print(str(x)+' '+str(y))

        if ((s_x >= 0 or s_y >= 0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
            elif s_x==0:
                x +=1
                c +=1

        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1


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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np


def canReach(src, dst):
    a = (dst[0] - src[0]) - np.sum(np.abs(src-dst)[1:3])
    if a >= 0 and a % 2 == 0:
        return True
    return False


N = int(input())
# dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])
available = True
prev_dst = np.array([0] * 3)

for n in range(N):
    t,x,y = map(int, input().split(" "))
    if canReach(prev_dst, np.array([t,x,y])):
        prev_dst = np.array([t,x,y])
    else:
        available = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np


def canReach(src, dst):
    a = (dst[0] - src[0]) - np.sum(np.abs(src-dst)[1:3])
    if a >= 0 and a % 2 == 0:
        return True
    return False


N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])
available = True
dst = np.vstack((np.array([0, 0, 0]),dst))

for n in range(N):
    if not canReach(dst[n], dst[n+1]):
        available = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np

def canReach(src, dst):
    a = (dst[0] - src[0]) - np.sum(np.abs(src-dst)[1:3])
    if a >= 0 and a % 2 == 0:
        return True
    return False

N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])

available = True
pos = [0, 0, 0]

for n in range(N):
    if not canReach(pos, dst[n]):
        available = False
        break
    else:
        pos = dst[n]

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np

def canReach(src, dst):
    dist = np.sum(np.abs(src-dst)[1:3])
    time = (dst[0] - src[0])
    if time - dist >= 0 and (time - dist) % 2 == 0:
        return True
    return False

N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])

available = True
pos = [0, 0, 0]

for n in range(N):
    if not canReach(pos, dst[n]):
        available = False
        break
    else:
        pos = dst[n]

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np

def canReach(src, dst):
    dist = np.sum(np.abs(src-dst)[1:3])
    time = (dst[0] - src[0])
    if time - dist == 0:
        return True
    elif time - dist > 0 and (time - dist) % 2 == 0:
        return True
    return False

N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])

available = True
pos = [0, 0, 0]

for n in range(N):
    if not canReach(pos, dst[n]):
        available = False
        break
    else:
        pos = dst[n]

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np


def canReach(src, dst):
    dist = np.sum(np.abs([dst[1] - src[1], dst[2] - src[2]]))

    if (dst[0] - src[0]) - dist == 0:
        return True
    elif (dst[0] - src[0]) - dist > 0 and ((dst[0] - src[0]) - dist) % 2 == 0:
        return True
    return False


N = int(input())
dst = [[int(x) for x in input().split(" ")] for z in range(N)]

available = True
pos = [0, 0, 0]

for n in range(N):
    if not canReach(pos, dst[n]):
        available = False
        break
    else:
        pos = dst[n]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

data = [input() for _ in range(n)]

for d in data:
  t, x, y = [int(i) for i in d.split()]
  
  s = t - x
  
  if s < 0:
    print('No')
    exit()
  else:
#    flag = False
    for c in range(s+1):
      
      if y == 2*c -s:
        break
    else:
      print('No')
      exit()
print('Yes')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
loc = [list(map(int, input().split())) for i in range(N)]
t = 0
x = 0
y = 0
def check(X,Y):
    k=0
    global x,y,t
    for i in range(len(loc)):
        d = (loc[i][0] - t) - (abs(loc[i][1] - X) + abs(loc[i][2] - Y))
        if d %2 ==0 and d >= 0: #（x、y)からはじめに行く位置を探す
            t = loc[i][0]
            x = loc[i][1]
            y = loc[i][2]
            loc.remove(loc[i])
            k =1 #フラグ
            break
         
    if k ==0:
        t = -1  #不可能

while(len(loc) !=0 and t!= -1):
    check(x,y)
    

if t == -1:
    print('No')

elif len(loc) ==0:
    print('Yes')
else:
    print('error') #チェック用

#print(loc)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

clear_flag=0
tmp=0
tmp_x=0
tmp_y=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]-tmp+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]-tmp+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]-tmp+1-x_plus-x_minus):
        y_minus=txy[0]-tmp-x_plus-x_minus-y_plus
        x=x_plus-x_minus+tmp_x
        y=y_plus-y_minus+tmp_y
        if x==txy[1] and y==txy[2]:
          next_flag=1
          clear_flag+=1
          tmp=txy[0]
          tmp_x=txy[1]
          tmp_y=txy[2]
          break
            
if clear_flag==N:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]+1-x_plus-x_minus):
        y_minus=txy[0]-x_plus-x_minus-y_plus
        x=x_plus-x_minus
        y=y_plus-y_minus
        if x==txy[1] and y==txy[2]:
          next_flag=1
          clear_flag+=1
          break
            
if clear_flag==N:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

clear_flag=0
for i in range(N):
  txy=list(map(int,input().split()))
  x=0
  y=0
  next_flag=0
  for x_plus in range(txy[0]+1):
    if next_flag==1:
      break
    for x_minus in range(txy[0]+1-x_plus):
      if next_flag==1:
        break
      for y_plus in range(txy[0]+1-x_plus-x_minus):
        if next_flag==1:
          break
        for y_minus in range(txy[0]+1-x_plus-x_minus-y_plus):
          if x_plus+x_minus+y_plus+y_minus==txy[0]:
            #print(x_plus,x_minus,y_plus,y_minus)
            x=x_plus-x_minus
            y=y_plus-y_minus
            if x==txy[1] and y==txy[2]:
            	next_flag=1
            	clear_flag+=1
            	break
            
          
if clear_flag==N:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
A = 'Yes'
N = int(input())
t = np.array([[0,0,0]])
for n in range(N):
     a = [[int(i) for i in input().split()]]
     t = np.append(t, np.array(a), axis=0)
     diff = t[n+1] -t[n]
     cond = np.abs(diff[1]) + np.abs(diff[2])
     if cond > diff[0]:
        A='No'
        break
     if np.sum(np.array(a)) % 2 ==1:
        A = 'No'
        break
print(A)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
A = 'Yes'
N = int(input())
t = np.array([[0,0,0]])
for n in range(N):
     a = [[int(i) for i in input().split()]]
     t = np.append(t, np.array(a), axis=0)
     diff = t[n+1] -t[n]
     cond = np.abs(diff[1]) + np.abs(diff[2])
     if cond > diff[0]:
        A='No'
        break
     if np.sum(t[n+1]) % 2 ==1:
        A = 'No'
        break
print(A)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def compare(x):
  return x[0]


def find(x, lst):
  for value in lst:
    if value[0] == x:
      return True
  return False


n = int(input())
lst = [[0, 0, 0]]
for i in range(n):
  lst.append(list(map(int, input().split())))
lst.sort(key=compare)
x = lst[len(lst) - 1][0]
for i in range(1, x):
  if not find(i, lst):
    lst.append([i, -1, -1])
lst.sort(key=compare)

points = [[0, 0]]
flg = False
try:
  for i in range(1, x + 1):
    fix = False
    wk = []
    for point in points:
      wk.append((point[0] + 1, point[1]))
      wk.append((point[0] - 1, point[1]))
      wk.append((point[0], point[1] + 1))
      wk.append((point[0], point[1] - 1))
      wk = list(set(wk))

      ps = (lst[i][1], lst[i][2])
      x = point[0]
      y = point[1]
      if (i == lst[i][0]) and (x >= 0) and (y >= 0) and ((x + 1, y) == ps or (x - 1, y) == ps or (x, y + 1) == ps or (x, y - 1) == ps):
        flg = True
        wk = [ps]
        break
    points = list(set(wk))
    if (i == lst[i][0]) and (lst[i][1] >= 0) and (not flg):
      break
finally:
  print('Yes') if flg else print('No')

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
def compare(x):
  return x[0]


def find(x, lst):
  for value in lst:
    if value[0] == x:
      return True
  return False


n = int(input())
lst = [[0, 0, 0]]
for i in range(n):
  lst.append(list(map(int, input().split())))
lst.sort(key=compare)
x = lst[len(lst) - 1][0]
for i in range(1, x):
  if not find(i, lst):
    lst.append([i, -1, -1])
lst.sort(key=compare)

points = [[0, 0]]
flg = False
try:
  for i in range(1, x + 1):
    fix = False
    wk = []
    for point in points:
      wk.append((point[0] + 1, point[1]))
      wk.append((point[0] - 1, point[1]))
      wk.append((point[0], point[1] + 1))
      wk.append((point[0], point[1] - 1))

      ps = (lst[i][1], lst[i][2])
      x = point[0]
      y = point[1]
      if (i == lst[i][0]) and (x >= 0) and (y >= 0) and ((x + 1, y) == ps or (x - 1, y) == ps or (x, y + 1) == ps or (x, y - 1) == ps):
        flg = True
        wk = [ps]
        break
    points = list(set(wk))
    if (i == lst[i][0]) and (lst[i][1] >= 0) and (not flg):
      break
finally:
  print('Yes') if flg else print('No')