#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#define SIZE 200000
using namespace std;
int formal(string s){
int ans = 0;
char ch ;
for(int i=0;i<s.length();i++){
if(s.at(i) != '-'){
if(s.at(i) == '0' || s.at(i) == '1'){
ch = s.at(i);
}
if(s.at(i) == 'A' || s.at(i) == 'B' || s.at(i) == 'C' || s.at(i) == '2' ){
ch = '2';
}
if(s.at(i) == 'D' || s.at(i) == 'E' || s.at(i) == 'F' || s.at(i) == '3' ){
ch = '3';
}
if(s.at(i) == 'G' || s.at(i) == 'H' || s.at(i) == 'I' || s.at(i) == '4' ){
ch = '4';
}
if(s.at(i) == 'J' || s.at(i) == 'K' || s.at(i) == 'L' || s.at(i) == '5' ){
ch = '5';
}
if(s.at(i) == 'M' || s.at(i) == 'N' || s.at(i) == 'O' || s.at(i) == '6' ){
ch = '6';
}
if(s.at(i) == 'P' || s.at(i) == 'R' || s.at(i) == 'S' || s.at(i) == '7' ){
ch = '7';
}
if(s.at(i) == 'T' || s.at(i) == 'U' || s.at(i) == 'V' || s.at(i) == '8' ){
ch = '8';
}
if(s.at(i) == 'W' || s.at(i) == 'X' || s.at(i) == 'Y' || s.at(i) == '9' ){
ch = '9';
}
ans = ans * 10 + ch - '0';
}
else{}
}
return ans;
}
int compare(const void * a,const void * b){
return *(int*)a-*(int*)b;
}
int main(void){
int test;
cin>>test;
int v[SIZE];
for(int t=0;t<test;t++){
string x;
cin>>x;
int y = formal(x);
v[t] = y;
}
qsort(v,test,sizeof(int),compare);
int pos = 0;
int flag = 0;
while(pos<test) {
//cout<<v[pos]<<endl;
int last = pos ;
while(v[pos+1]==v[pos]){
pos ++;
// cout<<v[pos]<<endl;
}
if(last != pos){
printf("%03d-%04d %d\n",v[pos]/10000,v[pos]%10000,pos-last+1);
flag = 1;
}
pos++;
}
if(flag == 0){
cout<<"No duplicates."<<endl;
}
//system("pause");
return 0;
}
poj1002不会超时
最新推荐文章于 2021-03-02 02:20:02 发布