|
||||||||||
Chips ChallengeTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 165 Accepted Submission(s): 61 Problem Description A prominent microprocessor company has enlisted your help to lay out some interchangeable components (widgets) on some of their computer chips. Each chip¡¯s design is an N¡ÁN square of slots. One slot can hold a single component, and you are to try to fit in as many widgets as possible. Modern processor designs are complex, of course. You unfortunately have several restrictions:
A specification for a chip is N lines of N characters, where ¡®.¡¯ indicates an open slot, ¡®/¡¯ indicates a disabled slot, and ¡®C¡¯ indicates a slot already occupied by a component. For example: CC/.. ./.// ..C.C /.C.. /./C/ If no more than 3/10 of the components may be in any one row or column, the maximum number of widgets that can be added to this 5 ¡Á 5 chip is 7. A possible arrangement is below, where ¡®W¡¯ indicates a widget added in an open slot. CC/W. W/W// W.C.C /.CWW /W/C/ Input The input consists of several test cases. Each case starts with a line containing three integers: The size of the chip N (1 <= N <= 40), and A and B (1 <= B <= 1000, 0 <= A <= B) as described above. Each of the following N lines contains N characters describing the slots, one of ¡®.¡¯, ¡®/¡¯ or ¡®C¡¯, as described above. The last test case is followed by a line containing three zeros. Output For each test case, display a single line beginning with the case number. If there is a solution, display the maximum number of widgets that can be added to the chip. Display ¡°impossible¡± if there is no solution. Follow the format of the sample output. Sample Input
Sample Output
Source | ||||||||||
|