22317_PieDivision

2022-5-16 18:21| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506316608000-Problem List-采集的数据-后羿采集器.html

Pro.ID

22317

Title

Pie Division

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22317

AC

0

Submit

1

Ratio

0.00%

时间&空间限制

  • Time Limit: 20000/10000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Frans is celebrating his birthday. At an exclusive baker's shop, he has bought two delicious pies, of different types. He cuts each pie into a number of pieces. At coffee time, he invites his colleagues for a piece of pie, but after the celebration, some pieces are left over. In fact, 2N pieces are left over: N pieces of each pie, and N happens to be even. Frans does not want to take all remaining pieces back home, so he decides to share them with a colleague who is fond of pie too.

    Now Frans wonders how to split the 2N remaining pieces, which seem to be randomly distributed over the table, in two. A simple way to achieve this would be to stretch a cord over the table, in a straight line. The pieces at one side of the cord are for Frans, the pieces at the other side are for the colleague. There is, however, a constraint. Both Frans and his colleague should take home (1/2)N pieces of the first pie, and (1/2)N pieces of the second pie. Is this possible with the cord trick? And if so, how many ways are there to do this? Of course, this depends on the positions of the 2N pieces on the table.

    For example, let N = 2, and let the pieces of one pie be depicted by closed circles, and the pieces of the other pie by open circles. In the configuration of Figure 1(a), there are two possible divisions, as indicated in Figure 1(b) and Figure 1(c).

    Figure 1: Two valid divisions of four pieces.

    On the other hand, in the configuration of Figure 2(a), there is only one valid division, as indicated in Figure 2(b).

    Figure 2: One valid division of four pieces.

    To simplify things, we assume that no three pieces of pie are on the same line. This implies in particular that no two pieces of pie occupy the same position. Moreover, we assume that each piece is infinitely small.

    输入

    The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:

    • One line with an even integer N, satisfying 2 ≤ N ≤ 1, 000.

    • N lines, each with two integers x and y, satisfying −10, 000 ≤ x, y ≤ 10, 000: the x- and y-coordinates of a piece of the first pie.

    • N lines, each with two integers x and y, satisfying −10, 000 ≤ x, y ≤ 10, 000: the x- and y-coordinates of a piece of the second pie.

    Integers on the same line are separated by a single space.

    输出

    Description

    Frans is celebrating his birthday. At an exclusive baker's shop, he has bought two delicious pies, of different types. He cuts each pie into a number of pieces. At coffee time, he invites his colleagues for a piece of pie, but after the celebration, some pieces are left over. In fact, 2N pieces are left over: N pieces of each pie, and N happens to be even. Frans does not want to take all remaining pieces back home, so he decides to share them with a colleague who is fond of pie too.

    Now Frans wonders how to split the 2N remaining pieces, which seem to be randomly distributed over the table, in two. A simple way to achieve this would be to stretch a cord over the table, in a straight line. The pieces at one side of the cord are for Frans, the pieces at the other side are for the colleague. There is, however, a constraint. Both Frans and his colleague should take home (1/2)N pieces of the first pie, and (1/2)N pieces of the second pie. Is this possible with the cord trick? And if so, how many ways are there to do this? Of course, this depends on the positions of the 2N pieces on the table.

    For example, let N = 2, and let the pieces of one pie be depicted by closed circles, and the pieces of the other pie by open circles. In the configuration of Figure 1(a), there are two possible divisions, as indicated in Figure 1(b) and Figure 1(c).

    Figure 1: Two valid divisions of four pieces.

    On the other hand, in the configuration of Figure 2(a), there is only one valid division, as indicated in Figure 2(b).

    Figure 2: One valid division of four pieces.

    To simplify things, we assume that no three pieces of pie are on the same line. This implies in particular that no two pieces of pie occupy the same position. Moreover, we assume that each piece is infinitely small.

    Input

    The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:

    • One line with an even integer N, satisfying 2 ≤ N ≤ 1, 000.

    • N lines, each with two integers x and y, satisfying −10, 000 ≤ x, y ≤ 10, 000: the x- and y-coordinates of a piece of the first pie.

    • N lines, each with two integers x and y, satisfying −10, 000 ≤ x, y ≤ 10, 000: the x- and y-coordinates of a piece of the second pie.

    Integers on the same line are separated by a single space.

    Output

    For every test case in the input, the output should contain a single number, on a single line: the number of ways to split the 2N pieces of pie in two, by stretching a cord over the table, such that at each side of the cord, there are (1/2)N pieces of the first pie and (1/2)N pieces of the second pie.

    Sample Input

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

    Sample Output

    2
    1
    3

    Source

    样例输入

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

    样例输出

    2
    1
    3

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部