262. Symbol Recognition
time limit per test: 0.25
memory limit per test: 65536
Consider a monochrome computer monitor with N x M pixels resolution. It can display K symbols. Symbol is a non-empty set of black pixels on the screen. You are to write a program, that computes minimal possible amount of pixels, that are enough to recognize a symbol.
First line of input contains integers N, M, K (1 <= N, M <= 10, 2 <= K <= 6). K blocks follow, separated by empty lines. Each block consists of N rows of M characters. It's a symbols representation on the N x M screen. `1' denotes black pixel, `0' denotes white pixel. You may assume that symbols are unique.
Print on the first line of output the minimal possible amount of pixels that enough to recognize symbol. I.e. you have to find set of pixels that has different color in each pair of symbols. If there are several sets with equal amount of pixels, output any of them. Then print N lines M characters each. `1' denotes that corresponding pixel is in your set. `0' denotes that corresponding pixel is not in your set.
2 4 3
In this example output set consists of two most left pixels. They are both white in first symbol; black and white in second symbol; both black in third symbol. So, it's possible to recognize each symbol using this set of pixels.
|Author:||Andrew V. Lazarev
|Resource:||Saratov SU Contest: Golden Fall 2004
|Date:||October 2, 2004
|Server time: 2017-09-26 22:11:01||Online Contester Team © 2002 - 2016. All rights reserved.|