Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[leet][743] The reason of network-delay-time FAIL #1

Closed
ChoiWheatley opened this issue May 25, 2023 · 3 comments
Closed

[leet][743] The reason of network-delay-time FAIL #1

ChoiWheatley opened this issue May 25, 2023 · 3 comments
Assignees

Comments

@ChoiWheatley
Copy link
Contributor

heapq 모듈의 정렬 규칙을 지정하지 않았던 것이 오답의 원인이다. 파이썬알고인터뷰 책에서의 설명은 Q의 타입을 dict[tuple[Weight, Vertex]]로 주었는데, WeightVertex를 거꾸로 준 이유가 바로 tuple 비교는 첫번째 원소부터 진행하기 때문이라는 것이다!

따라서, 일관적으로 코드를 작성하면서(Qdist의 타입 순서) 동시에 Weight를 비교하도록 설정하고 싶다면 별도의 래퍼클래스를 지정해야 한다.

@ChoiWheatley ChoiWheatley self-assigned this May 25, 2023
@ChoiWheatley
Copy link
Contributor Author

commit 34ec1a4

@ChoiWheatley
Copy link
Contributor Author

@dataclass(order=True)
class PrioritizedItem:
    key: int
    item: Any = field(compare=False)

@ChoiWheatley
Copy link
Contributor Author

ChoiWheatley commented May 25, 2023

문제는 풀었지만... 속도가 느리다. 파이썬 자체의 문제인 듯 하다. 259282c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant