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

map水过,险些超时,贴个代码

Posted by 452181625 at 2014-05-26 13:46:16 on Problem 2503
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
using namespace std;
int main()
{
	int i;
	char str[15];
	string str1,str2,s;
	map<string,string> m;
	while(gets(str) && strlen(str))
	{
		str1=str2="\0";
		for(i=0;;i++)
			if(str[i]==' ') 
			{
				str[i]='\0';
				break;
			}
			str1+=str;
			str2+=str+i+1;
			m[str2]=str1;
	}
	while(cin>>s)
	{
		if(m[s].size())
			cout<<m[s]<<endl;
		else
			cout<<"eh\n";
	}
	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