2015多校联合第十场 hdu5414CRB and String字符串思维题
来源:互联网 发布:心理学入门 知乎 编辑:程序博客网 时间:2024/05/01 07:47
Problem Description
CRB has two strings s and t.
In each step, CRB can select arbitrary character c of s and insert any character d (d ≠ c) just after it.
CRB wants to convert s to t. But is it possible?
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case there are two strings s and t, one per line.
1 ≤ T ≤ 105
1 ≤ |s| ≤ |t| ≤ 105
All strings consist only of lowercase English letters.
The size of each input file will be less than 5MB.
Output
For each test case, output “Yes” if CRB can convert s to t, otherwise output “No”.
Sample Input
4
a
b
cat
cats
do
do
apple
aapple
Sample Output
No
Yes
Yes
No
据说啊 只需要保证两个条件:
1:s是t的字串
2:对于t前k个字符如果是相同的s的前k个字符也必须是相同的
啊啊啊啊啊啊 现在才发现 居然一直看错题了!!选出来的c不删掉 只是在后面加一个d(d!=c)
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<math.h>#include<vector>#include<map>#include<set>#include<stdlib.h>#include<cmath>#include<string>#include<algorithm>#include<iostream>#define exp 1e-10using namespace std;const int N = 100005;const int inf = 1000000000;const int mod = 1000000007;char s[N],t[N];int main(){ int T,i,j,k; scanf("%d",&T); while(T--) { scanf("%s%s",s,t); for(k=i=j=0;t[i]!='\0';i++) { if(!k&&t[i]==t[0]&&s[i]!=t[0])//t的前k个字符相等,那么s的前k个字符也必须相等 break; if(t[i]!=t[0]) k=1; if(s[j]!='\0'&&t[i]==s[j])//s是t的子串 j++; } if(t[i]=='\0'&&s[j]=='\0') puts("Yes"); else puts("No"); } return 0;}
- 2015多校联合第十场 hdu5414CRB and String字符串思维题
- hdu5414CRB and String 模拟
- 2015多校联合第十场hdu5410CRB and His Birthday 01背包+完全背包
- 2015多校联合第十场hdu5407CRB and Candies数论 唯一分解定理
- 多校第十场1009 CRB and String题解
- 2017多校联合第十场/HDU 6180 Schedule (贪心)
- 多校第十场 hdu 6180 Schedule (multiset)/(思维)
- hdu 5288||2015多校联合第一场1001题
- 2015多校联合第六场 hdu5360hiking
- 2017多校联合第五场1006/hdu6090Rikka with Graph(思维公式)
- 2017多校联合第8场1008/hdu 6140Hybrid Crystals(思维)
- 多校第十场
- HDU5414 CRB and String 字符串+模拟+思维
- 2017多校联合第十场/HDU 6171 Admiral 双向bfs + 哈希
- 多校联合第三场
- hdu 6060 RXD and dividing 2017多校第三场第五题(思维+dfs)
- 2017多校联合第三场 1005题 hdu 6060 RXD and dividing (超详细!!!)构造
- HDU 5414 CRB and String (2015 Multi-University Training Contest 10 2015多校联合)
- redis cluster 集群重启关闭
- Android:对话框(12种:警告对话框&进度条对话框&日期对话框&时间对话框)
- jor(1):简表(JOR)开源的报表工具调研
- 模拟 nbut1225 NEW RDSP MODE I
- 新手必须知道的13个Xcode小技巧
- 2015多校联合第十场 hdu5414CRB and String字符串思维题
- 鸟哥的Linux私房菜-----14、磁盘配额
- 自定义控件(五)禁止滑动的ViewPager
- CAS服务端取消https验证
- C/C++编程细节(一)——你未必知道
- 堆区和栈区的区别
- 同一个变量打印char类型和unsigned char 类型,引发的思考
- hdu 3874 Necklace(离线操作+树状数组或线段树)
- vijos - P1092全排列 (康托展开 + 康托展开的逆运算)