Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Quantum
Description At the Institution for Bits and Bytes at University of Ramville, Prof. Jeremy Longword and his eight graduate students are investigating a brand new way of storing and manipulating data on magnetic disks for use in hard drives. The method is based on letting quasimagnetic quantum operations operate on the sectors on the disk, and is, of course, safer andmore reliable than any earlier invented storage method. The use of each quantum operation costs a certain amount of energy, and the more energy the storage unit consumes, the warmer it will get. Therefore, you and your research team, are assigned the task of writing a program that, given sets of possible quantum operations and their costs, can calculate the lowest possible total cost for transforming a set of data to the wanted result. On the disk, binary words of length 1 ≤ Input The input starts with a single positive integer - One line containing three integers:
*L*,*n*and_{op}*n*separated by one space._{w} *L*indicates the length of the binary words and the quantum operations.*n*(≤ 32) is the number of quantum operations that are available for use when transforming the binary words._{op}*n*(≤ 20) is the number of binary words that are to be transformed in the current test case._{w}
After this, c 1000 of carrying out the quantum operation. The definition and the cost are separated by a single space._{i}Finally, there are nw rows, each containing two binary words separated by a single space. The first of these words should, when possible, be transformed to the second using the quantum operations. The binary words are expressed as sequences of 1’ s and 0’s. After these rows, the next test case follows, if there is any. Output Each test case should produce a row containing a list of the energy costs of transforming each of the binary words. The costs should be separated by a single space and presented in the same order as the corresponding input. When there is no successful way of transforming a binary word, “NP”, meaning Sample Input 2 4 3 3 NFFN 1 NFNF 2 NNFN 4 0010 0100 0001 0010 0100 1000 4 4 5 CFSF 4 NNSS 3 FFFF 5 FNFN 6 1111 0000 1001 0110 0101 1000 1000 0011 0000 1001 Sample Output 1 3 NP 5 4 8 9 9 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator