| ||||||||||
| 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 | |||||||||
what's the problem?all the test data is passed.#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator