标签:des style blog color java os io strong
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1442 Accepted Submission(s): 541
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <vector> 5 #include <iostream> 6 using namespace std; 7 8 main() 9 { 10 char s1[10005], s2[10005], a[5], b[5]; 11 int t; 12 int n1, n2, i, j, k, kase=1; 13 vector<char>ve[110]; 14 cin>>t; 15 while(t--){ 16 for(i=0;i<110;i++) ve[i].clear(); 17 memset(s1,‘\0‘,sizeof(s1)); 18 memset(s2,‘\0‘,sizeof(s2)); 19 scanf("%s%s",s1,s2); 20 scanf("%d",&k); 21 22 for(i=0;i<k;i++) { 23 scanf("%s%s",a,b); 24 25 ve[a[0]-‘a‘].push_back(b[0]); 26 } 27 n1=strlen(s1); 28 n2=strlen(s2); 29 i=j=0; 30 int l; 31 while(i<n1&&j<n2){ 32 if(s1[i]==s2[j]){ 33 i++;j++; 34 } 35 else{ 36 int flag=0; 37 for(l=0;l<ve[s2[j]-‘a‘].size();l++){ 38 if(ve[s2[j]-‘a‘][l]==s1[i]){ 39 // ve[s1[j]-‘a‘].clear(); 40 flag=1;break; 41 } 42 } 43 if(flag) i++,j++; 44 if(!flag) j++; 45 } 46 } 47 printf("Case #%d: ",kase++); 48 if(i>=n1) 49 puts("happy"); 50 else puts("unhappy"); 51 } 52 }
标签:des style blog color java os io strong
原文地址:http://www.cnblogs.com/qq1012662902/p/3903225.html