Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) B. Strings Equalization
链接:
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) 题解
A..B略 C 对当前的值排序,再二分答案,然后对于(i%x==0 && i%y==0)放入大的,再放其他的贪心解决即可. #include<iostream> #incl ...
- 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. 题解:很显然只有 \( ...
- 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) 思路:我们想一下如果题目说的是最 ...
- 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...
随机推荐
- [百家号]7nm ARM 64核!华为Hi1620高性能CPU公开:3.0GHz
7nm ARM 64核!华为Hi1620高性能CPU公开:3.0GHz https://baijiahao.baidu.com/s?id=1617735663824201180&wfr=spi ...
- Hadoop学习(4)-mapreduce的一些注意事项
关于mapreduce的一些注意细节 如果把mapreduce程序打包放到了liux下去运行, 命令java –cp xxx.jar 主类名 如果报错了,说明是缺少相关的依赖jar包 用命令had ...
- (十四)mybatis 和 spring 整合
目录 整合思想 整合步骤 整合之后原始 dao 开发 整合之后 Mapper 代理开发 总结 整合思想 让 spring 管理 sqlSessionFactory ,使用 单例模式 创建该对象 : 根 ...
- 【php设计模式】单例模式
实现单例的三个关键点: 1.使用一个静态成员来保持一个单例实例 2.一个私有的构造方法使得该类只能在类的内部方法中被实例化 3.在实例化对象的静态方法中,先判断静态变量是否已经被赋值,如果赋值则返回该 ...
- Zookeeper快速开始
具体部署流程: #下载 wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/current/apache-zookeeper-3.5. ...
- Python简介以及入门
一. Python简介 1. Python的诞生 Python的创始人是吉多·范罗苏姆(Guido van Rossum),荷兰人.1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯 ...
- ingress之tls和path使用
ingress tls 上节课给大家展示了 traefik 的安装使用以及简单的 ingress 的配置方法,这节课我们来学习一下 ingress tls 以及 path 路径在 ingress 对象 ...
- Redis 使用指南:深度解析 info 命令
Redis 是一个使用 ANSI C 编写的开源.基于内存.可选持久性的键值对存储数据库,被广泛应用于大型电商网站.视频网站和游戏应用等场景,能够有效减少数据库磁盘 IO, 提高数据查询效率,减轻管 ...
- WP8的新功能-通过一个程序来启动另一个程序
Wp8对原来的WP7做了大量的优化...其中一个就包括Protocol Association,也就是通过uri来打开另外一个程序,这也就是说,我们可以做一个程序来启动另外一个程序了,如微信,QQ之类 ...
- 泛型和DataTable的属性
泛型转DataTable public DataTable ToDataTable<TResult>(this IEnumerable<TResult> value) wher ...