#P15601. [ICPC 2020 Jakarta R] Robust Defense
[ICPC 2020 Jakarta R] Robust Defense
题目描述
The Department of Defense (DoD) has developed a new wireless technology that is claimed to be unpenetrable. This new technology consists of two types of devices: a transmitter and a receiver. Even though the DoD has tried to make those devices to be robust, the new transmitter might be spoilt depending on the cause. The new receiver, on the other hand, is quite robust and designed such that it cannot be turned off. The receiver is online if only if at least one of the following conditions is satisfied.
- There exists 2 active transmitters (not spoilt) such that the receiver is located exactly at a line segment connecting those 2 transmitters.
- There exists 3 active transmitters (not spoilt) such that the receiver is located strictly inside a triangle formed by those 3 transmitters.
This new technology allows the DoD to strategically place their communication towers such that their military bases cannot be tapped by an outsider. There are military bases each located at a coordinate and communication towers each located at a coordinate . Each military base is equipped with a new receiver, and each communication tower is equipped with a new transmitter. It is guaranteed that there is no pair of buildings (i.e. military bases or communication towers) that are located at the same location. It is also guaranteed that the receiver in each military base is online, thus, all military bases are online.
One day, the DoD predicts that a heavy storm will come close to its communication towers. During this heavy storm, each transmitter has a chance of to be spoilt and to survive (or not to be spoilt).
The DoD asks your help to calculate the probability that all the military bases are still online right after the heavy storm. This probability can be expressed as a rational number where and are two coprime integers. You should output an integer where is the modular inverse of modulo . In other words, you should output an integer () such that .
输入格式
Input begins with a line containing three integers: (; ; ) representing the number of military bases, the number of communication towers, and the probability of a transmitter not to be spoilt due to the heavy storm, respectively. The next lines each contains two integers: () representing the location of each military base. The next lines each contains two integers: () representing the location of each communication tower. It is guaranteed that there are no buildings (i.e. military bases or communication towers) that are located at the same location. It is also guaranteed that all military bases are online before the heavy storm.
输出格式
Output in a line an integer () such that where and are two coprime integers and is the probability that all the military bases are still online right after the heavy storm.
1 4 50
0 0
-1 0
3 0
0 1
2 -1
686292993
3 5 20
3 0
1 3
5 3
0 0
0 6
6 0
6 6
3 3
771443236
提示
Explanation for the sample input/output #1
Each transmitter has a chance of to survive the heavy storm. In this case, there are possible outcomes with the same probability, and only of them cause all the military bases to be still online right after the heavy storm, i.e. the set of active transmitters (not spoilt) are either of the following: , , , , and . Therefore, the probability is , hence , , and .
Explanation for the sample input/output #2
All transmitters except the transmitter must not be spoilt so that all the military bases are still online right after the heavy storm. With each transmitter having a chance to survive of or , the probability of such a case is . Therefore, , , and .