I am now a more experienced programmer and know more algorithms to help me, so, on this problem I thought that Jarvin's March and Point in Poly are the one's of choice, togheter with point in seg.
So, my approach was:
- Code: Select all
1. read in cops and robbers positions.
2. find the convex hull for the cops and/or robs if more then 2 cops/robbers
3. now, for each citizen:
4. if more then 2 cops:
5. if the citizen is in the same place of a cop or
the citizen is between two cops (on a line) or
the citizen is inside the convex hull
6. the citizen is said to be safe
7. else do the tests of 4 and 5 for the robs
9. if not safe and not robbed
10. the citizen is said to be neither
And this gives me WA
Can anyone help, or should I surrender?