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 |
这么大的数据,肯定要用hash 了In Reply To:超时了,哪位过来看一下啊 Posted by:fjnu_jxd_010 at 2005-07-20 23:29:36 > #include<iostream> > #include<string> > using namespace std; > int main() > { > int i=0,j,n,flag; > char c[100]; > string a[100009],b[100009]; > > while(1) > { > > > i++; > gets(c); > if(c[0]=='\0') > break; > a[i]=c; > for(j=0;j<=a[i].length();j++) > if(a[i][j]==' ') > { > b[i]=a[i].substr(j+1); > a[i]=a[i].substr(0,j); > break; > } > > > } > > n=i-1; > > while(scanf("%s",c)!=EOF) > { > flag=0; > for(j=1;j<=n;j++) > { > //cout<<c; > if(b[j]==c) > { > flag=1; > printf("%s\n",&a[j][0]); > break; > } > } > if(flag==0) > printf("eh\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