`
phinecos
  • 浏览: 343306 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

POJ1318 Word Amalgamation

 
阅读更多

题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1318

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->#include<set>
#include
<iostream>
#include
<string>
#include
<algorithm>
usingnamespacestd;

intmain()
{
set<string>dict;
stringword;
charch[10];
while(true)
{
gets(ch);
if(strcmp(ch,"XXXXXX")==0)break;
dict.insert(ch);
}
while(true)
{
gets(ch);
if(strcmp(ch,"XXXXXX")==0)break;
intcount=0;
word
=ch;
sort(word.begin(),word.end());
do
{
if(dict.find(word)!=dict.end())
{
cout
<<word.c_str()<<endl;
count
++;
}
}
while(next_permutation(word.begin(),word.end()));
if(count==0)
{
cout
<<"NOTAVALIDWORD"<<endl;
}
cout
<<"******"<<endl;
}
return0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics