시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 472 177 134 42.405%

문제

씬디는 애너그램(anagram) 프로그램을 만들어 줄 수 있는 남자를 좋아한다. 참고로 씬디는 매우 예쁘다.

애너그램 프로그램이란, 입력받은 영단어의 철자들로 만들 수 있는 모든 단어를 출력하는 것이다. 가령 "abc" 를 입력받았다면, "abc", "acb", "bac", "bca", "cab", "cba" 를 출력해야 한다.

입력받은 단어내에 몇몇 철자가 중복될 수 있다. 이 경우 같은 단어가 여러번 만들어 질 수 있는데, 한 번만 출력해야 한다.  또한 출력할 때에 알파벳 순서로 출력해야 한다.

입력

첫째 줄에 단어의 개수 N 이, 둘째 줄부터 N개의 영단어가 들어온다. 영단어는 대소문자로 이루어져 있고, 대문자와 소문자는 구별해야 한다.

출력

N개의 영단어에 대한 모든 가능한 애너그램을 출력한다. 각각의 영단어에 대한 애너그램을 출력할 때, 알파벳 순서로 중복되지 않게 출력한다.

예제 입력 1

2
abc
acba

예제 출력 1

abc
acb
bac
bca
cab
cba
aabc
aacb
abac
abca
acab
acba
baac
baca
bcaa
caab
caba
cbaa
W3sicHJvYmxlbV9pZCI6IjY0NDMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzUyY1x1YjUxNFx1YjI5NCBcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgoYW5hZ3JhbSkgXHVkNTA0XHViODVjXHVhZGY4XHViN2E4XHVjNzQ0Jm5ic3A7XHViOWNjXHViNGU0XHVjNWI0IFx1YzkwNCBcdWMyMTggXHVjNzg4XHViMjk0IFx1YjBhOFx1Yzc5MFx1Yjk3YyBcdWM4OGJcdWM1NDRcdWQ1NWNcdWIyZTQuIFx1Y2MzOFx1YWNlMFx1Yjg1YyBcdWM1MmNcdWI1MTRcdWIyOTQgXHViOWU0XHVjNmIwIFx1YzYwOFx1YzA1OFx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ciBvZiBnaXZlbiBsZXR0ZXJzLiBNYWtlIHN1cmUgeW91IGRvIG5vdCB1c2UgbG9uZyB3b3JkcyBmb3IgdGVzdGluZyB5b3VyIHByb2dyYW0gYmVjYXVzZSB0aGUgb3V0cHV0IGZpbGUgY291bGQgYmVjb21lIHZlcnkgYmlnLCB3YXN0ZSBhIGxvdCBvZiBzcGFjZSBvbiB0aGUgZGlzayBhbmQgZGVncmFkZSB0aGUgcGVyZm9ybWFuY2Ugb2YgdGhlIG5ldHdvcmsuJm5ic3A7PFwvcD5cclxuIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

ACM-ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 1995 E번

  • 문제의 오타를 찾은 사람: jh05013
  • 문제를 번역한 사람: sehun