Last active
March 21, 2018 15:07
-
-
Save hamuhei1412/dbe6117716a3d61dfe493cb94cba8e55 to your computer and use it in GitHub Desktop.
ABC086C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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