Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

题目的用例通过了,但系统一直反馈WA

Posted by eddy_liu at 2015-07-26 00:54:54 on Problem 1318
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator