#P75. [CSP-S 2020] Zoo Enlargement
[CSP-S 2020] Zoo Enlargement
Person in Charge
Problem Description
A zoo keeps a large number of animals. The zookeeper A will purchase different types of feed according to the animal breeding situation in accordance with the Feeding Guide, and send the purchase list to the purchaser B.
Specifically, there are different types of animals in the animal kingdom, numbered from to . The zoo keeps of these types, where the number of the -th type of animal is .
The Feeding Guide contains requirements. The -th requirement is in the form of "If the zoo keeps an animal whose binary representation of the number has the -th bit as , then the -th type of feed must be purchased". There are a total of types of feed, numbered from to . In this problem, we regard the binary representation of an animal's number as a -bit 01 string, where the -th bit is the least significant bit and the -th bit is the most significant bit.
According to the Feeding Guide, zookeeper A will make a feed list and hand it over to purchaser B, who will then buy the feed. The list is in the form of a -bit 01 string: the -th bit being means the -th type of feed needs to be purchased, and means it does not. In fact, based on the purchased feed, the zoo may be able to keep more animals. More specifically, if adding an unpurchased animal with number to the zoo's breeding list does not change the feed list, then we consider that the zoo can currently keep the animal with number .
Now purchaser B wants you to help calculate how many more types of animals the zoo can currently keep.
Input Format
The first line contains four integers separated by spaces, representing the number of animals in the zoo, the number of requirements in the Feeding Guide, the number of feed types, and the number of bits in the binary representation of animal numbers, respectively.
The second line contains integers separated by spaces, where the -th integer is .
The next lines each contain two integers representing a requirement.
It is guaranteed that all are distinct and all are distinct.
Output Format
Output a single integer on one line representing the answer.
Samples
3 3 5 4
1 4 6
0 3
2 4
2 5
13
Sample 1 Explanation
The zoo keeps three animals numbered . The three requirements in the Feeding Guide are:
- If the zoo keeps an animal whose number has the -th binary bit as , then the -rd type of feed must be purchased.
- If the zoo keeps an animal whose number has the -nd binary bit as , then the -th type of feed must be purchased.
- If the zoo keeps an animal whose number has the -nd binary bit as , then the -th type of feed must be purchased.
The feed purchase status is as follows:
- The -th binary bit of the number of the animal numbered is , so the -rd type of feed needs to be purchased;
- The -nd binary bit of the numbers of the animals numbered and is , so the -th and -th types of feed need to be purchased.
Since adding an animal numbered to the current zoo will not change the shopping list, the answer is .
Sample 2
See zoo/zoo2.in and zoo/zoo2.ans in the contestant's directory.
Sample 3
See zoo/zoo3.in and zoo/zoo3.ans in the contestant's directory.
Data Range
For of the data: , , , and all are distinct.
For of the data: , , , .
For of the data: , , .
For of the data: , , .