시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 685 248 191 43.115%

문제

씬디는 애너그램(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
W3sicHJvYmxlbV9pZCI6IjY0NDMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzUyY1x1YjUxNFx1YjI5NCBcdWM1NjBcdWIxMDhcdWFkZjhcdWI3YTgoYW5hZ3JhbSkgXHVkNTA0XHViODVjXHVhZGY4XHViN2E4XHVjNzQ0Jm5ic3A7XHViOWNjXHViNGU0XHVjNWI0IFx1YzkwNCBcdWMyMTggXHVjNzg4XHViMjk0IFx1YjBhOFx1Yzc5MFx1Yjk3YyBcdWM4OGJcdWM1NDRcdWQ1NWNcdWIyZTQuIFx1Y2MzOFx1YWNlMFx1Yjg1YyBcdWM1MmNcdWI1MTRcdWIyOTQgXHViOWU0XHVjNmIwIFx1YzYwOFx1YzA1OF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VpY2tseSB3aXRoIHRoZSBudW1iZXIgb2YgZ2l2ZW4gbGV0dGVycy4gTWFrZSBzdXJlIHlvdSBkbyBub3QgdXNlIGxvbmcgd29yZHMgZm9yIHRlc3RpbmcgeW91ciBwcm9ncmFtIGJlY2F1c2UgdGhlIG91dHB1dCBmaWxlIGNvdWxkIGJlY29tZSB2ZXJ5IGJpZywgd2FzdGUgYSBsb3Qgb2Ygc3BhY2Ugb24gdGhlIGRpc2sgYW5kIGRlZ3JhZGUgdGhlIHBlcmZvcm1hbmNlIG9mIHRoZSBuZXR3b3JrLiZuYnNwOzxcL3A+XHJcbiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

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

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