链接:

https://codeforces.com/contest/1241/problem/B

题意:

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.

思路:

s和t都能变, 直接判断是否有相同的即可.

代码:

#include <bits/stdc++.h>
using namespace std; int main()
{
int t;
cin >> t;
while (t--)
{
int Vis[30] = {0};
char s[200];
cin >> s;
int len = strlen(s);
for (int i = 0;i <len;i++)
Vis[s[i]-'a'] = 1;
cin >> s;
len = strlen(s);
bool flag = false;
for (int i = 0;i < len;i++)
{
if (Vis[s[i]-'a'])
{
flag = true;
break;
}
}
if (flag)
puts("YES");
else
puts("NO");
} return 0;
}

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) B. Strings Equalization的更多相关文章

  1. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature【枚举二分答案】

    https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the rea ...

  2. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) D. Sequence Sorting

    链接: https://codeforces.com/contest/1241/problem/D 题意: You are given a sequence a1,a2,-,an, consistin ...

  3. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature

    链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but ...

  4. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) A. CME

    链接: https://codeforces.com/contest/1241/problem/A 题意: Let's denote correct match equation (we will d ...

  5. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1)

    Virtual participate 的,D题不会做,打了1:30就打不动了,过了ABCE. A - CME 题意:? 题解:? void test_case() { int n; scanf(&q ...

  6. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) 题解

    A..B略 C 对当前的值排序,再二分答案,然后对于(i%x==0 && i%y==0)放入大的,再放其他的贪心解决即可. #include<iostream> #incl ...

  7. Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)

    A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...

  8. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3

    A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最 ...

  9. 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)

    比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...

随机推荐

  1. TensorFlow 官方文档 Programmer's Guide 中文翻译 —— 引言

    TensorFlow Programmer's Guide (Introduction) TensorFlow 编程手册 (引言) #(本项目对tensorflow官网上给出的指导手册(TF1.3版本 ...

  2. [转帖]Windows安全认证是如何进行的?[Kerberos篇]

    Windows安全认证是如何进行的?[Kerberos篇] NTLM 的简单看了一下 基本上了解了.. 这个KERBEROS 的看不太懂 感觉说的我也有点迷糊.. 虽然是对称加密的 但是不清不楚的.. ...

  3. QT QcustomPlot的使用(二)

    在QcustomPlot中,给横纵坐标添加箭头的方法 //在末尾添加箭头 customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeA ...

  4. html5手机网页开发,中文输入法下软键盘遮挡输入框

    安卓手机解决办法 微信UI框架weui中给出了解决方法:weui框架http://weui.github.io/weui/example.js // .container 设置了 overflow 属 ...

  5. MySql字段类型及字节

    字段类型:TINYINT-----------------一个很小的整数.有符号的范围是-128到127,无符号的范围是0到255. SMALLINT--------------一个小整数.有符号的范 ...

  6. git bash配置SSH远程连接阿里云ECS

    1.连接配置 1-1.添加安全组规则 1-2.使用GitHub的话本地都会有id_rsa.pub(公钥),id_rsa(私钥),一般保存在C盘用户目录下.ssh文件夹. 把公钥内容复制下来(ssh-r ...

  7. JAVA中ArrayList重写比较方法

    ArrayList的sort方法重写: 当ArrayList中存放的为含有多个成员变量的数据类型时,在进行sort排序时要重写比较方法,一般都写在这个数据类型类的内部如: package 算法竞赛入门 ...

  8. VUE实现简单的全选/全不选

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  9. bootstrap 处理警告

    $("#id").bootstrapValidator({}).on('success.field.bv', function (e, data) { })

  10. java oop 基础

    1.如果将一个类打包,使用该类的时候,必须使用该类的全名,java编译器才能找到. 2.也可以使用import 导入这个包. 3.可以不需要import语句 直接使用 java.lang包中的类. 4 ...