Garage Door Code
면접 대비시간 제한4초메모리 제한1024 MB
관찰된 여러 자릿수 문자열 각각이 실제 K자리 코드를 부분 수열로 포함할 때, 모든 관찰과 일치하는 K자리 코드를 모두 찾아 사전순으로 출력한다.
문제
There have been an increasing number of laptop thefts in your area lately. After yours was recently stolen, too, you decided that you had enough and are going to do something about it! After asking around, you heard some rumors about where the stolen laptops have been hidden and you want to get your laptop back!
The rumors led you to a particular garage and you have decided to keep an eye on it to try to figure out how to get in. Over the course of the afternoon, you have seen a handful of people come, enter the garage, and then leave.
There's a security keypad on the door. As you have watched carefully, you have observed different people putting in the code, but they enter different numbers of digits. You figure out that some, maybe all, of them are pretending to intersperse additional key presses just to confuse anyone who might be watching them. You look up the keypad manufacturer's webpage and find that the keypad was designed to use codes with a predetermined length of digits. Given the set of observations you've made of different individuals "entering" elongated variations of the code (each does contain the correct code), can you determine what the correct code might be? %Or, instead of unique yes/no, what are possible codes (or how many are there) that would be consistent with your set of observations? It is guaranteed that there will always be at least one correct code that matches all observations. There may be multiple codes that match; you must find all matching codes.
입력
The first line of input contains two integers (), the number of digits specified by the manufacturer for a correct code, and (), the number of elongated entry code sequences that you observed.
Each of the next lines contains a string of at least and at most 12 digits (0-9). These are the elongated entry code sequences that you have observed.
출력
Determine all -digit codes that match the full set of elongated observations.
On the first line, output , the number of codes that match the set of elongated observations. Then output lines, each containing one of these matching codes, having sorted them in increasing lexicographic order.