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 |
Re:Why tle???In Reply To:Why tle??? Posted by:XinTao at 2003-06-05 16:06:17 #include<iostream> #include<fstream> #include<vector> #include<string> #include<map> #include<algorithm> using namespace std; char ch[]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'}; string ReadOne() { string s; cin>>s; for(unsigned int i=0;i<s.length();i++) { if(isalpha(s[i])) { s[i]=ch[s[i]-'A']; continue; } if(s[i]=='-') { s.erase(s.begin()+i); i--; continue; } } return s; } void Output(string s) { s.insert(s.begin()+3,1,'-'); cout<<s; } vector<string> vec; map<string,int> dic; void Proc() { vec.clear(); dic.clear(); int n; for(cin>>n;n;n--) { string s=ReadOne(); if(dic.count(s)) { dic[s]++; } else { dic[s]=1; vec.push_back(s); } } sort(vec.begin(),vec.end()); for(int i=0;i<vec.size();i++) { if(dic[vec[i]]>1) { Output(vec[i]); cout<<" "<<dic[vec[i]]<<endl; } } } int main(int argc, char* argv[]) { Proc(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator