Logo
(追記) (追記ここまで)

3544번 - Funny Language 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB20181789.474%

문제

There is a well know game with words. Given a word you have to write as many other words as possible using the letters from the given word. If the letter repeats multiple times in the original word, you can use it up to as many times in the new words. The order of letters in the original word does not matter. For example, given the word CONTEST you can write NOTE, NET, ON, TEST, SET, etc.

Now you are in charge of writing a new dictionary. Your task is to sneak n new words into it. You know in advance m words Wi (1 ≤ i ≤ m) that you will have to play a game with and you need to figure out which new n words to add to the dictionary to maximize the total number of words you can write out of these m words.

More formally, find such a set of nonempty words S where |S| = n, Wi ∉ S for any i, and Σ1≤i≤m|Si| is maximal, where Si ⊂ S is the set of words that can be written using letters from Wi.

입력

The first line of the input file contains two integer numbers n (1 ≤ n ≤ 100) — the number of new words you can add to the dictionary and m (1 ≤ m ≤ 1 000) — the number of words you will play the game with. The following m lines contain original words. Each word consists of at most 100 uppercase letters from A to Z.

출력

Write to the output file n lines with a new word on a line.

제한

예제 입력 1

3 5
A
ACM
ICPC
CONTEST
NEERC

예제 출력 1

C
CN
E

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > NEERC 2009 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /