#P15827. [JOI Open 2014] Project of Migration
[JOI Open 2014] Project of Migration
Description
In the year of 21XX, the JOI kingdom is faced with a big crisis. The King of the JOI kingdom takes the initiative to migrate people to the IOI star, which is a recently-discovered star.
In the JOI kingdom, there are ethnic groups numbered from 1 to . There are pairs of ethnic groups which have friendly relationships. On the IOI star, there are resident areas numbered from 1 to (). The resident area is the point in the coordinate plane (). In the migration project, we allocate one of the resident areas to each ethnic group. No resident area is allocated to more than one ethnic groups.
For each pair of ethnic groups having a friendly relationship, we will construct a railway track connecting their resident areas. A railway track is a line segment connecting two resident areas. It may happen that two railway tracks intersect each other depending on the way of allocation of resident areas.
By request from the King, you are to find a migration project with minimum number of pairs of railway tracks intersecting each other.
Task
Given the information of ethnic groups in the JOI kingdom and the information of the resident areas on the IOI star, find a migration project with minimum number of pairs of railway tracks intersecting each other.
Input Format
There are five subtasks. Each subtask corresponds to a public input data file. The format of each input data file is as follows.
- The first line of input contains two space separated integers and . This means there are ethnic groups in the JOI kingdom, and there are pairs of ethnic groups having friendly relationships.
- The -th line () of the following lines contains two space separated integers and . This means the ethnic group and the ethnic group have a friendly relationship.
- The following line contains an integer , the number of resident areas on the IOI star.
- The -th line () of the following lines contains two space separated integers and . This means the resident area is in the coordinate plane.
Note
It may happen that more than two railway tracks intersect at a point depending on the way of allocation of resident areas.
Output Format
For each input data file, submit an output data file. The output data file consists of lines. The -th line () contains an integer which denotes the resident area allocated to the ethnic group .
6 10
1 2
1 3
1 4
1 5
1 6
2 4
2 6
3 4
3 5
4 6
7
2 1
2 5
4 3
6 7
7 3
8 5
9 1
1
5
4
2
7
3
Hint
Sample 1 Explanation
In this sample input, there are seven resident areas on the IOI star as in the following figure.
:::align{center}
:::
There are six ethnic groups. We allocate a resident area to each ethnic group as follows.
- We allocate the resident area 1 to the ethnic group 1.
- We allocate the resident area 5 to the ethnic group 2.
- We allocate the resident area 4 to the ethnic group 3.
- We allocate the resident area 2 to the ethnic group 4.
- We allocate the resident area 7 to the ethnic group 5.
- We allocate the resident area 3 to the ethnic group 6.
We will construct railway tracks as in the following figure. The number of pairs of railway tracks intersecting each other is 2.
Constraints
All input data satisfy the following conditions.
- .
- .
- .
- .
- do not lie in a line ().
- For any two ethnic groups, we can travel from the resident area of one group to the resident area of another group by passing through some railway tracks on the IOI star.
:::align{center}
:::
- The railway track connecting the resident area 1 (the place of the ethnic group 1) and the resident area 4 (the place of the ethnic group 3) and the railway track connecting the resident area 2 (the place of the ethnic group 4) and the resident area 3 (the place of the ethnic group 6) are intersecting each other.
- The railway track connecting the resident area 1 (the place of the ethnic group 1) and the resident area 4 (the place of the ethnic group 3) and the railway track connecting the resident area 2 (the place of the ethnic group 4) and the resident area 5 (the place of the ethnic group 2) are intersecting each other.
Subtasks
For each subtask, the values of , , , , are as in the following table. For the values of , , see Grading.
| Subtask | |||||
|---|---|---|---|---|---|
| 1 | 30 | 50 | 60 | 25 | 100 |
| 2 | 125 | 124 | 300 | 0 | 75 |
| 3 | 200 | 2000 | 400 | 110000 | 250000 |
| 4 | 250 | 350 | 250 | 400 | 2000 |
| 5 | 300 | 1600 | 500 | 72000 | 150000 |
Grading
This is an output-only task. There are five subtasks, and each subtask consists of one input data file. Submit an output data file for each subtask. Your score of each subtask is calculated as follows.
- If your migration project does not satisfy the conditions in the task statement, your score is 0.
- If your migration project satisfies the conditions in the task statement, your score is calculated according to the values of , as follows. Let be the number of pairs of railway tracks intersecting each other.
- If , your score is 0.
- If , your score is $\left\lfloor 1 + 19 \times \left( \frac{T - C}{T - S} \right)^2 \right\rfloor$. Here, denotes the largest integer less than or equal to .
- If , your score is 20.
京公网安备 11011102002149号