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

[test case] more tall trees for jump on tree #1258

Closed
lrvideckis opened this issue Oct 16, 2024 · 5 comments
Closed

[test case] more tall trees for jump on tree #1258

lrvideckis opened this issue Oct 16, 2024 · 5 comments
Labels
testcase About testcase

Comments

@lrvideckis
Copy link

lrvideckis commented Oct 16, 2024

https://github.com/yosupo06/library-checker-problems/blob/master/tree/jump_on_tree/gen/max_random.cpp#L208

doing this results in trees with logn expected height, correct? so the only tests are either line/linked list, and trees with logn height

What if we added a test case which isn't line but has linear height? I̶ d̶o̶n̶'t̶ h̶a̶v̶e̶ a̶ s̶p̶e̶c̶i̶f̶i̶c̶ b̶u̶g̶ i̶n̶ m̶i̶n̶d̶

idea 1: for(int i=1;i<n;i++) par[i] = gen.uniform(max(0,i-k), i - 1); where k is in [1,10] maybe (k=1 gives linked list, and the lower the k-value, the higher the expected tree height)

idea 2: generate line of size n/2, then add n/2-1 more random edges

@lrvideckis
Copy link
Author

well actually here's potentially a bug: if you do a vertical path decomposition by deepest leaf, then as you walk up the paths, there will be O(sqrt(n)) of them. but not if the tree has logn height. (and line case, there is a single vertical path)

@NachiaVivias NachiaVivias added the testcase About testcase label Oct 16, 2024
@lrvideckis
Copy link
Author

here's a O(nq) solution which AC's but shouldn't

https://judge.yosupo.jp/submission/243149

basically it's HLD, but you choose an arbitrary child instead of child-with-largest-subtree to extend each vertical path. So there are O(n) vertical paths as you walk up towards the root.

but tests have logn expected height, so it passes in this case. And it passes line case because it's a single vertical path

@lrvideckis
Copy link
Author

you should add this test to LCA as well

https://judge.yosupo.jp/submission/243154

@lrvideckis
Copy link
Author

the case that results in O(n) vertical paths when traversing upwards looks like:

graph(1)

@maspypy
Copy link
Collaborator

maspypy commented Oct 23, 2024

Thank you.
I have added test cases for the LCA, and I was able to confirm that your submission results in TLE.

#1257
https://judge.yosupo.jp/submission/243154

I will now make similar additions for jump on tree.

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

No branches or pull requests

3 participants