2ms   348KB

有点小错误,忘记将last_j也初始化为0了。。刷不上去了,在评论里记录下吧。。
全部评论
#include <stdio.h> #include <string.h> int main(void) { int i, j, k, p, q, last_j, len_r, len_s; char regular[188], s[888], record[888], ch, match; for( ; scanf("%s%s", regular, s)!=EOF; ){ len_r = strlen(regular); len_s = strlen(s); for(j=0; j<len_s; j++){ if((ch=s[j])>='a'&&ch<='z'){ record[j] = 1; continue; } if(ch>='A'&&ch<='Z'){ s[j] = ch+32; record[j] = 1; continue; } if(ch>='0'&&ch<='9'){ record[j] = 1; continue; } record[j] = 0; } for(i=0; i<len_r; i++) if((ch=regular[i])>='A' && ch<='Z') regular[i] = ch+32; i = j = k = last_j = 0; //上榜代码这里忘记初始化last_j为0了!! for( ; k<len_r; ){ if(regular[k] != '*'){ k++; continue; } break; } if(i != k){ match = 0; for( ; j<len_s; j++) if(s[j]==regular[i] || regular[i]=='?'&&record[j]){ p = i+1; q = j+1; for( ; p<k && q<len_s; p++,q++){ if(s[q] == regular[p]) continue; if(regular[p]=='?' && record[q]) continue; break; } if(p == k){ last_j = j = q; match = 1; break; } } if( !match ) goto opt; } if(k == len_r){ match = 1; goto opt; } for(i=++k; k<len_r; i=++k){ for( ; k<len_r; ){ if(regular[k] != '*'){ k++; continue; } break; } if(i != k){ match = 0; for( ; j<len_s; j++) if(s[j]==regular[i] || regular[i]=='?'&&record[j]){ p = i+1; q = j+1; for( ; p<k && q<len_s; p++,q++){ if(s[q] == regular[p]) continue; if(regular[p]=='?' && record[q]) continue; break; } if(p == k){ for(p=j-1; p>=last_j; p--){ if( record[p] ) continue; break; } if(p != last_j-1) goto opt; last_j = j = q; match = 1; break; } } if( !match ) goto opt; } } opt: printf("%s\n", match ? "true" : "false"); } return 0; }
点赞 回复 分享
发布于 2021-02-12 18:24

相关推荐

10-10 00:14
门头沟学院 Java
程序员小白条:20年架构师,无工资
点赞 评论 收藏
分享
天降大厂offer:你是我见过最美的牛客女孩
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务