답안 #1052858

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052858 2024-08-11T04:55:56 Z amongus_pvp Jakarta Skyscrapers (APIO15_skyscraper) Python 3
0 / 100
12 ms 3164 KB
from collections import deque, defaultdict

def min_jumps_to_pass_news(N, M, doges):
    # Create adjacency list for the graph based on doge jumps
    graph = defaultdict(list)
    for b, p in doges:
        if 0 <= b < N:
            if 0 <= b + p < N:
                graph[b].append(b + p)
            if 0 <= b - p < N:
                graph[b].append(b - p)
    
    # BFS to find the shortest path
    queue = deque([0])  # Start BFS from skyscraper 0
    visited = [False] * N
    distance = [float('inf')] * N
    visited[0] = True
    distance[0] = 0
    
    while queue:
        current = queue.popleft()
        current_dist = distance[current]
        
        for neighbor in graph[current]:
            if not visited[neighbor]:
                visited[neighbor] = True
                distance[neighbor] = current_dist + 1
                queue.append(neighbor)
    
    # Check the distance to skyscraper 1
    if distance[1] == float('inf'):
        return -1
    return distance[1]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -