#P6990. [NEERC2014] Filter
[NEERC2014] Filter
题目描述
You are working on a new high-performance database engine -- Instant Compression and Processing Codec ICPC stores user activity records. Each user activity record has an integer user identifier. The records are stored in a number of data files. Each data file is compressed and can contain records from multiple users, however ICPC has to process queries that look for a specific subsets of users. In order to do so, there has to be a way to quickly determine which data files may contain records for a specific user before attempting to decompress them, which may be a long and CPU-consuming process.
ICPC uses an algorithm called Bloom Filter. The way it is implemented in ICPC is described below. For each ICPC database the following integer parameters are chosen:
is the number of bits in the filter;
is the number of hash functions in the filter;
are the parameters for hash functions for
A value of the bloom filter is computed for each data file. The data file's bloom filter is a vector of bits. A bit number is set to one if and only if there is a record in this data file for some user identifier such that for some hash function the following equality holds:
mod (1)
Your task is to implement ICPC filtering logic. You are given filter parameters and values for a number of data files and a set of user identifiers. Your task is determine which data files may contain record with at least one user identifier from the specified set. A data file may contain a record with a user identifier if and only if for all all the bits given by equality (1) in its filter value are set to one.
输入格式
The first line of the input file contains filter parameters -- integer numbers , and for $0 \le i < f (1 \le m \le 1000 , 1 \le f \le 100 , 1 \le a_{i} < 2^{31}).$
The second line of the input file contains an integer -- the number of data files . Each of the following lines contains bloom filter value of the corresponding file in hexadecimal form. Each value is represented by a string of hexadecimal digits (one of The first digit of the string represents bits of the value (stored in order from the least significant bit of a hexadecimal digit to the most significant bit), the second digit -- bits , the third -- , etc. When mod , then the last hexadecimal digit represents the last mod bits of the value in its least significant bits.
The following line of the input file contains an integer -- the number of user identifiers in a query , followed by integers -- the set of distinct user identifiers in the query
输出格式
Write a line with the integer number to the output file -- the number of data files that may contain a record with at least one user identifier from the specified set, followed by numbers -- the numbers of the corresponding data files in ascending order.
23 4 3 5 7 11
3
effde7
c07902
0800c1
3 2 4 6
2 0 2
提示
Time limit: 1 s, Memory limit: 256 MB.