Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
题目的用例通过了,但系统一直反馈WA#include<iostream> #include<string> #include<list> #include<algorithm> using namespace std; list<string> outputList; void ergodic(string prefix, string str){ if(str==""){ //cout<<prefix<<endl; outputList.push_back(prefix); }else{ for(int i=0;i<str.length();i++){ ergodic(prefix+str[i],str.substr(0,i)+str.substr(i+1,str.length())); } } } int main(int argc, char *argv[]){ string str; list<string> inputList; while(cin>>str,str!="XXXXXX"){ inputList.push_back(str); } while(cin>>str,str!="XXXXXX"){ bool isUnscramble=false; outputList.clear(); ergodic("",str); unique(outputList.begin(),outputList.end()); //sort(outputList.begin(),outputList.end(),less<string>()); outputList.sort(); for(list<string>::iterator iter=outputList.begin(); iter!=outputList.end(); ++iter){ if(find(inputList.begin(),inputList.end(),*iter)!=inputList.end()){ cout<<*iter<<endl; isUnscramble=true; } } if(!isUnscramble){ cout<<"NOT A VALID WORD"<<endl; } cout<<"******"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator