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

Bug in Graham Scan Convex Hull.cpp #3

Open
lxxue opened this issue Jan 17, 2018 · 1 comment
Open

Bug in Graham Scan Convex Hull.cpp #3

lxxue opened this issue Jan 17, 2018 · 1 comment

Comments

@lxxue
Copy link

lxxue commented Jan 17, 2018

I guess there is a bug in the implementation of Graham's Scan algorithm.

Try the following testcase:
Input: { 0, 0 }, { 1, 1 }, { 2, 2 }, { 1, 4 }
output: { 1, 4 }, { 2, 2 }, { 1, 1 }, { 0, 0 }
correct output: { 1, 4 }, { 2, 2 }, { 0, 0 }

I believe the problem is in line 70: points[1] is not necessarily a vertex of convex hull if points[1] and points[2] have the same direction.

Btw: thank you for your wonderful blogs and readable code!

@avighnac
Copy link

Yeah, the convex hull code doesn't even pass on CSES, like bruh.

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

2 participants