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 ...
随机推荐
- java CGLib代理
转载自 cglib之Enhancer 1. 背景 cglib库的Enhancer在Spring AOP中作为一种生成代理的方式被广泛使用.本文针对Enhancer的用法以实际代码为例作一些介绍. ...
- Symfony 服务配置 看这一篇就够了
对于刚接触 Symfony 的新手来说,如何配置服务是一件很困难的事情.虽然在 Symfony 的新版本的框架中加入了自动加载(autowire),基本上满足了一般的需求,但是如果你想深入了解“服务” ...
- 关于RESTful API
添几篇文章: 一.What Is REST? 二.RESTful API最佳实践 三.MS Azure——API Design 这些文章里面也推荐了一些关联文章,微软那篇最详细,非常值得一读.
- skywalking-agent 与docker组合使用
docker部署 公司有使用docker部署的微服务 可以直接使用 仓库/java:8-jdk-alpine-asla-shanghai-1-skyagent-2作为基础镜像 这个镜像包是java8 ...
- antd做form表单的组件共用,利用mapPropsToFields填写默认值
做单页应用,不管是用Vue还是React,或者其他,有一个重要的原则,就是:组件重用. 既然组件可以重用,那么当添加一个信息,和修改该信息的布局必然是一致的,这时候,最好的方法自然是利用同一个组件,在 ...
- 进程程序替换(自主实现shell)
进程替换 替换进程所运行的程序 流程:将另一段代码加载到内存中,通过页表将原来进程的映射关系重新建立到新的程序在内存中的地址,相当于替换了进程所运行程序以及所要处理的数据 (替换了代码段,重新初始化数 ...
- JS中逗号运算符的用法
逗号运算符,它将先计算左边的参数,再计算右边的参数值.然后返回最右边参数的值. 原书举的例子不太好,无法解释上面那句话,这里另外提供一个: var a = 10, b = 20; function C ...
- js对象中属性调用.和[] 两种方式的区别
JS 调用属性一般有两种方法——点和中括号的方法. 标准格式是对象.属性(不带双引号),注意一点的是:js对象的属性,key标准是不用加引号的,加也可以,特别的情况必须加,如果key数字啊,表达式啊等 ...
- vue父组件传值和子组件触发父组件方法
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> <scr ...
- sql 基础语法使用
SQL的一些基础查询语法 基础.限定.模糊查询 关键字都是大写. 使用 BETWEENN AND 的时候小的数字或者日期放到 AND(并且) 的面前,大的一个放到AND 后面. 示例 ...