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

문제

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

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

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

입력

첫째 줄에 단어의 개수 N 이, 둘째 줄부터 N개의 영단어가 들어온다. 영단어는 소문자로 이루어져 있다. 단어의 길이는 20보다 작거나 같고, 애너그램의 수가 100,000개 이하인 단어만 입력으로 주어진다.

출력

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

예제 입력 1

2
abc
acba

예제 출력 1

abc
acb
bac
bca
cab
cba
aabc
aacb
abac
abca
acab
acba
baac
baca
bcaa
caab
caba
cbaa
W3sicHJvYmxlbV9pZCI6IjY0NDMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzUyY1x1YjUxNFx1YjI5NCBcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgoYW5hZ3JhbSkgXHVkNTA0XHViODVjXHVhZGY4XHViN2E4XHVjNzQ0Jm5ic3A7XHViOWNjXHViNGU0XHVjNWI0IFx1YzkwNCBcdWMyMTggXHVjNzg4XHViMjk0IFx1YjBhOFx1Yzc5MFx1Yjk3YyBcdWM4OGJcdWM1NDRcdWQ1NWNcdWIyZTQuIFx1Y2MzOFx1YWNlMFx1Yjg1YyBcdWM1MmNcdWI1MTRcdWIyOTQgXHViOWU0X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IG9yZGVyLjxcL3A+XHJcbiIsImhpbnQiOiI8cD5UaGUgbnVtYmVyIG9mIHBvc3NpYmxlIGNvbWJpbmF0aW9ucyByYWlzZXMgdmVyeSBxdWlja2x5IHdpdGggdGhlIG51bWJlciBvZiBnaXZlbiBsZXR0ZXJzLiBNYWtlIHN1cmUgeW91IGRvIG5vdCB1c2UgbG9uZyB3b3JkcyBmb3IgdGVzdGluZyB5b3VyIHByb2dyYW0gYmVjYXVzZSB0aGUgb3V0cHV0IGZpbGUgY291bGQgYmVjb21lIHZlcnkgYmlnLCB3YXN0ZSBhIGxvdCBvZiBzcGFjZSBvbiB0aGUgZGlzayBhbmQgZGVncmFkZSB0aGUgcGVyZm9ybWFuY2Ugb2YgdGhlIG5ldHdvcmsuJm5ic3A7PFwvcD5cclxuIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

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

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