PivotOJ

Antialiasing

시간 제한: 4000ms메모리 제한: 1024MB출처: ICPC Rocky Mountain Regional 2021BOJ 24752

문제

To reduce aliasing effects, computer graphics systems render a polygon by setting the brightness of each pixel proportional to the area of the pixel inside the polygon.  If a pixel is completely inside the polygon, that pixel is set to the brightest intensity.  If only half of the pixel is inside the polygon, then the pixel is set halfway between darkest and brightest.

Given a convex polygon and a pixel location, determine the fraction of the pixel's area that is inside the polygon.  Each pixel is square, and is indexed by its row and column coordinates rr and cc.  If a vertex of the polygon is located at (r,c)(r,c), then the vertex is located at the center of the pixel at row rr and column cc. Rows are numbered from 00 starting from the top row, and columns are numbered from 00 starting from the leftmost column.

입력

The first line of input specifies two integers NN (3N1003 \leq N \leq 100), which is the number of vertices in the convex polygon, and QQ (1Q10001 \leq Q \leq 1\,000), which is the number of queries.  The next NN lines each contains two integers rr and cc giving the coordinates of the polygon in counterclockwise order.  The next QQ lines each contains two integers rr and cc indicating the coordinates of the pixel we are interested in.  It is guaranteed that the area of the polygon is positive.  All coordinates satisfy 0r10000 \leq r \leq 1\,000 and 0c10000 \leq c \leq 1\,000.

출력

For each query, display a line indicating the fraction of the pixel's area inside the polygon.  The fraction should be in lowest terms.  

예제

예제 1

입력
4 4
1 1
4 1
4 4
1 4
3 3
10 10
1 3
1 4
출력
1/1
0/1
1/2
1/4

예제 2

입력
3 4
1 1
11 11
1 21
1 1
11 11
21 1
4 4
출력
1/8
1/4
0/1
1/2
코드를 제출하려면 로그인하세요.