Problem p03457 (python)

Fixed submission:
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# at_coder.ABC086C_Traveling
# Date: 2019/06/02
# Filename: ABC086C_Traveling 

__author__ = 'acto_mini'
__date__ = "2019/06/02"


def main():
    # 作業ディレクトリを自身のファイルのディレクトリに変更
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

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

    # 整数の入力
    num = int(input())

    for i in range(num):
        a, b, c = map(int, input().split())
        t.append(a)
        x.append(b)
        y.append(c)

    can = True
    for i in range(num):
        dt = t[i + 1] - t[i]
        dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
        if (dt < dist):
            can = False
        if (dt % 2 != dist % 2):
            can = False

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

    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# at_coder.ABC086C_Traveling
# Date: 2019/06/02
# Filename: ABC086C_Traveling 

__author__ = 'acto_mini'
__date__ = "2019/06/02"


dict = [
    [1, 1, 0],
    [1, 0, 1],
    [1, -1, 0],
    [1, 0, -1]
]

def route (dis, current, goal):

    if dis < 0:
        return False

    new_current = [0, 0, 0]

    for d in dict:
        new_current[0] = current[0] + d[0]
        new_current[1] = current[1] + d[1]
        new_current[2] = current[2] + d[2]

        if goal[0] == new_current[0] and goal[1] == new_current[1] and goal[2] == new_current[2]:
            return True

        if route(dis-1, new_current, goal):
            return True

    return False

def main():
    # 作業ディレクトリを自身のファイルのディレクトリに変更
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

    current = [0, 0, 0]

    # 整数の入力
    num = int(input())
    goal_list = []

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

    fail = False
    for i in range(num):

        t, x, y = goal_list[i][0], goal_list[i][1], goal_list[i][2]

        if route(dis=t, current=current, goal=[t, x, y]):
            current = [t, x, y]
            continue

        fail = True
        break

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

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# at_coder.ABC086C_Traveling
# Date: 2019/06/02
# Filename: ABC086C_Traveling 

__author__ = 'acto_mini'
__date__ = "2019/06/02"


dict = [
    [1, 1, 0],
    [1, 0, 1],
    [1, -1, 0],
    [1, 0, -1]
]

def route (dis, current, goal):

    if dis < 0:
        return False

    new_current = [0, 0, 0]

    for d in dict:
        new_current[0] = current[0] + d[0]
        new_current[1] = current[1] + d[1]
        new_current[2] = current[2] + d[2]

        if goal[0] == new_current[0] and goal[1] == new_current[1] and goal[2] == new_current[2]:
            return True

        if route(dis-1, new_current, goal):
            return True

    return False

def main():
    # 作業ディレクトリを自身のファイルのディレクトリに変更
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

    current = [0, 0, 0]

    # 整数の入力
    num = int(input())
    goal_list = []

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

    fail = False
    for i in range(num):

        t, x, y = goal_list[i][0], goal_list[i][1], goal_list[i][2]

        if route(dis=t, current=current, goal=[t, x, y]):
            current = [t, x, y]
            continue

        fail = True
        break

    if fail:
        print("NO")
    else:
        print("YES")

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#! env python
# -*- coding: utf-8 -*-

import os
import sys

# at_coder.ABC086C_Traveling
# Date: 2019/06/02
# Filename: ABC086C_Traveling 

__author__ = 'acto_mini'
__date__ = "2019/06/02"


dict = [
    [1, 1, 0],
    [1, 0, 1],
    [1, -1, 0],
    [1, 0, -1]
]

def route (dis, current, goal):

    if dis < 0:
        return False

    new_current = [0, 0, 0]

    for d in dict:
        new_current[0] = current[0] + d[0]
        new_current[1] = current[1] + d[1]
        new_current[2] = current[2] + d[2]

        if goal[0] == new_current[0] and goal[1] == new_current[1] and goal[2] == new_current[2]:
            return True

        if route(dis-1, new_current, goal):
            return True

    return False

def main():
    # 作業ディレクトリを自身のファイルのディレクトリに変更
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

    current = [0, 0, 0]

    # 整数の入力
    num = int(input())
    goal_list = []
    for i in range(num):
        t, x, y = map(int, input().split())
        goal_list.append([t, x, y])

    fail = False
    for i in range(num):

        t, x, y = goal_list[i][0], goal_list[i][1], goal_list[i][2]

        if route(dis=t, current=current, goal=[t, x, y]):
            continue

        fail = True
        break

    if fail:
        print("NO")
    else:
        print("YES")

    return

if __name__ == '__main__':
    main()