32132023-02-22 17:06:1212BotiMúzeumi őrökpython3Wrong answer 27/40684ms31220 KiB
import heapq
from bisect import bisect

n, e, u = map(int, input().split())
os = [list(map(int, input().split())) + [idx] for idx in range(n)]
os.sort()
done = [False] * n
parent = [-1] * n

heap = [(cost, end, idx) for idx, (start, end, cost, _) in enumerate(os) if start == e]
heapq.heapify(heap)

while len(heap) > 0:
    # print(heap)
    # print(parent)
    cost, end, idx = heapq.heappop(heap)
    if done[idx]:
        continue
    done[idx] = True
    if end >= u:
        print(cost)
        l = []
        while idx != -1:
            l.append(os[idx][3] + 1)
            # print(os[idx])
            idx = parent[idx]
        l.reverse()
        print(len(l), *l)
        exit()
    for i in range(idx + 1, n):
        if os[i][0] > end + 1:
            break
        if done[i] or parent[i] != -1:
            continue
        parent[i] = idx
        heapq.heappush(heap, (cost + os[i][2], os[i][1], i))
SubtaskSumTestVerdictTimeMemory
base27/40
1Accepted0/019ms11716 KiB
2Accepted0/0148ms17432 KiB
3Wrong answer0/118ms11956 KiB
4Accepted3/318ms12252 KiB
5Accepted2/217ms12472 KiB
6Accepted2/219ms12812 KiB
7Accepted2/218ms13044 KiB
8Accepted2/218ms13244 KiB
9Accepted2/218ms13468 KiB
10Time limit exceeded0/2676ms30376 KiB
11Time limit exceeded0/2679ms30548 KiB
12Accepted2/220ms13784 KiB
13Accepted2/279ms15680 KiB
14Partially correct1/3104ms18344 KiB
15Accepted3/3126ms19692 KiB
16Time limit exceeded0/2661ms30900 KiB
17Time limit exceeded0/2684ms31220 KiB
18Partially correct1/218ms14144 KiB
19Partially correct1/218ms14312 KiB
20Accepted2/217ms14644 KiB
21Accepted2/217ms14360 KiB