Problem p02726 (python)

Fixed submission:
import collections
n,x,y=map(int,input().split())
lst=[]
num=[0]*(n+1)
for i in range(1,n):
  for j in range(i+1,n+1):
    k=min(abs(i-j),abs(i-x)+1+abs(j-y),abs(i-y)+1+abs(j-x))
    if num[k]==0:
      num[k]+=1
    lst.append(k)
    
Lst=list(collections.Counter(lst).items())
key=0
for i in range(1,n):
  if num[i]==0:
    print(0)
  else:
    print(Lst[key][1])
    key+=1

Buggy submission (verdict: Runtime Error):
import collections
n,x,y=map(int,input().split())
import heapq
class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        if self.goal_point is not None:
            return self.get_path(self.goal_point, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))

route_map = [dict() for _ in range(n)]
route_map[x-1][y-1]=1
route_map[y-1][x-1]=1
for i in range(n-1):
    route_map[i][i+1] = 1
    route_map[i+1][i]=1    
lst=[]
for i in range(n):
    lst+=Dijkstra(route_map,i).execute()//2        
Lst=list(collections.Counter(lst).items())
Key=list(collections.Counter(lst).keys())
m=max(Key)
for i in range(1,m+1):
    print(Lst[i][1])
for i in range(m+1,n):
    print(0)

Buggy submission (verdict: Runtime Error):
import collections
n,x,y=map(int,input().split())
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        if self.goal_point is not None:
            return self.get_path(self.goal_point, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))

route_map = [dict() for _ in range(n)]
route_map[x-1][y-1]=1
route_map[y-1][x-1]=1
for i in range(n-1):
    route_map[i][i+1] = 1
    route_map[i+1][i]=1    
lst=[]
for i in range(n):
    lst+=Dijkstra(route_map,i).execute()        
Lst=list(collections.Counter(lst).items())
Key=list(collections.Counter(lst).keys())
m=max(Key)
for i in range(1,m+1):
    print(Lst[i][1]//2)
for i in range(m+1,n):
    print(0)