2009年11月20日 星期五

PKU3135 - Polygons on the Grid

Link: http://acm.pku.edu.cn/JudgeOnline/problem?id=3135

An exhaustion problem.
The solution is well known, but this is a good problem for me to practice my exhaustion skills.

We can pre-compute the all possible placement on the grids for specific length sticks. In the worst case, there is 36 possible placement on the grids, which is small and we can do exhaustion on different placements.

Here is some skills for cut-case:
1. Fix the longest stick to be the first one, and try permutations for other sticks.
2. Check whether the sticks left are not long enough to reach back to the origin. Otherwise, cut this case.
3. After putting n-1 sticks, the length to the origin must be equal to the length of the last stick. Otherwise, cut this case.
4. We can fix the direction to put the first stick to be in the first region (x,y are positive)
5. Because for the first stick, it is symmetric for (y,x) and (x,y) cases arrangement, we can only try one of them.

Another thing is that do not use STL pair when doing these problems.

沒有留言:

張貼留言