시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB56602266901844044.531%

문제

바로 어제 최백준 조교가 방 열쇠를 주머니에 넣은 채 깜빡하고 서울로 가 버리는 황당한 상황에 직면한 조교들은, 702호에 새로운 보안 시스템을 설치하기로 하였다. 이 보안 시스템은 열쇠가 아닌 암호로 동작하게 되어 있는 시스템이다.

암호는 서로 다른 L개의 알파벳 소문자들로 구성되며 최소 한 개의 모음(a, e, i, o, u)과 최소 두 개의 자음으로 구성되어 있다고 알려져 있다. 또한 정렬된 문자열을 선호하는 조교들의 성향으로 미루어 보아 암호를 이루는 알파벳이 암호에서 증가하는 순서로 배열되었을 것이라고 추측된다. 즉, abc는 가능성이 있는 암호이지만 bac는 그렇지 않다.

새 보안 시스템에서 조교들이 암호로 사용했을 법한 문자의 종류는 C가지가 있다고 한다. 이 알파벳을 입수한 민식, 영식 형제는 조교들의 방에 침투하기 위해 암호를 추측해 보려고 한다. C개의 문자들이 모두 주어졌을 때, 가능성 있는 암호들을 모두 구하는 프로그램을 작성하시오.

입력

첫째 줄에 두 정수 L, C가 주어진다. (3 ≤ L ≤ C ≤ 15) 다음 줄에는 C개의 문자들이 공백으로 구분되어 주어진다. 주어지는 문자들은 알파벳 소문자이며, 중복되는 것은 없다.

출력

각 줄에 하나씩, 사전식으로 가능성 있는 암호를 모두 출력한다.

예제 입력 1

4 6
a t c i s w

예제 출력 1

acis
acit
aciw
acst
acsw
actw
aist
aisw
aitw
astw
cist
cisw
citw
istw
W3sicHJvYmxlbV9pZCI6IjE3NTkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NTRcdWQ2MzggXHViOWNjXHViNGU0XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWJjMTRcdWI4NWMgXHVjNWI0XHVjODFjIFx1Y2Q1Y1x1YmMzMVx1YzkwMCBcdWM4NzBcdWFkNTBcdWFjMDAgXHViYzI5IFx1YzVmNFx1YzFlMFx1Yjk3YyBcdWM4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jaCBvdXRwdXQgbGluZSBjb250YWlucyBhIHdvcmQgb2YgbGVuZ3RoIEwgY2hhcmFjdGVycyAoYW5kIG5vIHNwYWNlcykuIFRoZSBvdXRwdXQgbGluZXMgbXVzdCBhcHBlYXIgaW4gYWxwaGFiZXRpY2FsIG9yZGVyLjxcL2xpPlxyXG48XC91bD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsImh0bWxfdGl0bGUiOiIwIiwicHJvYmxlbV9sYW5nX3Rjb2RlIjoiRW5nbGlzaCJ9XQ==

출처

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO November 2005 Contest > Bronze ?번

  • 문제를 만든 사람: author5
  • 잘못된 데이터를 찾은 사람: djm03178
  • 데이터를 추가한 사람: sksdong1