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:
import sys
def main():
    n = int(input())
    txy = []
    for _ in range(n):
        txy.append(tuple(map(int, input().split())))

    t = x = y = 0
    for i1 in range(n):
        txye = txy[i1]
        t, dt = txye[0], txye[0] - t
        x, dx = txye[1], abs(txye[1] - x)
        y, dy = txye[2], abs(txye[2] - y)
        if dt < (dx + dy):
            print('No')
            sys.exit()
        elif dt > (dx + dy) and (dt - dx - dy) % 2 != 0:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
n=int(input())
px=0
py=0
pt=0
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(x-px)+abs(y-py)>t-pt or (abs(x-px)+abs(y-py))%2!=(t-pt)%2:
        print('No')
        sys.exit()
    else:
        px=x
        py=y
        pt=t
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
T = [0] * N
XY = [0] * N
for i in range(N):
    t,x,y = map(int, input().split())
    T[i] = t
    XY[i] = [x,y]

x,y = 0,0
t = 0
for i in range(N):
    nx,ny = XY[i]
    nt = T[i]
    distance = abs(x-nx) + abs(y-ny)
    if distance <= nt - t and ((nt - t) - distance) %2 == 0:
        x,y = nx,ny
        t = nt
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
T=[0]
X=[0]
Y=[0]

for _ in range(N):
    t, x, y = [int(i) for i in input().split()]
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    z = abs(X[i]-X[i+1])+abs(Y[i]-Y[i+1])
    if z & 1 == (T[i + 1] - T[i]) & 1 and z <= (T[i + 1] - T[i]):
        continue
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
t=[0]*100003
x=[0]*100003
y=[0]*100003

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

for i in range(1,N+1):
    dt=t[i]-t[i-1]
    dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if dist>dt:
        break
    else:
        pass
    if dist%2==dt%2:
        pass
    else:
        break
    count+=1
if count==N:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
time = 0
point = [0,0]
for i in range(n):
    t,x,y = map(int,input().split())
    distance = abs(x-point[0]) + abs(y-point[1])
    dum_time = t-time
    if distance > dum_time:
        print("No")
        exit()
    elif distance%2 != dum_time%2:
        print("No")
        exit()
    time = t
    point[0] = x
    point[1] = y
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0,0])
for i in range(len(A)-1):
    dt = A[i+1][0]-A[i][0]
    dist = abs(A[i+1][1]-A[i][1])+abs(A[i+1][2]-A[i][2])
    if dist>dt:
        print("No")
        quit()
    if dist%2!=dt%2:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
print("Yes" if count == N else "No")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        l=[list(map(int,input().split())) for i in range(n)]
        l.insert(0,[0,0,0])
        for j in range(n):
            t,x,y=l[j+1][0]-l[j][0],l[j+1][1]-l[j][1],l[j+1][2]-l[j][2]
            if t<(abs(x)+abs(y))or t%2!=(abs(x)+abs(y))%2:
                return 'No'
        return 'Yes'
    print(main())
resolve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        l=[list(map(int,input().split())) for i in range(n)]
        l.insert(0,[0,0,0])
        for j in range(n):
            t,x,y=l[j+1][0]-l[j][0],l[j+1][1]-l[j][1],l[j+1][2]-l[j][2]
            if t<(abs(x)+abs(y)):
                return 'No'
            elif t%2!=(abs(x)+abs(y))%2:
                return 'No'
        return 'Yes'
    print(main())
resolve()

Submission status: Accepted

Solution code:
n = int(input())

now = [0,0,0]
for i in range(n):
    s = list(map(int,input().split()))
    time = s[0] - now[0]
    dis = abs(s[1] - now[1]) + abs(s[2] - now[2])
    if time < dis or (time-dis)%2 == 1:
        print("No")
        exit()
    now = s

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
flag = 1
t1 = 0
x1 = 0
y1 = 0
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  dt = t2-t1
  dx = abs(x2-x1)
  dy = abs(y2-y1)
  if dt<(dx+dy) or dt %2 != (dx+dy) % 2:
    flag = 0
    break
  t1 = t2
  x1 = x2
  y1 = y2
print("Yes" if flag else "No")

Submission status: Accepted

Solution code:
n = int(input())

now = [0,0,0]
for i in range(n):
    s = list(map(int,input().split()))
    time = s[0] - now[0]
    dis = abs(s[1] - now[1]) + abs(s[2] - now[2])
    if time < dis or (time-dis)%2 == 1:
        print("No")
        exit()
    now = s

print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]
current_time = 0
current_x = 0
current_y = 0
for point in points:
    t, x, y = point
    diff_time = t - current_time
    diff_x = abs(x - current_x)
    diff_y = abs(y - current_y)
    if diff_x + diff_y > diff_time:
        print("No")
        break
    elif diff_x + diff_y < diff_time:
        remainder = diff_time - (diff_x + diff_y)
        if remainder % 2 == 1:
            print("No")
            break
    current_x = x
    current_y = y
    current_time = t
else:
    print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
t=[0]
x=[0]
y=[0]
for i in range(n):
  t_inp,x_inp,y_inp=(int(x) for x in input().split())
  t.append(t_inp)
  x.append(x_inp)
  y.append(y_inp)
  
flag=True
for i in range(1,n+1):
  dt=t[i]-t[i-1]
  dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if dt<dist:
    flag=False
    break
  if dt%2 != dist%2:
    flag=False
    break
    
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([iarr() for i in range(n)])
# 要素数はn+1
txy = np.concatenate((np.zeros((1,3),int),txy))
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 1
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

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

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([iarr() for i in range(n)])
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 0 if t[0] < abs(x[0]) + abs(y[0]) else 1
for i in range(n-1):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

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

Submission status: Accepted

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

for i in range(n):
  if txy[i+1][0] - txy[i][0] < abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2]):
    print('No')
    exit()
  else:
    if (txy[i+1][0] - txy[i][0])%2 == 0 and (abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2]))%2 != 0:
      print('No')
      exit()
    elif (txy[i+1][0] - txy[i][0])%2 != 0 and (abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2]))%2 == 0:
      print('No')
      exit()
      
print('Yes')

Submission status: Accepted

Solution code:
def solve(n, t_list):

    px = 0
    py = 0
    pt = 0
    ans = "Yes"
    for t, x, y in t_list:
        d = abs(x-px) + abs(y-py)
        dt = t - pt
        if (d %2  == dt % 2) and dt >= d:
            px = x
            py = y
            pt = t
        else:
            ans = "No"
            break

    return ans


if __name__ == "__main__":
    n = int(input())
    t_list = [[int(j) for j in input().split()] for i in range(n)]
    print(solve(n, t_list))

Submission status: Accepted

Solution code:
def solve(n, t_list):

    px = 0
    py = 0
    pt = 0
    ans = "Yes"
    for t, x, y in t_list:
        d = abs(x-px) + abs(y-py)
        dt = t - pt
        if ((d %2 == 0 and dt % 2 == 0) or (d % 2 == 1 and dt %2 == 1) )and dt >= d:
            px = x
            py = y
            pt = t
        else:
            ans = "No"
            break

    return ans


if __name__ == "__main__":
    n = int(input())
    t_list = [[int(j) for j in input().split()] for i in range(n)]
    print(solve(n, t_list))

Submission status: Accepted

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

pre = [0, 0, 0]
can = True
for i in range(N):
    dist = abs(plan[i][1] - pre[1]) + abs(plan[i][2] - pre[2])
    dt = plan[i][0] - pre[0]
    
    if dt < dist:
        can = False
    if dt % 2 != dist % 2:
        can = False
        break
    pre = plan[i]
        
if can:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

N = int(input())
x1,y1,t1 = 0,0,0
for _ in range(N):
    t2,x2,y2 = map(int, input().split())
    X, Y, T = abs(x2 - x1), abs(y2 - y1), t2 - t1
    if X + Y > T or (T - X - Y) % 2 == 1:
        print('No')
        exit()
    x1, y1, t1 = x2, y2, t2
print('Yes')

Submission status: Accepted

Solution code:
# C - Traveling
N = int(input())
T = []
for n in range(N):
    T.append([int(i) for i in input().split()])
now_t = 0
now_x = 0
now_y = 0
cnt=0
for t in T:
    if t[0]%2 !=(t[1]+t[2])%2:
        print('No')
        exit()
        
    if t[0] -now_t  >= abs(t[1]-now_x)+abs(t[2]-now_y):
        now_t = t[0]
        now_x = t[1]
        now_y = t[2]
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
n = int(input())
t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

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

for i in range(n):
    length = abs((x[i+1]-x[i])+(y[i+1]-y[i]))
    move = t[i+1]-t[i]
    if move < length:
        print('No')
        sys.exit()
    if (move - length)%2==1:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
bt, bx, by = 0, 0, 0
flag = True
for i in range(n):
    nt, nx, ny = map(int, input().split())
    dist = abs(nx - bx) + abs(ny - by)
    diff_t = nt - bt
    if diff_t < dist or (diff_t - dist) % 2:
        flag = False
    bt, bx, by = nt, nx, ny
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    D = list(map(int, input().split()))
    dt = D[0] - t
    dx = D[1] - x
    dy = D[2] - y
    l = abs(dx) + abs(dy)
    if dt < l:
        print('No')
        exit()
    if dt % 2 != l % 2:
        print('No')
        exit()
    t, x, y = dt, dx, dy
print('Yes')

Submission status: Accepted

Solution code:
# C - Traveling
# https://atcoder.jp/contests/abc086/tasks/arc089_a

# dt = ti+1 −ti
# dist = abs(xi+1 − xi)+abs(yi+1 − yi)

# キーポイント: パリティ
# x + y は毎秒ごとに必ず偶奇が入れ替わる。

n = int(input())

T = 0
X = 0
Y = 0

cnt = 0

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

    dist = abs(x-X) + abs(y-Y)
    dt = (t-T)

    # dist と dt の偶奇は一致する必要あり
    if dist <= dt and dist%2 == dt%2:
        cnt += 1
    T,X,Y = t,x,y
print("Yes" if cnt == n else "No")

Submission status: Accepted

Solution code:
# C - Traveling
# https://atcoder.jp/contests/abc086/tasks/arc089_a

# dt = ti+1 −ti
# dist = abs(xi+1 − xi)+abs(yi+1 − yi)

# キーポイント: パリティ
# x + y は毎秒ごとに必ず偶奇が入れ替わる。

n = int(input())

T = 0
X = 0
Y = 0

cnt = 0

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

    if abs(x-X) + abs(y-Y) <= (t-T) and (x+y)%2 == t%2:
        cnt += 1
    T,X,Y = t,x,y
print("Yes" if cnt == n else "No")

Submission status: Accepted

Solution code:
N=int(input())
t=[]
x=[]
y=[]
#t.append(0)
#x.append(0)
#y.append(0)
t_cur=0
x_cur=0
y_cur=0

for i in range(N):
  plan=input().split(' ')
  t.append(int(plan[0]))
  x.append(int(plan[1]))
  y.append(int(plan[2]))

for i in range(N):
  t_gap=t[i]-t_cur
  x_gap=abs(x[i]-x_cur)
  y_gap=abs(y[i]-y_cur)

  dist=x_gap+y_gap

#  print("trip=",t[i],x[i],y[i])
#  print("t_gap=",t_gap)
#  print("dist=",dist)
  if (t_gap-dist)>=0 and (t_gap-dist)%2==0:
    t_cur=t[i]
    x_cur=x[i]
    y_cur=y[i]
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
pt, px, py = 0, 0, 0

for i in range (N):
    t, x, y = map(int, input().split())
    dt = abs(t - pt)
    dxy = abs(x-px+y-py)
    if dxy > dt or (dxy - dt)%2:
        print("No")
        exit()
    pt, px, py = t, x, y
print("Yes")

Submission status: Accepted

Solution code:
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=t,x,y
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(1,n+1):
    t[i],x[i],y[i]=map(int,input().split())
time=0
dist=0
for i in range(n):
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    time=t[i+1]-t[i]
    if time>=dist and time%2 == dist%2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
nx = ny = 0
nt = 0
for _ in range(N):
  t,x,y = IL()
  if abs(nx-x)+abs(ny-y) > t-nt:
    NE()
  if (abs(nx-x)+abs(ny-y) )%2 != (t-nt)%2:
    NE()
  nx = x
  ny = y
  nt = t
Y()

Submission status: Accepted

Solution code:
import sys
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
a = 0
def sub(p,q):
    return p-q
for i in range(n):
    a = abs(ls[i][1]) + abs(ls[i][2])
    if ((a -ls[i][0]) % 2 != 0) or (a -ls[i][0] > 0):
        print("No")
        sys.exit()
    if i != n-1:
        ls[i+1] = list(map(sub,ls[i+1],ls[i]))
    else:
        pass
print("Yes")

Submission status: Accepted

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation



'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  # [1, 0, 3]

'''

def factorial(x, mod=10**9+7):
    # x!
    # 階乗
    # ex) factorial(5) = 120
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''


########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    #lenを変数に置くと事故るから注意
    n=int(input())
    #a,b=input().split(" ")#a,bがともに文字列のとき
    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):
        #print(i)
        if (t[i+1]-t[i]) <(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])):
            print("No")
            sys.exit()
        if (t[i+1]-t[i]-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2!=0:
            print("No")
            sys.exit()
    print("Yes")
    #a,b=map(int, input().split(" "))
    #mapでとってもstrで変換すればappend可能
    #nl=list(map(int, input().split(" ")))#数字の時
    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    #brray=[list(map(int, input().split(" ")))for i in range(N)]
    #print(brray)

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')#ある要素のインデックス番号を取得
    #s = ''.join(l)
    #s = " ".join(map(str,a))#スペースを空ける時はこう
    #print(s)
    # aaabbbccc

    #if state in known_states and not flag: # state => 2 steps => 5
        #こうやってある要素がリストの中にあるか探すのか
    #print(f'steps: {steps}, state: {state}')
    #こう書いてあるとデバックしやすい

    #dp= [[0]*3 for i in range(5)]#列　行
    #dp用の0の入ったやつ
    #dp= [[0]*(w+1) for i in range(n+1)]#0からwまでのw+1回計算するから
    #print(dp)＃初期条件が入る分計算回数+1列分必要(この場合は判断すべきものの数)
    DP = np.zeros(w+1, dtype=int)#これでも一次元リストが作れる
    exdp=np.zeros((3,4)) # ３×４の２次元配列を生成。2次元ならこう
    #dtypeは指定しないとfloatになる
    #for i in range(n):#ちょっとした入力に便利
    #    a, b = map(int, input().split())
        #dp[i][0] += [a]
        #これだとintとlistをつなぐことになって不適
    #    dp[i] += [a]
    #    dp[i] += [b]
        #これはうまくいく
        #やり方はいろいろあるということ
    #print(dp)


    #brray=[list(map(int, input().split(" ")))for i in range(N)
    #print(brray)



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]#内包表記に慣れろ
    #print(pin_l)

    ls = ["a", "b", "c", "d", "e"]


    #print(ls[2:5])
    #スライスでの取得

    #print(ls[:-3])
    #一番左端から右から3番目より左まで取得

    #print(ls[:4:2])
    #スライスで1個飛ばしで取得
    #ないときは左端スタート
    #始点のインデックス番号 : 終点のインデックス番号 : スキップする数+1
    #print(ls[::2])
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=t,x,y
print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
ans='Yes'
pt, px, py=0, 0, 0
for i in range(n):
  t, x, y=map(int, input().split())
  if t-pt<abs(x-px)+abs(y-py):
    ans='No'
    break
  elif (abs(x-px)+abs(y-py)-(t-pt))%2==1:
    ans='No'
    break
  pt, px, py=t, x, y
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
t = [0]*100001
x = [0]*100001
y = [0]*100001
for n in range(N):
    t[n+1], x[n+1], y[n+1] = map(int, input().split())
ans = True
for n in range(N):
    dt   = t[n+1] - t[n]
    dist = abs(x[n+1] - x[n]) + abs(y[n+1] - y[n])
    if dt < dist:
        ans = False
    if dt % 2 != dist % 2:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    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):
        t_diff = T[i+1]-T[i]
        x_diff = abs(X[i+1]-X[i])
        y_diff = abs(Y[i+1]-Y[i])
        if abs(x_diff + y_diff - t_diff) % 2 == 1 or x_diff+y_diff-t_diff>0:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
for txy in TXY:
    T = txy[0]
    X = txy[1]
    Y = txy[2]
    if (T-t) - abs(X-x) - abs(Y-y) >= 0 and ((T-t) - abs(X-x) - abs(Y-y)) % 2 == 0:
        t = T
        x = X
        y = Y
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
plan = [[0,0,0]]
plan.extend(list(map(int, input().split())) for i in range(N))
f = True
for i in range(N):
    time = plan[i+1][0]-plan[i][0]
    dist = abs(plan[i+1][1]-plan[i][1])+abs(plan[i+1][2]-plan[i][2])
    if dist>time or (dist%2 != time%2):
        f = False
print('Yes' if f else 'No')