fork(4) download
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<string>
  4. #include<map>
  5. #include<vector>
  6. #include<algorithm>
  7.  
  8. using namespace std;
  9.  
  10. map<char,char> button;
  11. char tmp[123],tmp2[8];
  12. string tmp3;
  13. int dobel,now,t,n;
  14.  
  15. int main(){
  16. button['A']='2'; button['B']='2'; button['C']='2';
  17. button['D']='3'; button['E']='3'; button['F']='3';
  18. button['G']='4'; button['H']='4'; button['I']='4';
  19. button['J']='5'; button['K']='5'; button['L']='5';
  20. button['M']='6'; button['N']='6'; button['O']='6';
  21. button['P']='7'; button['R']='7'; button['S']='7';
  22. button['T']='8'; button['U']='8'; button['V']='8';
  23. button['W']='9'; button['X']='9'; button['Y']='9';
  24.  
  25. scanf("%d",&t); //printf("%d\n",t);
  26. for(int tc=0;tc<t;tc++){
  27. map<string,int> phone;
  28. vector<string> clone;
  29. dobel=0;
  30. scanf("%d",&n); //printf("%d\n",n);
  31. for(int i=0;i<n;i++){
  32. scanf("%s",tmp); now=0;
  33. for(int j=0;j<strlen(tmp);j++){
  34. if(tmp[j]>='A'&&tmp[j]<='Z'){
  35. tmp2[now]=button[tmp[j]]; now++;
  36. }else if(tmp[j]>='0'&&tmp[j]<='9'){
  37. tmp2[now]=tmp[j]; now++;
  38. }
  39. }
  40. tmp3=tmp2;
  41. phone[tmp3]++;
  42. //printf("%s %d\n",tmp2,phone[tmp3]);
  43. if(phone[tmp3]==2){
  44. dobel++; clone.push_back(tmp3);
  45. }
  46. }
  47.  
  48. if(dobel==0){
  49. printf("No Duplicates.");
  50. }else{
  51. sort(clone.begin(),clone.end());
  52. for(int i=0;i<dobel;i++){
  53. printf("%s-%s %d",clone[i].substr(0,3).c_str(),clone[i].substr(3).c_str(),phone[clone[i]]);
  54. if(i<dobel-1) printf("\n");
  55. }
  56. }
  57. if(tc<t-1) printf("\n\n");
  58. }
  59. printf("\n");
  60.  
  61. return 0;
  62. }
Success #stdin #stdout 0s 3488KB
stdin
8

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

3
3--------------------------------------3----3-----W---1-1-----1
-----F-----D---E---Y111
ABC-DEFG

12 
0-0-0-0-0-0-0 
00-0-0-0-0-0 
000-0-0-0-0 
0000-0-0-0 
00000-0-0 
000000-0 
001-----------------------------------0000 
001-------------------------------------------------0000 
0---------00000--------1 
0000--------------------------------001 
---------------------------------1000000 
1000--------000---------------------------------------- 

40
0U--4N712
---X2-KN-U-75
VR-J37G--3
85W-0Y6-V
85W-0Y6-V
85W-0Y6-V
--N-6AV4-NK
--XL----F-PO--B-0
-P-10167P
7--R8YME-N
P-U-1O6W-----1
X-KFK87--L
YFX63K-N
-3-73G---ELH
--2RD-6-IJ-Y
P2--SJ9G9
P2--SJ9G9
O-1----2287-2
-DC-C1L-3V
7963V68
U-66X52M
U-66X52M
-8-16F5TG
---YN-32E5-K
---YN-32E5-K
4--KDJ-PV2
4--KDJ-PV2
P27-42L2
P27-42L2
-MIWO-W5D
44M7675
F---6-7R80M
T5S6U1-P
T5S6U1-P
T5S6U1-P
BUM85L--3
BUM85L--3
DB1E---046
36O--7-1W2
-R--52-P-Y7H

5
-0-0-0-0-1-0-1
IYSDS-1-1-
MMDPS-22
0000A--AA
-----AMSAM--AA

6
3-10-10-1A
6464642
ASACCS5
-1111115
F101010
888-1200

5
-5-5-9-7-4-9-2
2947955
GO-HOME-1
HOME-123
12344-AA

9
-123-5657
12----12121
ABBCSS1
12112-A--B
ABBC-123
-1-2----3AABC
KKSDS-AA
ALNKNDS
----KKJ1234
stdout
310-1010 2
487-3279 4
888-4567 3

333-9111 2

000-0000 6
000-0001 2
001-0000 2
100-0000 2

286-8553 2
453-5782 2
727-4252 2
727-5949 2
857-6817 3
859-0968 3
866-9526 2
963-2355 2

No Duplicates.

No Duplicates.

No Duplicates.

No Duplicates.