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

what's the problem?all the test data is passed.

Posted by 00448224 at 2005-10-21 12:26:56 on Problem 1171
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int score(string s)
{
	int b[26]={2,5,4,4,1,6,5,5,1,7,6,3,5,2,3,5,7,2,1,2,4,6,6,7,5,7} ,n=0;
	for(int i=0;i<s.length();i++)
		n+=b[s[i]-'a'];
	return n;
}
bool in(int a[],string s)
{
	int b[26]={0},n;
	for(int i=0;i<s.length();i++)
	{
		n=s[i]-'a';
		b[n]++;
		if(a[n]<b[n])
			return false;
	}
	return true;
}
void main()
{
	string c1,c2;
	int n1,a[26]={0},max=0,temp1,temp2;
	vector<string> v;
	cin>>c1;
	n1=score(c1);
	for(int i=0;i<c1.length();i++)
		a[c1[i]-'a']++;
	cin>>c2;
	while(c2[0]!='.'){
		if(in(a,c2))
			v.push_back(c2);
		cin>>c2;
	}
	vector<string>::const_iterator p1=v.begin(),p2;
	max=score(*p1);
	for(;p1!=v.end()-1;p1++)
	{
		temp1=score(*p1);
		if(temp1>=max)
			max=temp1;
		for(p2=p1+1;p2!=v.end();p2++)
		{
			string y=(*p1)+(*p2);
			if(in(a,y))
			{
				temp2=score(y);
				if(temp2>=max)
					max=temp2;
			}
		}
	}
	cout<<max<<endl;
}	


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