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

Use __lg to make treeJump shorter #260

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IvanRenison
Copy link
Contributor

It breaks the case when P is empty, but thats not an useful case

It breaks the case when P is empty, but thats not an useful case
@simonlindholm
Copy link
Member

I don't care about the case of empty P, because that's not a tree, but I do care about sz(P) == 1. __lg(0) is undefined, right?

@IvanRenison
Copy link
Contributor Author

IvanRenison commented May 12, 2024

Oh, yes, I saw in this stack overflow answer that it's -1, and in my machine gives -1, but according to this codeforces blog you are right.
I fixed it with sz(P) < 2 ? 0 :1 + __lg(sz(P) - 1)

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

Successfully merging this pull request may close these issues.

2 participants