Problem:


Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.

If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

1 ≤ N ≤ 10^5

0 ≤ x_i ≤ 10^5

0 ≤ y_i ≤ 10^5

1 ≤ t_i ≤ 10^5

t_i < t_{i+1} (1 ≤ i ≤ N-1)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
t_1 x_1 y_1
t_2 x_2 y_2
:
t_N x_N y_N

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at (100,100) two seconds after being at (0,0).

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No



Sample input:
2
3 1 2
6 1 1


Sample output:
Yes

Submission status: Accepted

Solution code:
n = input()
pt = px = py = 0
for _ in xrange(n):
    t, x, y = map(int, raw_input().split())
    if abs(x-px)+abs(y-py) > t-pt:
        print "No"
        break
    if (x+y-px-py) % 2 ^ (t-pt) % 2 :
        print "No"
        break
    pt = t
    px = x
    py = y
else:
    print "Yes"

Submission status: Accepted

Solution code:
N = int(input())
T = list()
for index in range(N):
	T.append((int(i) for i in input().split()))

pt, px, py = (0, 0, 0)
for t, x, y in T:
	d = (t - pt) - (abs(x - px) + abs(y - py))
	if d >= 0 and d % 2 == 0:
		pt, px, py = (t, x, y)
	else:
		print("No")
		exit(0)

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
cord_list = [[0, 0, 0]]
flag = 0
    
for j in range(N):
    cord_list.append(list(map(int, input().split())))
    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: Accepted

Solution code:
N = int(input())
cord_list = [[0, 0, 0]]
flag = 0
for i in range(N):
    cord_list.append(list(map(int, input().split())))
    
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: Accepted

Solution code:
N = int(input())
cord_list = [[0, 0, 0]]
flag = 0
for i in range(N):
    cord_list.append(list(map(int, input().split())))
    
for j in range(N):
    a = cord_list[j+1][0] - cord_list[j][0]
    b = cord_list[j+1][1] - cord_list[j][1]
    c = cord_list[j+1][2] - cord_list[j][2]
    if ((a - (abs(b) + abs(c)))%2 ==0) & ((abs(b) + abs(c)) <= a):
        pass
    else:
        print("No")
        flag += 1
        break
        
if flag == 0:
    print("Yes")

Submission status: Accepted

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: Accepted

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

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

        if time % 2 == 0 and dist % 2 == 0 or time % 2 == 1 and dist % 2 == 1:
            if -(time) <= dist <= time:
                pass
            else:
                return ans(1)
        else:
            return ans(1)

    return ans(0)

def ans(num):
    if num == 1: print("No")
    else: print("Yes")

check(n,p)

Submission status: Accepted

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

for m in range(n):
  time = lis[m+1]-lis[m]
  idou = abs(x[m+1]-x[m]) + abs(y[m+1]-y[m])
  if time < idou or (time - idou)% 2 == 1:
    print("No")
    break
  if m == n-1:
    print("Yes")

Submission status: Accepted

Solution code:
for i in range(int(input())):
    t, x, y = map(int, input().split())
    if x + y > t or (x + y) % 2 != t % 2:
        can = 0
        break
    else:
        can = 1
if can == 0: print("No")
elif can == 1: print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
txy=[[int(j) for j in input().split()] for i in range(N)]
txy.insert(0,[0,0,0])
ans=True

for i in range(N):
	dtxy=[abs(txy[i+1][j] -txy[i][j]) for j in range(3)]
	if (dtxy[0]<sum(dtxy[1:])) or (dtxy[0]%2 != sum(dtxy[1:])%2):
		ans=False
		break
if ans:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
n = int(input())
status = [0, 0, 0]
ans = "Yes"
for i in range(0, n):
    line = input().split(" ")
    a = list(map(int, line))
    if a[0] - status[0] < abs(a[1] - status[1]) + abs(a[2] - status[2]):
        ans = "No"
        break
    elif (abs(a[1] - status[1]) + abs(a[2] - status[2]) - a[0] + status[0]) % 2 != 0:
        ans = "No"
        break
    else:
        status = a[:]
print(ans)

Submission status: Accepted

Solution code:
#空のリストを作成する
t = []
x = []
y = []

flag = 0

N=int(input())#まずはNのターミナル入力
for j in range(N): #Nの分だけfor文回す
    a,b,c=[int(i) for i in input().split()] #int型でa,b,cそれぞれに空欄ごとの数字を代入
    t.append(a) #tのリストにaの要素を追加
    x.append(b)
    y.append(c)

if t[0] % 2 == (x[0] + y[0]) % 2 and t[0] >= (x[0] + y[0]):
    flag = 1

for j in range(N-1):
    if (t[j+1]-t[j])%2 == (abs(x[j+1] - x[j]) + abs(y[j+1] - y[j])) % 2 and t[j+1] - t[j] >= (abs(x[j+1] - x[j]) + abs(y[j+1] - y[j])):
        flag = 1
    else:
        flag = 0

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

Submission status: Accepted

Solution code:
n = int(input())
ls = [[int(i) for i in input().split()] for i in range(n)]
flag = True
x, y = 0, 0
time = 0

for i in range(n):
    if not i == 0:
        x, y = ls[i-1][1], ls[i-1][2]
        time = ls[i-1][0]
    d = abs(ls[i][1]-x) + abs(ls[i][2]-y)

    if d > ls[i][0]-time:
        flag = False
        break
    if not (ls[i][0]-time-d) % 2 == 0:
        flag = False
        break

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

Submission status: Accepted

Solution code:
def main():
    N = int(input().strip())
    stx = sty = stt = 0
    for i in range(N):
        t, x, y = [int(x) for x in input().strip().split()]
        mvt = abs(stt - t)
        mvx = abs(stx - x)
        mvy = abs(sty - y)
        
        mvxy = mvx + mvy
        
        if mvt < mvxy:
            return "No"
        if mvt % 2 != mvxy % 2:
            return "No"
        # 次のスタート地点
        stx = x
        sty = y
        stt = t
    return "Yes"
        
if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
def main():
    N = int(input().strip())
    stx = sty = stt = 0
    for i in range(N):
        t, x, y = [int(x) for x in input().strip().split()]
        mvt = abs(stt - t)
        mvx = abs(stx - x)
        mvy = abs(sty - y)
        
        mvxy = mvx + mvy
        
        if mvt < (mvx + mvy):
            return "No"
        if (mvt % 2) != (mvxy % 2):
            return "No"
        stx = x
        sty = y
        stt = t
    return "Yes"
        
if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
def main():
    N = int(input().strip())
    stx = sty = stt = 0
    for i in range(N):
        t, x, y = [int(x) for x in input().strip().split()]
        mvt = abs(stt - t)
        mvx = abs(stx - x)
        mvy = abs(sty - y)
        
        if mvt < (mvx + mvy):
            return "No"
        if mvt == (mvx + mvy):
            stx = x
            sty = y
            stt = t
            continue
        if mvt % 2 == 0 and (mvx + mvy) % 2 == 0: #偶数同士
            stx = x
            sty = y
            stt = t
            continue
        if mvt % 2 != 0 and (mvx + mvy) % 2 != 0: #奇数同士
            stx = x
            sty = y
            stt = t
            continue
        return "No"
    return "Yes"
        
if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
N = int(input())
txx = [[0,0,0]] * (N+1)
for i in range(N):
    txx[i] = input().split()
    for j in range(3):
        txx[i][j] = int(txx[i][j])
      
loc = [0,0,0]
output = 'Yes'
for i in range(N):
    dt = txx[i][0] - loc[0]
    dx = txx[i][1] - loc[1]
    dy = txx[i][2] - loc[2]
    if (not(dx + dy <= dt)) or (not((dx + dy - dt) % 2 == 0)):
        output = 'No'
    loc = [txx[i][0],txx[i][1],txx[i][2]]
    
print(output)

Submission status: Accepted

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

import sys

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

for i in range(1, len(L)):
    t = L[i][0] - L[i-1][0]
    x = L[i][1] - L[i-1][1]
    y = L[i][2] - L[i-1][2]
    num = t - abs(x) - abs(y)
    if num < 0 or num % 2:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
cur_t = 0
cur_x = 0
cur_y = 0
flag = True
for i in range(N):
    t, x, y = map(int, input().split())
    cur_t += abs(x - cur_x)
    cur_t += abs(y - cur_y)
    if(cur_t > t):
        print('No')
        flag = False
        break
    cur_x = x
    cur_y = y
    if((t - cur_t) % 2 != 0):
        print('No')
        flag = False
        break

if(flag):
    print('Yes')

Submission status: Accepted

Solution code:
T = 0
X = 1
Y = 2
item = input()
tabiji = [[0,0,0]]
for i in range(1, int(item)+1):
    tabiji.append(input().split(' '))

a = 'Yes'
for i in range(0, len(tabiji)-1):
    time = int(tabiji[i+1][T]) - int(tabiji[i][T])
    dX = abs(int(tabiji[i+1][X]) - int(tabiji[i][X]))
    dY = abs(int(tabiji[i+1][Y]) - int(tabiji[i][Y]))
    dtime = time - dX - dY
    if dtime < 0 or dtime % 2 == 1:
        a = 'No'

print(a)

Submission status: Accepted

Solution code:
T = 0
X = 1
Y = 2
item = input()
tabiji = [[0,0,0]]
for i in range(1, int(item)+1):
    tabiji.append(input().split(' '))

a = 'Yes'
for i in range(0, len(tabiji)-1):
    time = int(tabiji[i+1][T]) - int(tabiji[i][T])
    dX = int(tabiji[i+1][X]) - int(tabiji[i][X])
    dY = int(tabiji[i+1][Y]) - int(tabiji[i][Y])
    for j in range(time):
        if dX > 0:
            dX -= 1
        elif dX < 0:
            dX += 1
        elif dY > 0:
            dY -= 1
        elif dY < 0:
            dY += 1
        if dX == 0 and dY == 0 and (time - j+1) % 2 == 1:
            a = 'No'
            break
        elif dX == 0 and dY == 0 and (time - j+1) % 2 == 0:
            break
    if dX != 0 or dY != 0:
        a = 'No'

print(a)

Submission status: Accepted

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

import sys

def main():
    n = int(sys.stdin.readline())
    txys = ((map(int, line.split())) for line in sys.stdin.readlines())

    pt, px, py = 0, 0, 0
    for t, x, y in txys:
        timeleft =  t - pt - abs(x - px) - abs(y - py)
        if timeleft < 0 or timeleft % 2 == 1:
            print('No')
            break
        pt, px, py = t, x, y
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys

def main():
    n = int(sys.stdin.readline())
    txys = ((map(int, line.split())) for line in sys.stdin.readlines())
    pt, px, py = 0, 0, 0
    for t, x, y in txys:
        distleft =  t - pt - abs(x - px) - abs(y - py)
        if distleft < 0 or distleft % 2 == 1:
            print('No')
            break
        pt, px, py = t, x, y
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

t=[]
x=[]
y=[]

for _ in range(N):
	tt,xx,yy=map(int,input().split())
	t.append(tt)
	x.append(xx)
	y.append(yy)

t_=0
x_=0
y_=0

for i in range(N):
	tmp1=abs(x[i]-x_) + abs(y[i]-y_) 
	tmp2=t[i]-t_
	t_=t[i]
	x_=x[i]
	y_=y[i] 
	if tmp1<=tmp2 and tmp1%2==tmp2%2:
		pass
	else:
		print("No")
		break

else:
	print("Yes")

Submission status: Accepted

Solution code:
N=int(input())

t=[]
x=[]
y=[]

for _ in range(N):
	tt,xx,yy=map(int,input().split())
	t.append(tt)
	x.append(xx)
	y.append(yy)

t_=0
x_=0
y_=0

for i in range(N):
	tmp1=x[i]-x_ + y[i]-y_ 
	tmp2=t[i]-t_
	t_=t[i]
	x_=x[i]
	y_=y[i] 
	if tmp1<=tmp2 and tmp1%2==tmp2%2:
		pass
	else:
		print("No")
		break

else:
	print("Yes")

Submission status: Accepted

Solution code:
def C_Traveling():
    N = int(input())
    a = 0
    b =0
    c =0
    for i in range(N):
        t, x, y = map(int, input().split())
        t1 = t-a
        x1 = abs(x-b)
        y1 = abs(y-c)
        z =t1 - x1 -y1
        if z%2  == 0 and z>=0:
            a =t
            b =x
            c =y
            continue
        else:
            print('No')
            break
    else: print('Yes')
        
C_Traveling()

Submission status: Accepted

Solution code:
n = int(input())
txyArray = []
for i in range(n):
    t,x,y = [int(i) for i in input().split()]
    txyArray.append([t,x,y])
t=0
x=0
y=0
for t2,x2,y2 in txyArray:
    sum = abs(x2-x) + abs(y2-y)
    diff = sum -(t2-t)
    if diff > 0 or diff%2 != 0:
        break
    t2=t
    x2=x
    y2=y
if diff > 0 or diff%2 != 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0
N = int(input())
info = []
for i in range(N):
    infocstr = input().split()
    infoc = []
    for num in infocstr:
        infoc.append(int(num))
    info.append(infoc)
    
for infoi in info:
    time = infoi[0] - t
    need = abs(x-infoi[1])+abs(y-infoi[2])
    d = time - need
    if d < 0 or d % 2 == 1:
        print('No')
        break
    t, x, y = infoi[0], infoi[1], infoi[2]
        
else:
    print('Yes')

Submission status: Accepted

Solution code:
def abs(a):   
    if a >= 0:       
        return a    
    else:        
        return (-a)    
n = int(input())
c = [] 
for i in range(0,n):     
    c.append(str(input()).split()) 
c.insert(0,[0,0,0])
for i in range(0,n):    
    t = int(c[i+1][0])-int(c[i][0])     
    x = int(c[i+1][1])-int(c[i][1])     
    y = int(c[i+1][2])-int(c[i][2])     
    d = abs(x) + abs(y)    
    if not(d <= t and t%2 == d%2):        
        print('No')        
        break
else:    
    print('Yes')

Submission status: Accepted

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) - 1):
	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: Accepted

Solution code:
N = int(input())
Position = [list(map(int,input().split())) for i in range(N)]
Position.insert(0,[0,0,0])
counter = 0
for i in range(N):
    td = Position[i+1][0] - Position[i][0]
    xd = abs(Position[i][1] - Position[i+1][1])
    yd = abs(Position[i][2] - Position[i+1][2])
    if td > xd+yd:
        if (td-(xd+yd))%2 != 0:
            break
    elif td < xd+yd:
        break
    counter += 1

if counter == N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

t.append(0)
x.append(0)
y.append(0)

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: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    cur_x = 0
    cur_y = 0
    cur_t = 0
    can_travel = True
    for _ in range(n):
        next_t, next_x, next_y = list(map(int, input().split(" ")))
        time_diff = abs(next_t - cur_t)
        xy_diff = abs(next_x - cur_x) + abs(next_y - cur_y)

        if time_diff < xy_diff:
            can_travel = False
        elif time_diff > xy_diff:
            can_travel = ((time_diff - xy_diff) % 2 == 0)

        if not can_travel:
            break
        cur_t, cur_x, cur_y = next_t, next_x, next_y

    print("Yes" if can_travel else "No")

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    cur_x = 0
    cur_y = 0
    cur_t = 0
    can_travel = True
    for _ in range(n):
        next_t, next_x, next_y = list(map(int, input().split(" ")))
        time_diff = abs(next_t - cur_t)
        x_diff = abs(next_x - cur_x)
        y_diff = abs(next_y - cur_y)

        if time_diff < (x_diff + y_diff):
            can_travel = False
        elif time_diff > (x_diff + y_diff):
            can_travel = ((time_diff - (x_diff + y_diff)) % 2 == 0)

        cur_t, cur_x, cur_y = next_t, next_x, next_y
        if not can_travel:
            break

    print("Yes" if can_travel else "No")

Submission status: Accepted

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

for i in range(N):
    # 秒数が足りないパターンと、奇数分余ってもとに戻れないパターン
    if (abs(TXY[i][1]-TXY[i+1][1])+abs(TXY[i][2]-TXY[i+1][2]) > (TXY[i+1][0]-TXY[i][0])) or \
            ((TXY[i+1][0] - TXY[i][0]) - (abs(TXY[i][1]-TXY[i+1][1])+abs(TXY[i][2]-TXY[i+1][2]))) % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:

def travel(arr):

    current_loc = (0, 0)
    current_time = 0

    for dest in arr:

        next_loc = (dest[1], dest[2])

        distance = abs(next_loc[0] - current_loc[0]) + abs(next_loc[1] - current_loc[1])

        if distance > dest[0] - current_time:
            return 'No'

        elif (dest[0] - current_time - distance)%2 != 0:
            return 'No'

    return 'Yes'


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

print(travel(arr))

Submission status: Accepted

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,y
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())#输入几行呢
i = 1
string = []
while i <= n:
    string.append(input().split(" "))
    i = i + 1
i = 0
state = 1
while i < n:
    if int(string[i][0])%2 == 0 and (int(string[i][1]) + int(string[i][2]))%2 == 0 and int(string[i][1]) + int(string[i][2]) <= int(string[i][0]):
        pass
    elif int(string[i][0])%2 != 0 and (int(string[i][1]) + int(string[i][2]))%2 != 0 and int(string[i][1]) + int(string[i][2]) <= int(string[i][0]):
        pass
    else:
        state = 0
        break
    i = i + 1
if state == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
T, X, Y = ([] for i in range(3))
ans = True
T.append(0)
X.append(0)
Y.append(0)
for i in range(N):
  t, x, y = map(int, input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
for i in range(N):
  dt = T[i + 1] - T[i]
  dx = X[i + 1] - X[i]
  dy = Y[i + 1] - Y[i]
  if dt >= abs(dx) + abs(dy) and dt % 2 == (abs(dx) + abs(dy)) % 2:
    continue
  else:
    ans = False
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

import sys

n = int(raw_input().split()[0])
tl = []
for i in range(n):
    e = [int(e) for e in raw_input().split()]
    tl.append(e)
#print tl

t = 0
x = 0
y = 0
ans = 'Yes'
for i in tl:
    ti, xi, yi = i
    dt = ti - t
    dx = abs(xi - x)
    dy = abs(yi - y)
    # print [t,x,y], i, [dt,dx,dy],
    if (dx + dy) > dt:
        # print '!',
        ans = 'No'
        break
    if (dt - (dx + dy)) & 1:
        # print '!!',
        ans = 'No'
        break
    # print
    t = ti
    x = xi
    y = yi
    
# print
sys.stdout.write('%s\n' % (ans))
sys.stdout.flush()

Submission status: Accepted

Solution code:
n = int(input())
pt = px = py = 0
ok = 1
for i in range(n):
    t, x, y = map(int, input().split())
    T = t - pt
    D = abs(x - px) + abs(y - py)
    if T < D or (T - D) % 2 == 1:
        ok = 0
        break
    pt = t; px = x; py = y
print("Yes"*ok or"No")

Submission status: Accepted

Solution code:
n=int(input())
a=[]
a.append([0,0,0])
stop=0
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    if stop==0:   
        t=a[i][0]-a[i+1][0]
        x=a[i][1]-a[i+1][1]
        y=a[i][2]-a[i+1][2]
        if abs(x)+abs(y) > abs(t) or (abs(t)-abs(x)-abs(y))%2 == 1: #absは絶対値
            stop=1
            print("No")
if stop==0:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    for i in range(N):
        t,x,y = list(map(int,input().split()))
        if ((t%2)==(abs(x+y)%2)) and (abs(x+y)<=t):

            flag = True
        else:
            flag = False
            break
    if flag == True:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(N):
    ans=(time[i+1]-time[i])-abs(axi_x[i+1]-axi_x[i])-abs(axi_y[i+1]-axi_y[i])
    if ans%2==1 or ans<0:
        print("No")
        break
    if i == N-1:
        print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
posX, posY = 0, 0
ans = True
for i in range(n):
    t, x, y = list(map(int, input().split()))
    d = (abs(posX - x) + abs(posY - y))
    if(d > t):
        ans = False
        break
    elif(d % 2 != t % 2):
        ans = False
        break
if(ans):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
t = [0 for i in range(N + 1)]
x = [0 for i in range(N + 1)]
y = [0 for i in range(N + 1)]
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
flag = 1
for i in range(N):
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if dl > dt or (dl - dt) % 2 == 1:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

n = int(raw_input())
d = [[0, 0, 0]]
for i in range(n):
    d.append([int(x) for x in raw_input().strip().split()])

for i in range(n):
    dt = d[i + 1][0] - d[i][0]
    dx = abs(d[i + 1][1] - d[i][1])
    dy = abs(d[i + 1][2] - d[i][2])
    if dt % 2 != (dx + dy) % 2 or (dx + dy) > dt:
        print('No')
        sys.exit()

print 'Yes'

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc086/tasks/arc089_a

"""
import sys
from sys import stdin
from collections import namedtuple
input = stdin.readline


def solve(points):
    cx, cy = 0, 0
    ct = 0
    for t, x, y in points:
        dt = t - ct
        dx = abs(x - cx)
        dy = abs(y - cy)
        if dx + dy > dt:
            return 'No'
        if dx + dy < dt:
            diff = dt - (dx + dy)
            if diff % 2 != 0:
                return 'No'
        ct = t
        cx = x
        cy = y
    return 'Yes'


P = namedtuple('P', ['t', 'x', 'y'])
def main(args):
    points = []
    N = int(input())
    for _ in range(N):
        t, x, y = map(int, input().split())
        points.append(P(t, x, y))
    ans = solve(points)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
N = input()
t, x, y = [0], [0], [0]
for _ in range(N):
    _t, _x, _y = map(int, raw_input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

txy = np.array([[_t, _x, _y] for _t, _x, _y in zip(t, x, y)], dtype=np.int64)

dm = np.diff(txy, axis=0)

for d in dm:
    total = np.abs(d[1]) + np.abs(d[2])
    if d[0] < total or (d[0] - total) % 2 != 0:
        print 'No'
        exit()

print 'Yes'

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
N = input()
t, x, y = [0], [0], [0]
for _ in range(N):
    _t, _x, _y = map(float, raw_input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)
 
txy = np.array([[_t, _x, _y] for _t, _x, _y in zip(t, x, y)], dtype=np.int64)

dm = np.diff(txy, axis=0)

ret = 'Yes'
for d in dm:
    total = np.abs(d[1]) + np.abs(d[2])
    if d[0] < total or (d[0] - total) % 2 != 0:
        ret = 'No'

print ret

Submission status: Accepted

Solution code:
N = int(input().strip())

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

pos = [0, 0, 0]
out = 'Yes'

for t_to, x_to, y_to in moves:
    move_to = abs(x_to - pos[1]) + abs(y_to - pos[2])
    time_to = t_to - pos[0]
    
    if move_to == time_to or (((time_to - move_to) > 0) and (time_to - move_to) % 2 == 0):
        pos = [t_to, x_to, y_to]
    else:
        out = 'No'
        break

print(out)

Submission status: Accepted

Solution code:
#abc086c
import sys

def yn(s,x,y):
 r=abs(x)+abs(y)
 if s>=r and (s-r)%2==0:
  return True
 else:
  return False

n=int(raw_input())
s0,x0,y0=map(int,raw_input().split())
if yn(s0,x0,y0)==False:
 print 'No'
 sys.exit()
for i in xrange(n-1):
 s,x,y=map(int,raw_input().split())
 if yn(s-s0,x-x0,y-y0)==False:
  print 'No'
  sys.exit()
 s0,x0,y0=s,x,y
print 'Yes'

Submission status: Accepted

Solution code:
N = int(input())
x = y = 0
for i in range(N):
	t, nx, ny = map(int, input().split())
	d = abs(nx - x) + abs(ny - y)
	if t < d or (t - d) % 2 == 1:
		print("No")
		break
else:
	print("Yes")

Submission status: Accepted

Solution code:
#! /usr/bin/env python

if __name__ == '__main__':
    N = int(input())
    a=[[0,0,0]]
    for i in range(N):
        a.append(list(map(int,input().split())))
    flag=0
    for i in range(N):
        if (((a[i+1][0]-a[i][0]) < abs(a[i][1]-a[i+1][1]) + abs(a[i][2]-a[i+1][2])) or ((a[i+1][0]-a[i][0]) % 2 != (abs(a[i][1]-a[i+1][1]) + abs(a[i][2]-a[i+1][2])) % 2)):
            flag = 1
            break
    if flag == 0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''input
2
3 1 2
6 1 1
'''

#~ @author = dwij28 (Abhinav Jha) ~#

n, data = input(), []
for N in xrange(n):
	t, x, y = map(int, raw_input().strip().split())
	data.append([t, x, y])
xp, yp, tp, ans = 0, 0, 0, True
for i in xrange(n):
	t, x, y = data[i]
	d = abs(x - xp) + abs(y - yp)
	tc = t - tp
	if not (d <= tc and tc % 2 == d % 2):
		ans = False
		break
	xp, yp, tp = x, y, t
print 'Yes' if ans else 'No'

Submission status: Accepted

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

judge = 'Yes'

N = int(input())
for i in range(N):
    t, x, y = map(int, input().split())
    if t < (x + y) or t % 2 != (x + y) % 2:
        judge = 'No'

print(judge)

Submission status: Accepted

Solution code:
from collections import defaultdict

d = defaultdict(int)
n = int(input())

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

s = sorted(d)

curent = 0

for ss in s:
    k1, k2 = d[ss]
    k3 = k1 + k2
    if k3 - curent > ss:
        print('No')
        exit(0)
    if ((k3 & 1) == 1 and (ss & 1) == 1) or ((k3 & 1) == 0 and (ss & 1) == 0):
        curent = k3
    else:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
t = 0
x = 0
y = 0
ans = 'Yes'
for _ in range(N):
    ti, xi, yi = map(int, input().split())
    if not (ti - t >= abs(xi - x) + abs(yi - y) and (ti - t) % 2 == (abs(xi - x) + abs(yi - y)) % 2):
        ans = 'No'
    t = ti
    x = xi
    y = yi
print(ans)

Submission status: Accepted

Solution code:
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


N = int(input())
dest = [[0,0,0]]
dest1 = [list(map(int, input().split())) for i in range(N)] # (ti xi yi)のリスト
dest = dest + dest1
yn = 0

for i in range(N):
    t_int = dest[i+1][0] - dest[i][0]
    t_min = abs(dest[i+1][1] - dest[i][1]) + abs(dest[i+1][2] - dest[i][2])
    if t_int >= t_min and (t_int - t_min)%2 == 0:
        continue
    else:
        yn += 1

if yn > 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
n = int(input())


def get_taxicab_metric(x1, y1, x2, y2):
    a = abs(x1 - x2)
    b = abs(y1 - y2)
    return a + b


t_prev, x_prev, y_prev = 0, 0, 0
is_failed = False

for _ in range(n):
    t, x, y = [int(x) for x in input().split()]

    distance = get_taxicab_metric(x, y, x_prev, y_prev)
    time_distance = t - t_prev

    if distance > time_distance:
        is_failed = True
        break

    if distance % 2 != time_distance % 2:
        is_failed = True
        break

    t_prev, x_prev, y_prev = t, x, y

print("No" if is_failed else "Yes")

Submission status: Accepted

Solution code:
import sys
N = int(input())
ls = [list(map(int, input().split())) for i in range(N)]
ls.insert(0, [0, 0, 0])
# print(ls)
for i in range(N):
    dist = abs(ls[i+1][1] - ls[i][1]) + abs(ls[i+1][2] - ls[i][2])
    time = ls[i+1][0] - ls[i][0]
    if dist > time or (time - dist) % 2 != 0:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
N = input()
ct, cx, cy = 0, 0, 0
enabled = True
for i in range(N):
    nt, nx, ny = map(int, raw_input().split())
    d = abs(nx-cx) + abs(ny-cy)
    dt = nt - ct
    enabled &= (dt >= d) and (dt % 2 == d % 2)
print "Yes" if enabled else "No"

Submission status: Accepted

Solution code:
import numpy as np

input_line_count = input()
line_count = int(input_line_count)

line = np.zeros([line_count, 3])
line_check = np.zeros(line_count)
for num in range(line_count):
  input_line = input()
  line[num] = input_line.split()
  if(line[num][0] % 2 == 0):
    if((line[num][1] + line[num][2]) % 2 == 0 and (line[num][1] + line[num][2]) <= line[num][0]):
      line_check[num] = 1
  elif(line[num][0] % 2 == 1):
    if((line[num][1] + line[num][2]) % 2 == 1 and (line[num][1] + line[num][2]) <= line[num][0]):
      line_check[num] = 1
for num1 in range(line_count):
  if(line_check[num1] == 0):
    answer = "No"
    break
  else:
    answer = "Yes"

print(answer)