10044-Erdos number Time limit exceeded

以下是我的代码,但是在通过uva测试是time limit exceeded, 不知道是什么原因,而且我自己测试了几个数据都是对的。

#include
#include
#include
#include
#include
#include

using namespace std;

string Erdos="Erdos, P.";
string Scenario="Scenario ";
string Infinity="infinity";
map Scientists;

void loopFind(map > map_name,vector parters,vector lines,int value){
	if(parters.size()<=0)return;

	for(int i=0;i parter1;
		vector lines1;
		string tmp=parters.at(i);
		for(map >::iterator it=map_name.begin();it!=map_name.end();++it){
			vector tmpNames=it->second;
			vector::iterator tmpIndex=find(lines.begin(),lines.end(),it->first);
			vector::iterator it1=find(tmpNames.begin(),tmpNames.end(),tmp);
			if(tmpIndex!=lines.end())break;
			else if(it1!=tmpNames.end()){
				for(int j=0;jfirst);
			}
		}
		loopFind(map_name,parter1,lines1,value+1);
	}
}

void findScientists(map > map_name){
	Scientists[Erdos]=0;
	vector parters;
	vector lines;
	
	for(map >::iterator it=map_name.begin();it!=map_name.end();++it){
		vector names=it->second;
		vector::iterator tmp=find(names.begin(),names.end(),Erdos);
		if(tmp!=names.end()){
			for(int i=0;ifirst);
		}
	}
	loopFind(map_name,parters,lines,2);
}

void getErdosNumber(vector paper,vector names){
	int index=1;
	map > map_name;
	
	for(vector:: iterator it=paper.begin();it!=paper.end();++it){
		string tmpString=*it;
		vector tmpSci;
		int begin=0;
		int end=0;
		if(tmpString.length()<1)continue;
		while(end>n;

	for(int i=1;i<=n;++i){
		int P=0;
		int N=0;
		cin>>P>>N;
		if(P<1||N<1)continue;

		getchar();	
		vector paper;
		for(int x=0;x names;
		for(int y=0;y::iterator it;
		
		for(vector::iterator ite=names.begin();ite!=names.end();++ite){
			it=Scientists.find(*ite);
			if(it!=Scientists.end()){
				 cout<first<<" "<second<

如果有人知道为什么会是time limit exceeded, 烦请告知,谢谢

你可能感兴趣的:(C++)