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 |
大牛们帮小弟看看啊 无限TLEing。。。。#include <algorithm> #include <stdio.h> #include <cstring> #include <stdlib.h> using namespace std; const char mapp[26] = {'2','2', '2', '3', '3', '3', '4', '4', '4', '5', '5', '5', '6', '6', '6', '7', '@', '7', '7', '8', '8', '8', '9', '9', '9', '@'}; typedef struct my_str{ char ch[100]; int len; }my_str,*my_string; void deal_str(my_str &s,my_str &s1,int *t,int o){ //字符处理 int j=0; for(int i=0;i<s.len&&j<8;++i){ if((s.ch)[i]>='0'&&(s.ch)[i]<='9'){ (s1.ch)[j++]=(s.ch)[i]; } else if((s.ch)[i]>='A'&&(s.ch)[i]<='Z'){ if(mapp[(s.ch)[i]-'A']!='@') (s1.ch)[j++]=mapp[(s.ch)[i]-'A']; } } s1.ch[8]='\0'; t[o]=atoi(s1.ch); } int main(){ int n,num=1,j,x,sign=0; my_string s,s1; scanf("%d",&n); s=new my_str[n]; s1=new my_str[n]; int *t=new int[n]; for(int i=0;i<n;++i){ //初始化 scanf("%s",s[i].ch); s[i].len=(int)(strlen(s[i].ch)); } for(int i=0;i<n;++i) deal_str(s[i],s1[i],t,i); sort(t,t+n);//排序 for(int i=0;i<n-1;){ num=1; for(j=i+1;j<n;++j){ if(t[i]==t[j]){ ++num; x=j; } } if(num>1){ sign=1; printf("%03d-%04d %d\n",t[i]/10000,t[i]%10000,num); i=x; } else ++i; } if(sign==0) printf("No duplicates.\n"); delete []s;delete []s1;delete []t; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator