链接:

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. [LuoguP2163][SHOI2007]园丁的烦恼_CDQ分治

    园丁的烦恼 题目链接:https://www.luogu.org/problem/P2163 数据范围:略. 题解: 树套树过不去,那就$CDQ$分治好了. 有点小细节,但都是$CDQ$分治必要的. ...

  2. Vue ---- Vuex 的第一次接触

    在 Vue.js 的项目中,如果项目结构简单, 父子组件之间的数据传递可以使用  props 或者 $emit 等方式 http://www.cnblogs.com/wisewrong/p/62660 ...

  3. [转帖]三款Nehalem至强5500塔式服务器横评对决(4)

    三款Nehalem至强5500塔式服务器横评对决(4) http://tech.sina.com.cn/b/2009-12-14/05051172233_4.shtml 可以看到两路服务器的设置 基本 ...

  4. 关于quartz定期,起服务时不新增配置文件中的定期问题

    关于quartz定期,起服务时不新增配置文件中的定期问题 问题原因:生产环境中起服务,未加载配置文件信息,且quartz连接超时 查找原因发现 由于别人新建了一个定期文件 并将 quartz工厂类的i ...

  5. win10从零安装eclipse并配置SVN和Maven

    原因:公司的新电脑,重新安装eclipse并通过SVN检入项目,中间经历了各种坎坷,终于在周五配置项目并启动成功:在此记录一下,给后来人以警戒,同时自己也可以常温常新. 刚开始安装的是eclipse4 ...

  6. ORC相关的库介绍和应用

    将图像翻译成文字一般被称为光学文字识别(Optical Character Recognition,OCR) OCR库:Pillow.Tesseract.NumPy Pillow Pillow可以对图 ...

  7. Python 闭包、迭代器、生成器、装饰器

    Python 闭包.迭代器.生成器.装饰器 一.闭包 闭包:闭包就是内层函数对外层函数局部变量的引用. def func(): a = "哈哈" def func2(): prin ...

  8. Class.getResources()和classLoader.getResources()区别

    Class.getResource(String path) path不以’/'开头时,默认是从此类所在的包下取资源: path 以’/'开头时,则是从ClassPath根下获取: package t ...

  9. Java 抽象类详解

    在<Java中的抽象方法和接口>中,介绍了抽象方法与接口,以及做了简单的比较. 这里我想详细探讨下抽象类. 一.抽象类的定义 被关键字“abstract”修饰的类,为抽象类.(而且,abx ...

  10. WEB监控系列第三篇:graphite指南

    一  使用说明 以下是喂数据的方式,但是在实际使用中我们使用statsd来喂数据,请参考我的第四篇文章:statsd指南 喂数据有三种方式: There are three main methods ...