Give a name that consists of 26 strings, which defines the "beauty" of the string as the sum of all its letters "beauty".
Each letter has a "pretty degree", ranging from 1 to 26. No two letters have the same "beauty degree". Letters Ignore case.
Give multiple names to calculate the maximum possible "beauty" for each name.
http://career-oj.huawei.com/exam/ShowProblemInfo?method=campusProblemInfo&id=228
This topic has been shown to be malformed:
The following is the code submitted :
1#include <iostream>2#include <vector>3#include <string>4#include <map>5 using namespacestd;6 7map<Char,int>ha;8 9 voidSorted (vector<int>&VEC)Ten { One intlen=vec.size (); A inttemp; - for(intI=0; i<len-1; i++) - for(intj=i+1; j<len;j++) the if(vec[j]<Vec[i]) - { -temp=Vec[i]; -vec[i]=Vec[j]; +vec[j]=temp; - } + } Avector<int> Piaoliangdu (vector<string>&VEC) at { -vector<int>Rev; -vector<int>v; - intlen=vec.size (); - for(intI=0; i<len;i++) - { in strings=Vec[i]; - for(string:: Iterator Iter1=s.begin (); Iter1!=s.end (); iter1++) to if(*iter1<'a'|| *iter1>'Z') +*iter1=*iter1+ +; - ha.clear (); the for(string:: Iterator Iter1=s.begin (); Iter1!=s.end (); iter1++) * { $ if(Ha.count (*iter1) = =0)Panax Notoginsengha[*iter1]=1; - Else theha[*iter1]++; + } A v.clear (); the for(map<Char,int>::iterator J=ha.begin (); J!=ha.end (); j + +) +V.push_back (j->second); - Sorted (v); $ $ intdu= -; - intRe=0; - for(vector<int>::reverse_iterator J=v.rbegin (); J!=v.rend (); j + +) the { -Re=re+ (du* (*j));Wuyidu--; the } - Rev.push_back (re); Wu } - returnRev; About } $ - intMain () - { - intN; Avector<string>Vec; + strings; theCin>>N; - while(n--) $ { theCin>>s; the Vec.push_back (s); the } the -vector<int> rev=Piaoliangdu (VEC); invector<int>:: iterator i; the for(I=rev.begin (); I!=rev.end ()-1; i++) thecout<<*i<<' '; Aboutcout<<*i<<Endl; theSystem"Pause"); the the}
Huawei Training Topic: Beginner--Name Beauty (failed, display format error)