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 |
为啥c++不超时g++超时#include<iostream> #include<stdio.h> #include<math.h> #include<vector> #include<map> #include<algorithm> #include<string> #include<string.h> #define N 100001 using namespace std; map<char,char>s1; string trans(string t) { int i,j; j=0; char p[100]; for(i=0;i<t.length();i++) { if(j==3) p[j++]='-'; if(t[i]=='-')continue; if(t[i]>='0'&&t[i]<='9') { p[j++]=t[i];continue; } p[j++]=s1[t[i]]; } p[j]='\0'; return p; } int main() { s1.insert(pair<char,char>('A','2')); s1.insert(pair<char,char>('B','2')); s1.insert(pair<char,char>('C','2')); s1.insert(pair<char,char>('D','3')); s1.insert(pair<char,char>('E','3')); s1.insert(pair<char,char>('F','3')); s1.insert(pair<char,char>('G','4')); s1.insert(pair<char,char>('H','4')); s1.insert(pair<char,char>('I','4')); s1.insert(pair<char,char>('J','5')); s1.insert(pair<char,char>('K','5')); s1.insert(pair<char,char>('L','5')); s1.insert(pair<char,char>('M','6')); s1.insert(pair<char,char>('N','6')); s1.insert(pair<char,char>('O','6')); s1.insert(pair<char,char>('P','7')); s1.insert(pair<char,char>('R','7')); s1.insert(pair<char,char>('S','7')); s1.insert(pair<char,char>('T','8')); s1.insert(pair<char,char>('U','8')); s1.insert(pair<char,char>('V','8')); s1.insert(pair<char,char>('W','9')); s1.insert(pair<char,char>('X','9')); s1.insert(pair<char,char>('Y','9')); map<string,int>s; map<string,int>::iterator it; int n,i,tmp,flag=0; string a; scanf("%d",&n); for(i=0;i<n;i++) { cin>>a; a=trans(a); it=s.find(a); if(it==s.end()) s.insert(pair<string,int>(a,1)); else it->second++; } for(it=s.begin();it!=s.end();it++) if(it->second>1) { cout<<it->first<<" "<<it->second<<endl; flag=1; } if(!flag) puts("No duplicates."); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator