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 |
TLE 哪位大神 给 看一下啊#include <stdio.h> #include <string.h> #include <stdlib.h> #include <map> #include <iostream> using namespace std; map<string,int>re; map<string,int>::iterator it; struct N { char s[105]; char str[15]; }num[100005]; int main() { freopen("in.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF){ re.clear(); for(int i=0;i<n;i++){ scanf("%s",num[i].s); int k=0; for(int j=0;j<strlen(num[i].s);j++){ if(num[i].s[j]>='0'&&num[i].s[j]<='9') num[i].str[k++]=num[i].s[j]; else if(num[i].s[j]>='A'&&num[i].s[j]<='Z'){ switch(num[i].s[j]){ case 'A':case 'B':case 'C':num[i].str[k++]='2';break; case 'D':case 'E':case 'F':num[i].str[k++]='3';break; case 'G':case 'H':case 'I':num[i].str[k++]='4';break; case 'J':case 'K':case 'L':num[i].str[k++]='5';break; case 'M':case 'N':case 'O':num[i].str[k++]='6';break; case 'P':case 'R':case 'S':num[i].str[k++]='7';break; case 'T':case 'U':case 'V':num[i].str[k++]='8';break; case 'W':case 'X':case 'Y':num[i].str[k++]='9';break; } } if(k==3) num[i].str[k++]='-'; } num[i].str[k]='\0'; re[num[i].str]++; } int flag=0; for(it=re.begin();it!=re.end();it++) if(it->second>1){ cout<<it->first<<' '<<it->second<<endl; flag=1; } if(flag==0) printf("No duplicates.\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator