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 |
帮忙看看!!#include <stdio.h> #include <map> #include <string> #include <algorithm> using namespace std; int main() { long int T,m,n,i,j,zain,sss,k=0; char s[101],ch; map<string,int> ss,flag; map<string,int>::iterator ite1,ite2; scanf("%d",&T); while(T--){ scanf("%d",&m); for(i=0;i<m;++i){ scanf("%s",&s); for(j=0;j<strlen(s);++j) if(s[j]>=65&&s[j]<=90) s[j]+=32; if(strlen(s)>2) sort(s+1,s+strlen(s)-1); ++ss[s]; } scanf("%d",&n); getchar(); sss=0; while(n--){ i=0; while(ch=getchar()){ if(ch>=65&&ch<=90) ch+=32; if(ch!=' '&&ch!='\n') s[i++]=ch; else{ s[i]='\0'; if(strlen(s)>2) sort(s+1,s+strlen(s)-1); ++flag[s]; i=0; if(ch=='\n') break; } } if(sss==0) { printf("Scenario #%d:\n",++k); sss=1; } zain=1; for(ite2=flag.begin();ite2!=flag.end();++ite2){ ite1=ss.find(ite2->first); if(ite1!=ss.end()){ j=ite2->second; while(j--){ zain*=(ite1->second); } } else{ zain=0; break; } } flag.clear(); printf("%d\n",zain); } printf("\n"); ss.clear(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator