#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
char table[32] = { 'A', 'B', 'C','2',
'D', 'E', 'F' , '3' ,
'G', 'H','I', '4' ,
'J', 'K', 'L' , '5' ,
'M', 'N', 'O' , '6',
'P', 'R', 'S' ,'7' ,
'T', 'U', 'V' , '8' ,
'W', 'X', 'Y' ,'9' };
void sss(string &s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == '-') {
s.erase(i, 1);
i--;
}
}
for (string::iterator e = s.begin(); e != s.end(); ++e) {
for (int j = 0; j < 32; j++) {
if (table[j] == *e) {
int po = j / 4;
*e = table[po * 4 + 3];
}
}
}
};
int main() {
int d;
string s;
s.resize(20);
scanf("%d", &d);
vector<string> ss;
for (int w = 0; w < d; w++) {
scanf("%s", &s[0]);
ss.push_back(s);
}
vector<string>::iterator it;
vector<string>::iterator it2;
for (it = ss.begin(); it != ss.end(); ++it) {
sss(*it);
(*it).resize(8);
(*it)[7] = '\0';
}
int flag = 0;
sort(ss.begin(), ss.end());
it = ss.begin();
it2 = ss.begin();
ss.push_back("|");
while ((*it) != "|") {
while ((*it2) == (*it)) {
++it2;
}
if ((it2 - it) > 1) {
char b[7];
strcpy(b, (*it).c_str());
printf("%c%c%c-%c%c%c%c %d\n", b[0],
b[1], b[2], b[3], b[4], b[5], b[6], (int)(it2 - it));
flag = 1;
}
it = it2;
}
if (flag == 0) {
printf("No duplicates.");
}
return 0;
};
测试数据
这个能通过
12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279
这个不能
1
888-1200
/usercode/script.sh: line 62: 13 Segmentation fault $output - < “/usercode/inputFile”