| ||||||||||
| 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 | |||||||||
用STL水过#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
bool cmp(string a,string b){
return a<b;
}
int main(){
int n,i;
cin>>n;
vector<string> vec;
while(n--){
string str,temp;
cin>>str;
for(i=0;i<str.size();i++){
if(str[i]>='A'&&str[i]<='Z'){
if(str[i]=='S'||str[i]=='V'||str[i]=='Y')
temp.push_back((str[i]-'A')/3+1+'0');
else
temp.push_back((str[i]-'A')/3+2+'0');
}
else if(str[i]>='0'&&str[i]<='9'){
temp.push_back(str[i]);
}
}
temp.insert(3,"-");
vec.push_back(temp);
}
sort(vec.begin(),vec.end(),cmp);
bool flag=false;
int times=0;
for(i=0;i<vec.size();i++){
if(i==0){
times++;
continue;
}
if(vec[i]==vec[i-1]){
times++;
if(i==vec.size()-1){
if(times>1){
flag=true;
cout<<vec[i]<<" "<<times<<endl;
}
}
}
else{
if(times>1){
cout<<vec[i-1]<<" "<<times<<endl;
flag=true;
}
times=1;
}
}
if(flag==false)
cout<<"No duplicates."<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator