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:
# -*- coding: utf-8 -*-

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

current_position = [0, 0]
t = 0
flag = True
for i in range(N):
    diff_x = abs(a[i][1] - current_position[0])
    diff_y = abs(a[i][2] - current_position[1])
    p = (a[i][0] - t) - (diff_x + diff_y)
    if p >= 0 and p % 2 == 0:
        pass
    else:
        flag = False
        break
    t = a[i][0]
    current_position[0] = a[i][1]
    current_position[1] = a[i][2]
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
old_t = 0
old_x, old_y = 0, 0
ok = True
for i in range(n):
    t, x, y = map(int, input().split())
    if ok:
        dt = t - old_t
        dx = abs(x - old_x)
        dy = abs(y - old_y)
        if dt < dx+dy:
            ok = False
            break
        else:
            if dt % 2 == 0:
                if (dx + dy) % 2 != 0:
                    ok = False
                    break
            else:
                if (dx + dy) % 2 == 0:
                    ok = False
                    break
        old_t = t
        old_x = x
        old_y = y
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
is_yes = False

for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y <= t) & ((x + y + t) % 2 == 0):
        is_yes = True
    else:
        print("No")
        quit()

if is_yes:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

n = int(input())
prev_t = 0
prev_x = 0
prev_y = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    d_t = abs(prev_t - t)
    d_x = abs(prev_x - x)
    d_y = abs(prev_y - y)
    if d_t % 2 != ((d_x + d_y) % 2) or d_t < d_x + d_y:
        print('No')
        sys.exit()
    prev_t = t
    prev_x = x
    prev_y = y
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
S = "Yes"
A = [(0,0,0)]
for i in range(N):
    t,x,y = map(int,input().split())
    A.append((t,x,y))
A = sorted(A)
for i in range(N):
    t1,x1,y1 = A[i]
    t2,x2,y2 = A[i+1]
    if abs(x2-x1)+abs(y2-y1) > t2-t1  or   (abs(x2-x1)+abs(y2-y1))%2 != (t2-t1)%2:
        S = "No"
        break
print(S)

Submission status: Accepted

Solution code:
N = int(input())
L = [list(map(int, input().split())) for k in range(N)]
L = [[0,0,0]] + L
for k in range(1,N+1):
    if (L[k][0]-L[k-1][0])%2 != (abs(L[k][1]-L[k-1][1])+abs(L[k][2]-L[k-1][2]))%2 or L[k][0]-L[k-1][0] < abs(L[k][1]-L[k-1][1])+abs(L[k][2]-L[k-1][2]):
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def can_Travel(visits):
    current_loc = (0, 0)
    current_time = 0
    for visit in visits:
        next_loc = (visit[1], visit[2])
        distance =  abs(next_loc[0] - current_loc[0]) + abs(next_loc[1] - current_loc[1])

        if distance > visit[0] - current_time:
            return False
        elif (visit[0] - current_time - distance)%2 != 0:
            return False

    return True


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

print("Yes" if can_Travel(visits) else "No")

Submission status: Accepted

Solution code:
N = int(input())
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
for i in range(N):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())
for i in range(N):
    dt = t[i+1] - t[i] 
    dx = x[i+1] - x[i]
    dy = y[i+1] - y[i]
    if dx+dy > dt or (dt-dx-dy)%2!=0:
        print('No')
        break
    if i == N-1:
        print('Yes')

Submission status: Accepted

Solution code:
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    if result==0:
        print('No')
        break
if result:
  print('Yes')

Submission status: Accepted

Solution code:
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    #print (result)
if result==1:
    print ('Yes')
else:
    print ('No')

Submission status: Accepted

Solution code:
N = int(input())
next_plan = [0, 0, 0]
for i in range(N):
    now_plan = next_plan
    next_plan = [int(i) for i in input().split()]
    time = next_plan[0] - now_plan[0]
    x = abs(next_plan[1] - now_plan[1])
    y = abs(next_plan[2] - now_plan[2])
    distance = x + y
    if not (distance <= time and (time - distance) % 2 == 0):
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
def solve():
  N = int(input())
  t = [0]
  x = [0]
  y = [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):
    l = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if l > dt or l % 2 != dt % 2:
      return "No"
  return "Yes"

print(solve())

Submission status: Accepted

Solution code:
N=int(input())
ans=True
for i in range(N):
    a,b,c=map(int,input().split())
    n=(a)-abs(b)-abs(c)
    if n<0 or n%2==1:
        ans=False
if ans==True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
x,y,z=0,0,0
ans=True
for i in range(N):
    a,b,c=map(int,input().split())
    n=(a-x)-abs(b-y)-abs(c-z)
    x,y,z=a,b,c
    if n<0 or n%2==1:
        ans=False
if ans==True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    t, x, y = [int(x) for x in input().split()]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')

Submission status: Accepted

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

n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    travel.append([int(x) for x in input().split()])

for j in travel:
    t, x, y = j[0], j[1], j[2]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')

Submission status: Accepted

Solution code:
import sys


def dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


N = int(input())
q = []
for i in range(N):
    q.append(tuple(list(map(int, input().split()))))
q = sorted(q)

tmp = (0, 0, 0)
for query in q:
    if (query[0] - tmp[0] < dist(tmp[1:], query[1:]) or (query[1] - tmp[1] + query[2] - tmp[2]) % 2 != (query[0] - tmp[0]) % 2):
        print('No')
        sys.exit()
else:
    print('Yes')

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def abs(x):
    if x>=0:
        return x
    else:
        return -x

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

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

    print('Yes')

Submission status: Accepted

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

if __name__ == '__main__':
    n = int(input())
    l = list(list(map(int, input().split())) for _ in range(n))

    dt = l[0][0]
    dx = l[0][1]
    dy = l[0][2]
    if BlCannotGo(dt, dx, dy):
        print('No')    
        exit()
        
    for i in range(1,n):
        dt = l[i][0] -  l[i-1][0] 
        dx = l[i][1] -  l[i-1][1]
        dy = l[i][2] -  l[i-1][2]
        if BlCannotGo(dt, dx, dy):
            print('No')    
            exit()

    print('Yes')

Submission status: Accepted

Solution code:
import time
n = int(input())
t = [[i for i in map(int, input().split())] for _ in range(n)]

now = [0, 0, 0]
flag = True

for target in t:
    t_t, t_x, t_y = target
    n_t, n_x, n_y = now

    distance = abs(t_x-n_x) + abs(t_y - n_y)
    require_time = t_t - n_t

    if distance <= require_time and (distance-require_time) % 2 == 0:
        now = target
        continue
    else:
        flag = False
        break

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

Submission status: Accepted

Solution code:
N=int(input())
t=0
x=0
y=0
for i in range(N):
    T=t
    X=x
    Y=y
    t,x,y=map(int,input().split())
    if abs(X-x)+abs(Y-y)>t-T:
        print("No")
        exit()
    elif (X+Y+T+x+y+t)%2!=0:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
start = [0, 0, 0]
for _ in range(N):
    goal = list(map(int, input().split()))
    dif = abs(goal[1] - start[1]) + abs(goal[2] - start[2])
    time = goal[0] - start[0]
    if dif > time or (dif - time ) % 2 != 0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
st, sx, sy = 0, 0, 0

is_reach = True

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

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


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

Submission status: Accepted

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

def can_reach(a):
    c = 0
    n = [0, 0]
    for point in a:
        c = point[0] - c
        dis = abs(point[1] - n[0]) + abs(point[2] - n[1])
        if (dis > c) or ((c - dis) % 2 != 0):
            return False
        c = point[0]
        n[0] = point[1]
        n[1] = point[2]
    return True

def main():
    n = int(input())
    a = [ list(map(int, input().split())) for _ in range(n)]

    print('Yes' if can_reach(a) else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def can_reach(a):
    c = 0
    n = [0, 0]
    for point in a:
        c = point[0] - c
        dis = (point[1] - n[0]) + (point[2] - n[1])
        if (dis > c) or ((c - dis) % 2 != 0):
            return False
        c = point[0]
        n[0] = point[1]
        n[1] = point[2]
    return True

def main():
    n = int(input())
    a = [ list(map(int, input().split())) for _ in range(n)]

    print('Yes' if can_reach(a) else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def can_move(t0, x0, y0, t1, x1, y1):
    assert t1 > t0
    dist = abs(x0 - x1) + abs(y0 - y1)
    dt = t1 - t0
    if dist > dt:
        return False
    if (dist + dt) % 2 == 1:
        return False
    return True

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

flag = True
for i in range(n):
    if not can_move(ts[i], xs[i], ys[i], ts[i + 1], xs[i + 1], ys[i + 1]):
        flag = False

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

Submission status: Accepted

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

for i in range(N):
    t1, x1, y1 = txys[i]
    t2, x2, y2 = txys[i+1]
    dt = t2 - t1
    dist = abs(x1 - x2) + abs(y1 - y2)
    if dt % 2 != dist % 2 or dist > dt:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

for i in range(N):
    t1, x1, y1 = txys[i]
    t2, x2, y2 = txys[i+1]
    dt = t2 - t1
    tIsEven = dt % 2 == 0
    dist = abs(x1 - x2) + abs(y1 - y2)
    xyIsEven = dist % 2 == 0
    if tIsEven != xyIsEven or dist > dt:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    if x + y > t or (x + y + t) % 2 == 1: #記事では不等号逆の誤植あり
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())

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

step = 0
start = (0, 0)
for g in goals:
    s = g[0] - step
    d = abs(g[1] - start[0]) + abs(g[2] - start[1])

    if s < d or s % 2 != d % 2:
        print('No')
        break

    step = g[0]
    start = (g[1], g[2])
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = [0]
X = [0]
Y = [0]
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    diff = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
    if T[i + 1] - T[i] < diff:
        print("No")
        exit()

    if (diff - (T[i + 1] - T[i])) % 2 != 0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
def can_move(coord1, coord2):
    distance = abs(coord2[1] - coord1[1]) + abs(coord2[2] - coord1[2])
    time = coord2[0] - coord1[0]
    if distance > time:
        return False
    quotient, remainder = divmod(distance - time, 2)
    if remainder == 1:
        return False
    return True

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

flag = True
for i in range(N):
    flag = flag and can_move(coord[i], coord[i+1])

if flag:
    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 = map(int, input().split())
    t.append(a)
    x.append(b)
    y.append(c)
i = 0
flag = True
while i < N:
    time = t[i+1]-t[i]
    dis = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if time<dis:
        flag = False
        break
    elif (time%2 + dis%2) == 1:
            flag = False
            break
    i += 1

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

Submission status: Accepted

Solution code:
n = int(input())
x = [[int(i) for i in input().split()] for i in range(n)]
y = [x[0]]
for j in range(1,n):
	y.append([x[j][0]-x[j-1][0],abs(x[j][1]-x[j-1][1]),abs(x[j][2]-x[j-1][2])])
if all(k[0]>=k[1]+k[2] and k[0]%2==(k[1]+k[2])%2 for k in y): print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
n = int(input(""))
data = [0]*n
t = [0]*n
x = [0]*n
y = [0]*n
flag = 0

for i in range(n):
    data[i] = input("")
    t[i] = int(data[i].split(" ")[0])
    x[i] = int(data[i].split(" ")[1])
    y[i] = int(data[i].split(" ")[2])

for i in range(n):
    if i == 0:
        if x[i]+y[i] > t[i] or (x[i]+y[i]-t[i])%2 != 0:
            print("No")
            flag = 1
            break
    else:
        if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i] or (x[i]+y[i]-t[i])%2 != 0:
            print("No")
            flag = 1
            break
if flag == 0:print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
place=[0,0]
bf_t=0
flag=0
for _ in range(n):
    t,x,y=map(int, input().split(" "))
    if (abs(place[0]-x) + abs(place[1] - y)) > (t-bf_t):
        #print("aaa")
        flag=1
        break
    elif (t-bf_t)%2 != ((place[0]+place[1]) - (x + y))%2:
        #print("bbb")
        flag=1
        break
    place[0]=x
    place[1]=y
    bf_t=t

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

Submission status: Accepted

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

num=0
for i in range(N):
    t=a[i][0]
    x=a[i][1]
    y=a[i][2]
    if  x+y<=t and (x+y)%2==t%2:
        num+=0
    else:
        num+=1


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

Submission status: Accepted

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

for i in range(n):
 tn, xn, yn = list(map(int, input().split()))
 if tn%2 != (xn+yn)%2: break
 if abs(x-xn)+abs(y-yn)>tn-t: break
 t, x, y = tn, xn, yn
 if i==n-1: ans="Yes"

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arr = [ [0, 0, 0] ] + arr
ans = "No"

for i in range(n):
 if arr[i][0]%2 != (arr[i][1]+arr[i][2])%2: break
 if abs(arr[i][1]-arr[i+1][1])+abs(arr[i][2]-arr[i+1][2])>arr[i+1][0]-arr[i][0]: break
 if i==n-1: ans="Yes"

print(ans)

Submission status: Accepted

Solution code:
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
t = [na() for _ in range(n)]
zahyo = [0,0]
pre = 0
flag = 1
for i in range(n):
    time = t[i][0] - pre
    dis = (t[i][1]+t[i][2]) - sum(zahyo)
    dis = abs(dis)
    if time >= dis and time%2 == dis%2:
        zahyo = [t[i][1], t[i][2]]
        pre = t[i][0]
    else:
        flag = 0
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())

t=x=y=0
judge=True
for i in range(N):
    in_t,in_x,in_y=map(int,input().split())
    dt=in_t-t
    dxy=abs(in_x-x)+abs(in_y-y)
    if dxy>dt or (dxy-dt)%2!=0: judge=False
    t=in_t
    x=in_x
    y=in_y

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

Submission status: Accepted

Solution code:
import sys
batch = 0
lines = 0
ans = []
for line in sys.stdin:
    if line == None or line == '\n':
        break
        
    cur = line.split(" ")
    if len(cur) == 1:
        lines = int(cur[0])
        batch = 0
        continue
    
    else:
        batch += 1
        if int(cur[0]) < int(cur[1]) + int(cur[2]):
            ans.append(0)
        elif (int(cur[0]) - int(cur[1]) - int(cur[2])) % 2 == 0:
            ans.append(1)
        else:
            ans.append(0)
        
        if batch == lines:
            prod = 1
            for n in ans:
                prod *= n
            if prod == 0:
                print("No")
            else:
                print("Yes")

Submission status: Accepted

Solution code:
# Q.C
N = int(input())
txy = [[0,0,0]]
for i in range(N):
    txy.append(list(map(int,input().split(" "))))


def matchdist(x,y):
    dt = abs(x[0]-y[0])
    ds = abs(x[1]-y[1]) + abs(x[2]-y[2])
    if ds%2 == dt%2 and ds<=dt:
        return True
    else:
        return False
flag = False
for i in range(N):
    if matchdist(txy[i],txy[i+1]):
        continue
    else:
        print("No")
        flag = True
        break
if not flag:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(raw_input())

x = 0
y = 0
t = 0
do = True
for i in range(0, n):
 z = raw_input().split(" ")
 nt = int(z[0])
 nx = int(z[1])
 ny = int(z[2])
 dt = nt - t
 dx = nx - x
 dy = ny - y
 t = nt
 x = nx
 y = ny
 
 if (abs(dx)+abs(dy))%2 != (dt)%2:
  do = False
  break
 if abs(dx)+abs(dy) > abs(dt):
  do = False
  break
if do:
 print "Yes"
else:
 print "No"

Submission status: Accepted

Solution code:
N = int(input())

ts = [0]
xs = [0]
ys = [0]

for _ in range(N):
    t,x,y = [ int(a) for a in input().split() ]
    ts.append(t)
    xs.append(x)
    ys.append(y)

good = True
for i in range(N):

    dist = abs(xs[i]-xs[i+1])+abs(ys[i]-ys[i+1]) 
    time = ts[i+1]-ts[i]
    # Parity
    if dist%2 != time%2:
        good = False

    # Distance
    if dist > time:
        good = False

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

Submission status: Accepted

Solution code:
N=int(input())
t=[None]*(N+1)
x=[None]*(N+1)
y=[None]*(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())

flag=True
for i in range(N):
    if abs(x[i+1]-x[i])+abs(y[i+1]-y[i])>t[i+1]-t[i]:
        flag=False
        break
    if (x[i+1]-x[i]+y[i+1]-y[i])%2!=(t[i+1]-t[i])%2:
        flag=False
        break
        
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
t = x = y = 0
judge = True
for i in range(N):
    nt, nx, ny = map(int, input().split())
    dt = nt - t
    dxy = abs(nx - x) + abs(ny - y)
    if dxy > dt or (dxy - dt) % 2 == 1: judge = False
    t = nt
    x = nx
    y = ny
print("Yes" if judge else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t,x,y = (0,0,0)
Flag = True
for i in range(n):
    nt,nx,ny = list(map(int,input().split()))
    dist = abs(nx-x) + abs(ny-y)
    if dist > nt-t or (nt+nx+ny)%2 != 0:
        Flag = False
if Flag == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

t = [0] + [col[0] for col in grid]
xs = [0] + [col[1] for col in grid]
ys = [0] + [col[2] for col in grid]

res = 'Yes'
for i in range(N):
    interval = t[i+1] - t[i]
    x_dist = xs[i+1] - xs[i]
    y_dist = ys[i+1] - ys[i]
    dist = x_dist + y_dist
    if dist == 0 and interval % 2 == 1:
        res = 'No'
        break
    if dist > interval or dist % 2 != interval % 2:
        res = 'No'
        break

print(res)

Submission status: Accepted

Solution code:
import sys
n=int(input())
L=[list(map(int,input().split())) for i in range(n)]
L.insert(0,[0,0,0])
for i in range(n):
    a,b=L[i+1][0]-L[i][0],abs(L[i+1][1]-L[i][1])+abs(L[i+1][2]-L[i][2])
    if (a-b)%2==0 and a>=b:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    if i == 0:
        if txy[i][0] < abs(txy[i][1]) + abs(txy[i][2]) or txy[i][0]%2 != (txy[i][1] + txy[i][2])%2:
            print("No")
            exit()
    else:
        if txy[i][0] - txy[i-1][0] < abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2]) \
        or txy[i][0]%2 != (txy[i][1] + txy[i][2])%2:
            print("No")
            exit()

print("Yes")

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    t, x, y = 0, 0, 0
    for i in range(N):
        t_i, x_i, y_i = list(map(int, input().split()))
        delta_t = t_i - t
        distance = x_i - x + y_i - y
        if not (delta_t >= distance and (delta_t - distance) % 2 == 0):
            print("No")
            return
        else:
            t, x, y = t_i, x_i, y_i
    print("Yes")
            


solve()

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem C


class TravelingPlan(object):

    def __init__(self):
        from collections import OrderedDict
        self._points = OrderedDict()

    def add_point(self, name: str):
        if name not in self._points:
            self._points[name] = Point()
        return self._points[name]

    def is_executable(self):
        for j in range(len(self._points) - 1):
            current_point = self._points[str(j + 1)]
            previous_point = self._points[str(j)]
            result = self._can_move(previous_point, current_point)

            if result is False:
                return False
        return True

    def _can_move(self, previous_point, current_point):
        delta_x = current_point.x - previous_point.x
        delta_y = current_point.y - previous_point.y
        delta_x_y = delta_x + delta_y
        delta_t = current_point.t - previous_point.t

        if delta_x_y == delta_t:
            return True
        elif delta_x_y < delta_t:
            return self._is_reachable(delta_x_y, delta_t)
        elif delta_x_y > delta_t:
            return False

    def _is_reachable(self, delta_x_y, delta_t):
        for i in range(delta_t + 1):
            if (1 * i + (-1) * (delta_t - i)) == delta_x_y:
                return True
        return False


class Point(object):

    def __init__(self):
        self._x = 0
        self._y = 0
        self._t = 0

    @property
    def x(self):
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

    @property
    def y(self):
        return self._y

    @y.setter
    def y(self, value):
        self._y = value

    @property
    def t(self):
        return self._t

    @t.setter
    def t(self, value):
        self._t = value


if __name__ == '__main__':
    point_count = int(input())
    points = [list(map(int, input().split(" "))) for _ in range(point_count)]
    plan = TravelingPlan()
    origin = plan.add_point(str(0))

    for i in range(0, len(points)):
        point = plan.add_point(str(i + 1))
        point.t = points[i][0]
        point.x = points[i][1]
        point.y = points[i][2]

    if plan.is_executable() is True:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
n = int(input())
li = [list(map(lambda x:int(x),input().split())) for i in range(n)]
ok = True
for i in range(n-1):
    mo = (li[i+1][2] - li[i][2]) + (li[i+1][1] - li[i][1])
    ti = li[i+1][0] - li[i][0]
    if (mo%2)!=(ti%2) or mo>ti or (mo != 0 and ti == 0):
        ok = False
mo = (li[0][2] - 0) + (li[0][1] - 0)
ti = li[0][0] -0
if (mo%2)!=(ti%2) or mo>ti or (mo != 0 and ti == 0):
    ok = False
if ok :
    print("Yes")
else :
    print("No")

Submission status: Accepted

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

ts = 0
xs = 0
ys = 0

for i in range(N):
    t, x, y = [int(c) for c in input().split()]
    min_len = x-xs + y-ys
    dt = t-ts
    if min_len > dt or (dt - min_len) % 2 == 1:
        print('No')
        sys.exit()
    ts = t
    xs = x
    ys = y

print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
x, y, t = (0, 0, 0)
f = True
for i in range(N) :
    nt, nx, ny = list(map(int, input().split()))
    dist = abs(nx - x) + abs(ny - y)
    if dist > nt - t or (nx+ny+nt-t)%2 != (x+y)%2 :
        f = False
print("Yes" if f else "No")

Submission status: Accepted

Solution code:
N = int(input())

nt, nx, ny = 0, 0, 0
canTravel = True
for i in range(N):
	t, x, y = map(int, input().split())
	d = (x - nx) + (y - ny)
	dt = t - nt
	if(d <= dt and d % 2 == dt % 2):
		continue
	else:
		canTravel = False
		break

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

Submission status: Accepted

Solution code:
a = int(input())
x = 0
y = 0
time = 0
for i in range(a):
    aa,b,c = map(int,input().split())
    if (abs(b-x) + abs(c-y)) %2 == (aa - time)%2 and abs(b-x) + abs(c-y) <= aa - time:
        x = b
        y = c
        time = aa
    else:
        print("No")
        break
    if i == a-1:
        print("Yes")

Submission status: Accepted

Solution code:
import sys
n=int(input())
x,y=0,0
for i in range(n):
  t,nx,ny=map(int,input().split())
  dist=abs(nx-x)+abs(ny-y)
  if(dist>t):
    print("No")
    sys.exit()
  elif((t-dist)%2!=0):
    print("No")
    sys.exit()
print("Yes")

Submission status: Accepted

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

p= a[0][0] - a[0][1] - a[0][2] 

if p % 2 != 0 or p < 0:
    print('No')
    exit()

for i in range(1,N):
    route = abs(a[i][1]-a[i-1][1])+abs(a[i][2]-a[i-1][2])
    time = a[i][0] - a[i-1][0]
    b = time - route
    if  b % 2 != 0 or b < 0:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
n = int(raw_input())
travel = [map(int, raw_input().split()) for i in range(n)]

loc = (0,0)
now = 0
res = 'Yes'

for dest in travel:
  t, x, y = dest
  minpath = abs(x-loc[0]) + abs(y-loc[1])
  tmp = (t-now)-minpath
  if (tmp%2==0 and tmp>=0 ):
    loc = (x,y)
    now = t
    continue
  else:
    res = 'No'
    break
print res

Submission status: Accepted

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

for i in range(N):
    tsub=L[i+1][0]-L[i][0]
    dist=L[i+1][1]-L[i][1]+L[i+1][2]-L[i][2]

    if tsub%2==0:
        if dist%2!=0 or tsub<dist:
            print("No")
            exit()
    else:
        if dist%2==0 or tsub<dist:
            print("No")
            exit()
print("Yes")