QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#11853. Straight Lines 2

统计

By the distance from a given straight line to a polygon we mean the smallest distance of any point of the polygon from this straight line (by the polygon we understand both its edges and its interior). The polygon does not need to be convex, it can also have multiple vertices and self-crossings of its boundary.

Write a program which:

  • reads from the standard input the description of the polygon and description of some number of straight lines,
  • for each straight line calculates the distance from that line to the polygon,
  • writes result to the standard output.

Input Format

In the first line of the standard input there are two integers $ n $ and $ m $ (3 ≤ $ n $ ≤ 50 000, 1 ≤ $ m $ ≤ 50 000), separated by a single space and representing the number of sides of the polygon and the number of straight lines to be analyzed. Each of the following $ n $ lines contains two integers $ x_{i} $ and $ y_{i} $ ($-10^{9} ≤ x_{i}, y_{i} ≤ 10^{9}$), separated by a single space and representing coordinates of the $ i $'th vertex of the polygon. Pairs of consecutive vertices, as well as the first and the last vertex, define sides of the polygon. Each of the following $ m $ lines contains three integers $ A_{i} $, $ B_{i} $ and $ C_{i} $ ($-10^{9} ≤ A_{i}, B_{i}, C_{i} ≤ 10^{9}$, $ A_{i}^{2} + B_{i}^{2} > 0$), separated by single spaces and representing a straight line defined by equation $ A_{i}x + B_{i}y + C_{i} = 0$.

Output Format

Your program should print $ m $ lines to the standard output. $ i $'th line should contain the square of the distance between $ i $-th straight line and the polygon, written as an irreducible fraction, where numerator is separated from denominator by the / sign.

Example

Input

8 2
2 1
6 1
6 2
3 2
3 5
5 5
5 7
2 7
1 1 -2
1 0 -6

Output

1/2
0/1
problem_11853_1.jpg
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.