请选择 进入手机版 | 继续访问电脑版

12360技术网 - 专业IT技术发表平台

 立即注册  找回密码
查看: 5749|回复: 3

2020年1月23日山师比赛题解

[复制链接]

17

主题

26

帖子

250

积分

中级会员

Rank: 3Rank: 3

积分
250
发表于 2020-1-27 05:57:05 | 显示全部楼层 |阅读模式
G - 【The__Flash】的水题

You are given two strings of equal length s and t consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose two adjacent characters in any string and assign the value of the first character to the value of the second or vice versa.
For example, if s is “acbc” you can get the following strings in one operation:
“aabc” (if you perform s2=s1);
“ccbc” (if you perform s1=s2);
“accc” (if you perform s3=s2 or s3=s4);
“abbc” (if you perform s2=s3);
“acbb” (if you perform s4=s3);
Note that you can also apply this operation to the string t.
Please determine whether it is possible to transform s into t, applying the operation above any number of times.
Note that you have to answer q independent queries.
Input
The first line contains one integer q (1≤q≤100) — the number of
queries. Each query is represented by two consecutive lines.
The first line of each query contains the string s (1≤|s|≤100)
consisting of lowercase Latin letters.
The second line of each query contains the string t (1≤|t|≤100,
|t|=|s|) consisting of lowercase Latin letters.
Output
For each query, print “YES” if it is possible to make s equal to t,
and “NO” otherwise.
You may print every letter in any case you want (so, for example, the
strings “yEs”, “yes”, “Yes”, and “YES” will all be recognized as
positive answer).
Example
Input
3
xabb
aabx
technocup
technocup
a
z
Output
YES
YES
NO
Note
In the first query, you can perform two operations s1=s2 (after it s
turns into “aabb”) and t4=t3 (after it t turns into “aabb”).
In the second query, the strings are equal initially, so the answer is “YES”.
In the third query, you can not make strings s and t equal. Therefore,the answer is “NO”.
题意:给定两个字符串s和t,长度相同,如果s字符串能转换成t字符串,输出YES,否则输出NO
解题思路:从t字符串的第一个字符开始寻找,如果一旦在s字符串中发现t中的字符,以count为标志,count++来确定是否符合条件。
[code]#include #include int main(){        int n,i,k,len1,len2;        char s[1000],t[1000];        scanf("%d",&n);        while(n--)        {                int count=0;                scanf("%s",s);len1=strlen(s);            scanf("%s",t);len2=strlen(t);            for(k=0;k




上一篇:pygame像素地图的实现
下一篇:《Cocos Creator游戏实战》关卡功能实现
回复

使用道具 举报

0

主题

17

帖子

367

积分

中级会员

Rank: 3Rank: 3

积分
367
发表于 2020-2-7 00:52:13 | 显示全部楼层
既然你诚信诚意的推荐了,那我就勉为其难的看看吧![www.12360.co]
回复

使用道具 举报

0

主题

6

帖子

136

积分

注册会员

Rank: 2

积分
136
发表于 2020-2-11 00:42:03 | 显示全部楼层
楼主,我太崇拜你了![www.12360.co]
社区不能没有像楼主这样的人才啊!
回复

使用道具 举报

0

主题

17

帖子

367

积分

中级会员

Rank: 3Rank: 3

积分
367
发表于 4 天前 | 显示全部楼层
感谢楼主的无私分享![www.12360.co]
回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

12360技术网

GMT+8, 2020-2-29 19:57 , Processed in 0.109322 second(s), 24 queries .

本网站内容收集于互联网,Www.12360.Co不承担任何由于内容的合法性及健康性所引起的争议和法律责任。 欢迎大家对网站内容侵犯版权等不合法和不健康行为进行监督和举报。

© 2019-2020 Www.12360.Co

快速回复 返回顶部 返回列表