Skip to content

Instantly share code, notes, and snippets.

@hamuhei1412
Last active March 21, 2018 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamuhei1412/dbe6117716a3d61dfe493cb94cba8e55 to your computer and use it in GitHub Desktop.
Save hamuhei1412/dbe6117716a3d61dfe493cb94cba8e55 to your computer and use it in GitHub Desktop.
ABC086C
N = gets.to_i
x = []
y = []
t = []
N.times do
line = gets.split.map(&:to_i)
t << line[0]
x << line[1]
y << line[2]
end
#ここまで入力
s = 0
while s < N
if s == 0 #はじめの目的地かどうかで場合分け
if x[s]+y[s] > t[s] #移動距離が足りなければNo
puts "No"
exit
end
if (x[s]+y[s])%2 != t[s]%2 #移動距離と時間の偶奇が違うならNo
puts "No"
exit
end
else
if((x[s]-x[s-1]).abs+(y[s]-y[s-1]).abs) > t[s]-t[s-1] #移動距離が足りないならNo
puts "No"
exit
end
if(((x[s]-x[s-1]).abs+(y[s]-y[s-1]).abs)%2 != (t[s]-t[s-1])%2) #移動距離と時間の遇奇が違うならNo
puts "No"
exit
end
end
s+=1
end
puts "Yes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment