hdu 5414 CRB and String||QDUOJ GZS and String
来源:互联网 发布:淘宝详情页面尺寸 编辑:程序博客网 时间:2024/05/18 23:53
https://www.qduoj.com/problem/6/
题意是给两个字符串s,t,每次操作是在s的某个字符c后面添加一个字符d,但要求d!=c,问能不能经过某些操作后使构造出t串
贪心
几个感觉比较好的样例
aaaba
aaaaba
No
aaaba
aaabbba
Yes
baa
baa
Yes
abb
abb
Yes
cat
cacat
Yes
#include<algorithm>#include<stdio.h>#include<iostream>#include<vector>#include<cstring>#include<string>#include<math.h>#include<map>using namespace std;const int maxn=1e5+20;char s[maxn],t[maxn];int check(char *arr1,char *arr2,int l1,int r1,int l2,int r2){int i,j=r2;for(i=r1;i>=l1;i--){while(j>=l2){if(arr1[i]==arr2[j]&&(arr2[j+1]!=arr2[j]||(arr2[j+1]==arr2[j]&&arr1[i+1]==arr1[i])))break;j--;}if(j<l2)break;j--;}if(i==l1-1)return 1;return 0;}int main(){int T,i;cin>>T;while(T--){scanf("%s",s);scanf("%s",t);//cout<<s<<" "<<t<<endl;int len1=strlen(s);int len2=strlen(t);int flog=1;i=0;while(t[i]==t[0]){if(t[i]!=s[i]){flog=0;break;}i++;}if(flog)flog&=check(s,t,i,len1-1,i,len2-1);if(flog)printf("Yes\n");elseprintf("No\n");}return 0;}
阅读全文
0 0
- hdu 5414 CRB and String||QDUOJ GZS and String
- HDU 5414 CRB and String
- hdu 5414 CRB and String
- HDU 5414 CRB and string
- hdu 5414 CRB and String
- HDU 5414CRB and String
- hdu 5414 CRB and String (贪心)
- hdu 5414 CRB and String(贪心)
- HDU 5414 CRB and String(贪心)
- hdu 5414 CRB and String(贪心)
- [思路题] hdu 5414 CRB and String
- hdu 5414 CRB and String(字符串模拟)
- hdu 5414 CRB and String(字符串模拟)
- HDU 5414 CRB and String(水~)
- CRB and String(HDUOJ--5414
- CRB and String
- hdu5414 CRB and String
- hdu5414 CRB and String
- 水仙花数
- 编写 USB 存储设备使用痕迹检测和删除工具
- TensorFlow模型文件保存和读取
- unity3d 判断是否安装指定app android and ios
- jQuery实现三级城市联动
- hdu 5414 CRB and String||QDUOJ GZS and String
- C++浮点型变量的存储方式
- caffe 保存日志的方法
- PHP数据类型
- 多层感知机实现mnist手写数字识别
- Spring入门笔记(一)---入门配置
- Android类似电商类的多级选择
- 创建抽象类
- Fragment操作方法和生命周期的关系