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

Problem with Beecrowd 1468-balloon.cpp #27

Open
ChrisVilches opened this issue Aug 6, 2022 · 1 comment
Open

Problem with Beecrowd 1468-balloon.cpp #27

ChrisVilches opened this issue Aug 6, 2022 · 1 comment

Comments

@ChrisVilches
Copy link
Owner

ChrisVilches commented Aug 6, 2022

Beecrowd 1468-balloon.cpp

My solution is broken for this input (but it still gets AC)

4 1
1 9 7 3
3 8 12 6
0 12 2 12
2 15 4 15
5

3 1
1 9 7 3
4 7 12 8
0 12 2 12
5

Correct answer:

1 12
1 12

My AC code returns (this answer is incorrect):

1 12
12

Solution on UDEBUG also returns this incorrect answer.

Updating the code so that it works gets Wrong Answer on Beecrowd.

This can be solved by changing the code that collects events, and use something like this (UPDATE: This code also doesn't work, a proper segment sorting is necessary):

  for (int i = 0; i < N; i++) {
    Point event_point;

    event_point.x = 0;  // Don't care
    event_point.y = min(segments[i].p.y, segments[i].q.y);

    events[ev_n++] = make_pair(event_point, i);
  }

In other words, use the lowest point instead of the exit point. This works for this case, but I don't know if this fix is correct, and there's no data to test against (official data might be broken).

The case with 3 segments looks like this:

image

@ChrisVilches
Copy link
Owner Author

ChrisVilches commented Aug 17, 2022

  • uDebug solution was updated.
  • Collected all the data from uDebug plus my own test cases, and they all work correctly. uDebug also returns the same answer as mine (even for my custom test cases).
  • Data compilation was stored locally on my PC.
  • Ended up using the same segment sorting as kattis/pinball and kattis/directingrainfall.

TODO:

  • Code review the refactored file.
  • Re-submit to Beecrowd and UVA.

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