|
||||||||||
MemoryTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 562 Accepted Submission(s): 171 Special Judge Problem Description Little Bob¡¯s computer has 2n bytes of memory. For convenience, n-bit integers 0 to 2n - 1 are used to index these bytes. Now he wants to assign a value to each byte of the memory. In this problem, a byte is composed of m bits. Therefore he can only assign 0 to 2m - 1 (inclusive) to a single byte. Bob has some preferences on which value to be assigned to each byte. For the byte indexed by i, if it is assigned with value j (0 ¡Ü j < 2m), the preference score for it is wi,j. In addition, each byte has a threshold value. For two different bytes indexed by a and b, if the following two conditions are satisfied, there will be an additional score (ua xor ub): 1.a and b only have one bit of difference in their binary forms; 2.The assigned value of byte a is not less than its threshold value, or the assigned value of byte b is not less than its threshold value. The total score of an assignment solution is the sum of the preference scores of all bytes plus the sum of all additional scores. Bob wants to find an assignment solution with the maximum total score. If there are multiple solutions, you can output any of them. Input The first line contains an integer T (T ¡Ü 3), denoting the number of the test cases. For each test case, the first line contains two integers, n and m(1 ¡Ü n, m ¡Ü 8), as mentioned above. The second line contains 2n integers, and the i-th integer is the threshold value for byte i. The threshold values are between 0 and 2m - 1, inclusively. The third line contains 2n integers, and the i-th integer is ui(0 ¡Ü ui < 1024). The next 2n lines give all preference scores. Each line contains 2m integers, and the j-th integer of the i-th line is wi,j (-1024 ¡Ü wi,j < 1024). Output For each test case, output one line consisting of 2n integers between 0 and 2m - 1, and the i-th integer is the value assigned to byte i in the assignment solution with the maximum total score. Sample Input
Sample Output
Source | ||||||||||
|