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 = int(input())

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

ct,cx,cy = 0,0,0
for i in range(N):
    hdist = abs(data[i][1] - cx) + abs(data[i][2] - cy)
    if hdist > abs(data[i][0] - ct) or abs(hdist - abs(data[i][0] - ct)) % 2 != 0:
        print("No")
        break
    ct,cx,cy = data[i][0],data[i][1],data[i][2]
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t0, x0, y0 = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - t0
    dx = x - x0
    dy = y - y0
    if dt < dx + dy:
        print("No")
        exit()
    if (dx + dy - dt) % 2 != 0:
        print("No")
        exit()
    t0, x0, y0 = t, x, y
print("Yes")

Submission status: Accepted

Solution code:
abs = lambda x:x if x > 0 else -x

N = int(input())
txt = "Yes"

t,x,y = [0,0,0]

for nanachi in range(N):
  T,X,Y = map(int,input().split())
  d = abs(X-x) + abs(Y-y)
  if not((T - t >= d) and (d - T + t)%2 == 0):
    txt = "No"
    break
  t,x,y = [T,X,Y]
print(txt)

Submission status: Accepted

Solution code:


def solve():
    N = int(raw_input())
    t_now, x_now, y_now = 0, 0, 0
    for _ in xrange(N):
        t_next, x_next, y_next = map(int, raw_input().split())
        distance = abs(x_now - x_next) + abs(y_now - y_next)

        if distance > t_next - t_now or distance % 2 != (t_next - t_now) % 2:
            print "No"
            return
        t_now, x_now, y_now = t_next, x_next, y_next

    print "Yes"
    return


solve()

Submission status: Accepted

Solution code:
n = int(input())

def f(n):
  t_n, x_n, y_n = 0, 0, 0
  for i in range(n):
    t, x, y = map(int, input().split())
    t_d = abs(t_n - t)
    x_d = abs(x_n - x)
    y_d = abs(y_n - y)
    if not x_d+y_d <= t_d or (x_d+y_d)%2 == 0 and not t_d%2 == 0 or not (x_d+y_d)%2 == 0 and t_d%2 == 0:
      return "No"
    t_n, x_n, y_n = t, x, y
  
  return "Yes"

print(f(n))

Submission status: Accepted

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

counter=0
posnow=[0,0,0]
for i in range(N):
    dt=sche[i][0]-posnow[0]
    dx=sche[i][1]-posnow[1]
    dy=sche[i][2]-posnow[2]
    if (dt-dx-dy)<0 or (dt-dx-dy)%2:
        break
    else:
        posnow=sche[i]
        counter=counter+1
if counter==N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
data = []
for i in range(n):
    data.append(input().split())

x, y = 0, 0
t = 0
ans = "Yes"

for i in data:
    add = abs(int(i[2])-y) + abs(int(i[1])-x)
    tt = int(i[0])-t

    if tt % add == 0 :
        t = int(i[0])
        x,y = int(i[1]), int(i[2])

    else:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
t_before = 0
x_before = 0
y_before = 0
result = 'Yes'

N = int(input())
for i in range(N) :
  t, x, y = map(int, input().split())
  t_diff = abs(t - t_before)
  x_diff = abs(x - x_before)
  y_diff = abs(y - y_before)
  if (x_diff <= t_diff) and (y_diff <= t_diff) and ((t_diff - (x_diff + y_diff)) % 2 == 0) :
    t_before = t
    x_before = x
    y_before = y
  else :
    result = 'No'
    break
print(result)

Submission status: Accepted

Solution code:
import sys
def check_ans(t,x,y,nt,nx,ny):
    if (x+y) > (nx+ny+t):
        print("No")
        sys.exit()    
    if (x >= nx):
        nt += (x-nx)
    elif(x <= nx):
        nt += (nx-x)
    if (y >= ny):
        nt += (y-ny)
    elif(y <= ny):
        nt += (ny-y)
    if (t-nt)%2 != 0:
        print("No")
        sys.exit()

N = int(input())
nt = 0
nx = 0
ny = 0
t = []
x = []
y = []
#入力
for i in range(N):
    temp = input().split(" ")
    t.append(temp[0])
    x.append(temp[1])
    y.append(temp[2])
for i in range(N):
    if i == 0:
        check_ans(int(t[i]), int(x[i]), int(y[i]), nt, nx, ny)
    else:
        nt = int(t[i-1])
        nx = int(x[i-1])
        ny = int(y[i-1])
    check_ans(int(t[i]), int(x[i]), int(y[i]), nt, nx, ny)
print("Yes")

Submission status: Accepted

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

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

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

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

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

    
sum = 0 
for num in ans:
    sum = sum + num


if sum==n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# from abs import math
n = int(input())
tmpt = 0
tmpx, tmpy = 0, 0
c = 0

def check(t, x, y):
    if t>=x+y and ( (t%2==0 and (x+y)%2==0) or (t%2==1 and (x+y)%2==1) ):
        return True
    else:
        return False

for i in range(n):
    t, x, y = map(int, input().split())
    if x==tmpx and y==tmpy:
        break   

    target = t-tmpt
    tmpt = t
    t_x, t_y = abs(x-tmpx), abs(y-tmpy)
    tmpx = x
    tmpy = y
    if check(target, t_x, t_y):
        c+=1
    else:
        break

if n==c:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# coding: utf-8

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

def check(li):
    before = [0, 0, 0]
    for i in li:
        n, x, y = map(int, i)
        move = abs(n - before[0])
        pos = abs(x - before[1]) + abs(y - before[2])
        if not (pos <= move and pos % 2 == move % 2):
            return "No"
        before = [n, x, y]
    return "Yes"

# output
print(check(li))

Submission status: Accepted

Solution code:
a = int(raw_input())
curr_x = 0
curr_y = 0
old_t = 0
for i in range(a):
    t, x, y = map(int, raw_input().split())
    diff_x = abs(x - curr_x)
    diff_y = abs(y - curr_y)
    diff_xy = diff_x + diff_y
    result = 0
    t2 = t - old_t
    #t = t - old_t

    if diff_xy > t2:
        result += 1
        break
    elif diff_xy == t2:
        #print "Yes"
        result += 0
        curr_x = x
        curr_y = y
        old_t = t
    elif (t2 - diff_xy) % 2 == 0:
        #print "Yes"
        result += 0
        curr_x = x
        curr_y = y
        old_t = t
    else:
        result += 1
        break

if result == 0:
    print "Yes"
else:
    print "No"

Submission status: Accepted

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

sum = 0
for i in range(N):
    time = t[i+1]  - t[i]
    dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if time < dist:
        print("No")
        break
    else:
        if dist%2 == time%2:
            sum += 1
            continue
        else:
            print("No")
            break

if sum == N:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = []
x = []
y = []
for i in range(N + 1):
    t.append(0)
    x.append(0)
    y.append(0)

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

f = 0
for i in range(N):
    abs_list = []
    a = t[i + 1] - t[i]
    while a >= 0:
        abs_list.append(a)
        a += -2
    if abs(x[i] - x[i + 1] + y[i] - y[i + 1]) not in abs_list:
        f += 1
if f >= 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = input()
N = int(N)
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    txy = input()
    t, x, y = txy.split()
    t = int(t)
    x = int(x)
    y = int(y)
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)



for i in range(1, N+1):
    t = t_list[i] - t_list[i-1]
    x = abs(x_list[i] - x_list[i-1])
    y = abs(y_list[i] - y_list[i-1])
    xy = x+y
    if t%2 == xy%2:
        res = 'Yes'
    elif not t%2 == xy%2:
        res = 'No'
    if t < xy:
        res = 'No'

print(res)

Submission status: Accepted

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 dis == 0:
            if (points_list[i][0] - points_list[i-1][0]) % 2 == 0:
                p = points_list[i][1] + points_list[i][2]
            else:
                flag = False
                break
        elif points_list[i][0] - points_list[i-1][0] >= dis:
            if (points_list[i][0] - points_list[i-1][0]) % dis == 0 or (points_list[i][0] - points_list[i-1][0] - dis) % 2 == 0:
                p = points_list[i][1] + points_list[i][2]
                continue
                if abs(points_list[i][1] - points_list[i-1][1]) <= (points_list[i][0] - points_list[i-1][0]) and abs(points_list[i][2] - points_list[i-1][2]) <= (points_list[i][0] - points_list[i-1][0]):
                    continue
                else:
                    flag = False
                    break
            else:
                flag = False
                break
        else:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
arr=[]
for _ in range(int(raw_input())):
	arr.append(map(int,raw_input().split(' ')))
temp1,temp2,temp3,ans=0,0,0,True
for temp,x,y in arr:
	x_d = abs(x-temp1);y_d = abs(y-temp2);t_d=temp-temp3;
	if t_d >= x_d + y_d:
		if t_d%2 == ((x_d+y_d)%2):
			flag = True
		else:
			flag = False
			print "No"
			sys.exit()
	else:
		flag = False
		print "No"
		sys.exit()
print "Yes"

Submission status: Accepted

Solution code:
def seinokazu(num):
    if num >= 0:
        return num
    else:
        num = -1 * num
        return num


n = input()
n = int(n)
clear = False

nexs = []

now = 0
x = 0
y = 0

for z in range(n):
    nexs.append(input())

for i in range(n):
    aa = nexs[i].split(" ")
    nex = int(aa[0])
    xx = int(aa[1])
    yy = int(aa[2])

    xsa = xx - x
    xsa = seinokazu(xsa)
    ysa = yy - y
    ysa = seinokazu(ysa)
    xysa = xsa + ysa
    nsa = nex - now
    if xysa > nsa:
        clear = False
        break
    else:
        sa = xysa - nsa
        sa = seinokazu(sa)
        if sa % 2!=0:
            clear = False
            break
        else:
            clear = True
    now = nex
    x = xx
    y = yy

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

Submission status: Accepted

Solution code:
N = int(input())
t, x, y = [0], [0], [0]
isPossible = True
for i in range(N):
    a, b, c = [int(j) for j in input().split()]
    t.append(a)
    x.append(b)
    y.append(c)

for i in range(N):
    dt = t[i+1] - t[i]
    dx = abs(x[i+1] - x[i])
    dy = abs(y[i+1] - y[i])
    
    if dt <  dx + dy or dt % 2 != (dx + dy) % 2:
        isPossible = False

print(("No", "Yes")[isPossible])

Submission status: Accepted

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)
    dif_time = t - current
    dif = dif_time - tmp
    if tmp > dif_time:
        flag = True
    elif tmp == dif_time:
        flag = False
    elif tmp % 2 == 0 and dif_time % 2:
        flag = True
    else:
        flag = False
    if flag:
        print("No")
        break
    point = [x, y]
    current = t
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input()) 
flag = True
def isTravel(ti, xi, yi):
    a_min = [0, xi, (xi+yi-ti)//2, (xi-yi-ti)//2]
    a_max = [ti, xi+ti, (xi+yi+ti)//2, (xi-yi+ti)//2]
    a = max(a_min)
    if max(a_min)<=min(a_max) and (xi+yi+ti)%2==0:
        return True
    else:
        return False

for _ in range(N):
    ti, xi, yi = map(int, input().split())
    if flag:
        if isTravel(ti, xi, yi):
            pass
        else:
            flag = False
        
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math

N = int(input())
X = 0
Y = 0
T = 0
flag = True
for i in range(N):
    t,x,y = [int(i) for i in input().split()]
    dt = t-T
    dx = abs(x-X)
    dy = abs(y-Y)
    if dx + dy <= dt and (dt - dx - dy) % 2 == 0:
        flag = True
    else:
        flag = False

    if flag == False:
        break

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

Submission status: Accepted

Solution code:
import sys
N=int(input())
placeT=[0]*(N+1);placeX=[0]*(N+1);placeY=[0]*(N+1);
for i in range(N):
    placeT[i+1],placeX[i+1],placeY[i+1]=map(int,input().split())
for i in range(1,N+1):
    t0=placeT[i-1];x0=placeX[i-1];y0=placeY[i-1];
    t=placeT[i];x=placeX[i];y=placeY[i];
    if abs(x-x0)+abs(y-y0)>t-t0:
        print("No");sys.exit();
    else:
        if (abs(x-x0)+abs(y-y0)-(t-t0))%2!=0:
            print("No");sys.exit();
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

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

for i in range(N):
    t_, x_, y_ = map(int, input().split())
    t.append(t_)
    x.append(x_)
    y.append(y_)

ans = "Yes"
for i in range(N):
    if x[i] + y[i] > t[i]:
        ans = "No"
        break
    if t[i] % 2 == 0 and (x[i] + y[i]) % 2 == 1:
        ans = "No"
        break
    elif t[i] % 2 == 1 and (x[i] + y[i]) % 2 == 0:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    t1, x1, y1 = 0, 0, 0

    for i in range(N):
        t2, x2, y2 = map(int, input().split())
        dt = t2 - t1
        ds = abs(x1 - x2) + abs(y1 - y2)
        if dt - ds >= 0 and (dt - ds) % 2 == 0:
            pass
        else:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

N = int(input())

prev_t, x, y = 0, 0, 0
for _ in range(N):
    t, t_x, t_y = map(int, input().split())

    m_t, m_x, m_y = t - prev_t, math.fabs(t_x - x), math.fabs(t_y - y)
    if m_x > m_t or m_y > m_t or math.fabs(m_t - (m_x + m_y)) % 2 == 1:
        print("No")
        exit()

    prev_t, x, y = t, t_x, t_y

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0

for i in range(n):
    tb, xb, yb = t, x, y
    t, x, y = map(int, input().split())
    tn = t - tb
    xn = x - xb
    yn = y - yb
    move = abs(xn) + abs(yn)

    if tn < move or (tn - move) % 2 == 1:
        ans = 'No'
        break

else:
    ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

list = [(0,0,0)]
for i in range(N):
	data = input().split()
	list.append((int(data[0]), int(data[1]), int(data[2])))

for i in range(1, len(list)):
	t = list[i][0] - list[i-1][0]
	if(list[i][1] != list[i-1][1]):
		x = abs(list[i][1] - list[i-1][1])
		t -= x
		if(t < 0):
			print("No")
			exit()
	if(list[i][2] != list[i-1][2]):
		y = abs(list[i][2] - list[i-1][2])
		t -= y
		if(t < 0):
			print("No")
			exit()
	if(t % 2 != 0):
		print("No")
		exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())

tn = 0
xn = 0
yn = 0

while n > 0:
    n -= 1
    c = "f"
    I = input()
    N = I.split()
    t = int(N[0])
    x = int(N[1])
    y = int(N[2])

    ts = t - tn
    xs = x - xn
    ys = y - yn
    s = ts - ( xs + ys )

    if s == 0:
        c = "t" 
    elif s > 0:
        if s % 2 ==0:
            c = "t"
    if c == "f":
        break

if c == "t":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    t,x,y=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    for i in range(1,N+1):
        t[i],x[i],y[i]=map(int,input().split())
        dif=((t[i]-t[i-1])-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])))
        #print(dif)
        if dif < 0 or dif % 2 != 0:
            print("No")
            return
    print("Yes")
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
flag = False

def traverable(st,sx,sy,gt,gx,gy):
    if ((gx+gy)-(sx+sy)) % 2 != (gt-st) %2:
        return False
    elif (gx+gy)-(sx+sy) > gt-st:
        return False
    else:
        return True

N = int(input())
t = [0];x = [0];y = [0]
for i in range(N):
    tt,xx,yy = [int(i) for i in input().split()]
    t.append(tt);x.append(xx);y.append(yy)

for i in range(N):
    if not(traverable(t[i],x[i],y[i],t[i+1],x[i+1],y[i+1])):
        flag = True

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

Submission status: Accepted

Solution code:
no_flag = False
N = int(input())
old_t, old_x, old_y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if not no_flag:
        judge = (t - old_t) - (x - old_x) - (y - old_y)
        if (judge < 0) or (judge % 2):
            no_flag = True
if not no_flag: print('Yes')
else:   print('No')

Submission status: Accepted

Solution code:
c = [0, 0]
f = True
for _ in range(int(input())):
    t, x, y = map(int, input().split())
    if sum(c) + t < abs(x) + abs(y):
        f = False
    if t % 2 != abs(c[1] - y + c[0] - x) % 2:
        f = False
print(f and 'Yes' or 'No')

Submission status: Accepted

Solution code:
n = int(input())
cp = [0,0]
t1 = 0

for i in range(n):
    t,x,y = map(int,input().split())
    l = abs(x-cp[0])+abs(y-cp[1])
    s = t - t1 - l
    if s < 0 or s % 2 == 1:
        print('No')
        break
    cp = [x,y]
    t1 = t
else:
    print('Yes')

Submission status: Accepted

Solution code:
M = int(raw_input())

t0,x0,y0=0,0,0
OK=1

for i in range(M):
    t,x,y = map(int, raw_input().split())
    dl=abs(x-x0)+abs(y-y0)
    dt=t-t0
    if(dl>dt):
        OK=0
        break
    elif ((dt-dl)%2==1):
        OK=0
        break
    else:
        t0,x0,y0=t,x,y

if OK==1 :
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#%%
def canDeerGo(strinp):
    t, n1, n2 = map(int, strinp.split())
    var1 = t + n1 + n2
    var2 = n1 + n2
    ans = True
    if var1 % 2 != 0 or var2 > t:
        ans = False
    return ans
#%%
def diffData(s,ss):
    t, n1, n2 = map(int, s.split())
    t2,n12,n22 = map(int, ss.split())
    l = [t2-t,n12-n1,n22-n2]
    canDeerGo(' '.join((list(map(str,l)))))
#%%
num = int(input())
ss =''
for i in range(num):
    s = input()
    if ss != '':
        diffData(s,ss)
    ans = canDeerGo(s)
    if ans == False:
        ans = 'No'
        break
    elif i == num-1:
        ans = 'Yes'
    ss = s
print(ans)

Submission status: Accepted

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()))
    dt, dxy = t - ot, abs(x - ox) + abs(y - oy)

    if dt < dxy or (dt + dxy) % 2 != 0:
        flg = False

    ot, ox, oy = t, x, y

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

Submission status: Accepted

Solution code:
n = int(input())
t0 = int(0)
x0 = int(0)
y0 = int(0)

def solve(n):
    global t0, x0, y0
    for i in range(n):
        t, x, y = map(int, input().split())
        if t - t0 < abs(x - x0) + abs(y - y0):
            return "No"
        if ((t - t0) - (abs(x - x0) + abs(y - y0))) % 2 == 1:
            return "No"
        x0 = x
        y0 = y
        t0 = t        
    return "Yes"    

print(solve(n))

Submission status: Accepted

Solution code:
n = int(input())
me = [0,0]
arr = []
tmp = 0
flg = True
for i in range(n):
    arr += [list(map(int,input().split()))]

for t in arr:
    for _ in range(t[0]-tmp):
        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
        tmp = t[0]
    if me != t[1:]:
        flg = False
        break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

flg = 1
for i in range(N):
        if x[i]+y[i] > t[i]:
            flg = 0
        elif (x[i]+y[i])%2 != t[i]%2:
            flg = 0
print("Yes" if flg == 1 else "No")

Submission status: Accepted

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

for i in range(n):
   ttmp, xtmp, ytmp = map(int, input().split())
   t.append(ttmp)
   x.append(xtmp)
   y.append(ytmp)

for i in range(n):
   if i == 0:
      if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2:
         cnt += 1
      else:
         print("No")
         break
   else:
         if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2 and x[i]+y[i]-x[i-1]-y[i-1] <= t[i]-t[i-1] :
            cnt += 1
         else:
            print("No")
            break

if cnt == n:
   print("Yes")

Submission status: Accepted

Solution code:
'''
奇数距離の場合、偶数回の移動は不可能
偶数距離の場合、奇数回の移動は不可能
'''
N = int(input())
L =[]
for i in range(N):
	t,x,y = input().split(' ')
	L.append([int(t),int(x),int(y)])

now = [0,0,0]
for i in range(N):
	time = L[i][0] - now[0]
	sub_x = abs(now[1] - L[i][1])
	sub_y = abs(now[2] - L[i][2])
	dist = sub_x + sub_y
	if dist%2 == 0:
		if time < dist or time%2 == 1:
			print('No')
			quit()
		else:
			now = L[i]
	else:
		if time < dist or time%2 == 0:
			print('No')
			quit()
		else:
			now = L[i]


print('Yes')

Submission status: Accepted

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

for i in range(num):
    n_next, x_next, y_next = [int(i) for i in input().split()]
    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
    else:
        x_now = x_next
        y_now = y_next
        n_now = n_next

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

Submission status: Accepted

Solution code:
import numpy as np
N =int(input())
data =np.array( [[ int(i) for i in input().split(" ")] for i in range(N)])
t_past = 0
x_past = 0
y_past = 0
flag = 0
for i in range(N):
    t_diff = data[i,0] - t_past
    x_diff = data[i,1] - x_past
    y_diff = data[i,2] - y_past
    if not( t_diff -abs(x_diff) -abs(y_diff) >=0 and (t_diff-abs(x_diff)-abs(y_diff))%2 ==0):
        flag = 1
        break
    t_past = data[i,0]
    x_past = data[i,1]
    y_past = data[i,2]
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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))
can_travel = False
prev_t, prev_x, prev_y = 0,0,0
for t, x, y in txy:
    if abs(x-prev_x) + (y-prev_y) > t - prev_t:
        can_travel = False
        break
    elif (abs(x-prev_x) + abs(y-prev_y)) % 2 != (t-prev_t) % 2:
        can_travel = False
        break
    else:
        prev_t, prev_x, prev_y = t, x, y
        can_travel = True
        continue
if can_travel:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
t=0
x=0
y=0
ans=True
for i in range(N):
  ta,xa,ya=map(int,input().split())
  res1=abs(xa-x)
  res2=abs(ya-y)
  if res1+res2>(ta-t):
    ans=False
    break
  else:
    if ((ta-t)-(res1+res2))%2==1:
      ans=False
      break
  t=ta
  x=xa
  y=ya
if ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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])
    #終了条件
    #間に合わない or 偶奇が違う
    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: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

flag = 0
for i in range(N):
   T_min = (x[i+1]-x[i]) + (y[i+1]-y[i])
   if (t[i+1]-t[i]) < T_min:
      flag = 1
      break
   elif (t[i+1]-t[i]-T_min)%2 != 0:
      flag = 1
      break

if flag ==1:
   print("No")

else:
   print("Yes")

Submission status: Accepted

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 or tdiff < xdiff + ydiff:
        canBePlanned = 'No'
        break
    xprev, yprev, tprev = x[i], y[i], t[i]

print(canBePlanned)

Submission status: Accepted

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

judge = 0
now = [0, 0, 0]

for i in range(N):
    t = int(plan[i][0])
    x = int(plan[i][1])
    y = int(plan[i][2])
    
    dis = abs(x - now[1]) + abs(y - now[2])
    t_ = t - now[0]
    
    if t_ < dis:
        judge = 1
        break
    else:
        t_ = t_ - dis
        
        if t_ % 2 != 0:
            judge = 1
            break
    
    now = [t, x, y]

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

Submission status: Accepted

Solution code:
# coding=utf-8

N = int(input())

l = [(0,0,0)]
for _ in range(N):
    line = input().split(" ")
    t = int(line[0])
    x = int(line[1])
    y = int(line[2])
    l.append((t, x, y))

def judge(s1, s2):
    t = abs(s1[1]-s2[1])
    t += abs(s1[2]-s2[2])
    diff = (s2[0]-s1[0]) - t

    if diff==0:
        return True
    elif diff<0:
        return False
    else:
        return diff%2==0

for i in range(len(l)-1):
    s1 = l[i]
    s2 = l[i+1]
    if not judge(s1,s2):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
num=int(raw_input())
startTime =0
startX=0
startY=0
endTime =0
endX=0
endY=0

flag=False
for i in range(num):
	test=raw_input().split(" ")
	test=map(int, test)
	endTime = test[0]
	endX = test[1]
	endY = test[2]
	now = abs(startTime-endTime) - (abs(startY-endY) + abs(startX-endX))
	if not(now >= 0 and now%2==0):
		flag=True
		break
	startY = endY
	startX = endX
	startTime = endTime

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

Submission status: Accepted

Solution code:
def reachable(dt,dx,dy):
  r = dx + dy
  c1 = dt >= r
  c2 = ((dt - r) % 2 == 0)
  return c1 & c2

def solve():
  N = int(input())
  t=0
  x=0
  y=0
  ans = "Yes"
  for i in range(N):
    raw = list(map(int,input().split(" ")))
    dt=raw[0]-t
    dx=raw[1]-x
    dy=raw[2]-y
    t = raw[0]
    x = raw[1]
    y = raw[2]
    if not reachable(dt,dx,dy):
      ans = "No"
      break
    
  return ans

if __name__ == '__main__':
  
  ans = solve()
  print(ans, flush=True)

Submission status: Accepted

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+1][0]-list[i][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: Accepted

Solution code:
N = int(input())

init_x, init_y, init_t = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    diff_t = t - init_t
    dist = x - init_x + y - init_y
    if (diff_t >= dist) and ((diff_t % 2 == 0 and dist % 2 == 0) or (diff_t % 2 != 0 and dist % 2 != 0)):
        init_x, init_y, init_t = t, x, y
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(raw_input())

plan = []

for i in range(N):
    num = map(int, raw_input().split())
    plan.append(num)

#print array

pre_time  = 0
pre_cord_x = 0
pre_cord_y = 0

available = True

while len(plan) > 0:
    case = plan.pop(0)
    dif_t = case[0] - pre_time
    dif_x = case[1] - pre_cord_x
    dif_y = case[2] - pre_cord_y

    if ((dif_x + dif_y) <= dif_t) and (((dif_t - (dif_x + dif_y)) % 2) == 0):
        available = True
    else:
        available = False
        break
    # continue
    pre_time   = case[0]
    pre_cord_x = case[1]
    pre_cord_y = case[2]

if available == True:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
import sys
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
t[0]=0
x[0]=0
y[0]=0
for i in range(1,n+1):
    t[i],x[i],y[i] = map(int,input().split())
    if i!=0:
        if abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>t[i]-t[i-1]:
            print("No")
            sys.exit()
        if ((x[i-1]+y[i-1])%2==0 and (x[i]+y[i])%2==0) or ((x[i-1]+y[i-1])%2==1 and (x[i]+y[i])%2==1):
            if (t[i]-t[i-1])%2!=0:
                print("No")
                sys.exit()
        else:
            if (t[i]-t[i-1])%2==0:
                print("No")
                sys.exit()

                
print("Yes")