Codeforces Round #313 (Div. 2) D. Equivalent Strings(简单搜索)

matlab电容式传感器仿真,差动电容式位移传感器的仿真研究 设计了一种差动电容式位移传感器,主要对传感器的数学模型及电容检测电路进行了仿真研究。其中检测电路设计主要包括正弦激励电路、转换桥路、信号放大电路、精密整流电路和滤波电路。最后利用Matlab/SimurFnk软件对所设计的系统进行仿真,并分析了传感器性能。仿真研究表明,传感器及其检测电路具有合理性,测量范围内具有很好的线性度。0|| I≯ lat on ii{差动容尊翩’亘研发注:湖南省教育厅资... 阅读详情

D. Equivalent Strings
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:

  1. They are equal.
  2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct:
    1. a1 is equivalent to b1, and a2 is equivalent to b2
    2. a1 is equivalent to b2, and a2 is equivalent to b1

As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent.

Gerald has already completed this home task. Now it's your turn!

Input

The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length.

Output

Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise.

Sample test(s)
Input
aaba
abaa
Output
YES
Input
aabb
abab
Output
NO
Note

In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a".

In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa".


题目链接:codeforces.com/contest/560/problem/D


题目大意:给出两串长度相等的字符串a,b,问其是否为等价字符串。

                  判断依据为:1.两个字符串相等。

                                        2.把每个字符串拆分成长度相等的两个子串:a=a1+a2,b=b1+b2,如果a1=b2且a2=b1,则a与b等价

深搜递归判断子串是否等价,子串等价,主串就一定等价。注意子串长度相等的条件,不满足不能拆。


代码如下:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
string a,b;
bool eq(int len,string x,string y)//用来判断x,y是否等价
{
	if(x==y)
		return true;
	if(len%2||len==0)       //当主串不能拆时,不等价
		return false;
	len/=2;
	string	a1=x.substr(0,len);
	string	a2=x.substr(len,len);
	string	b1=y.substr(0,len);
	string	b2=y.substr(len,len);
	if(eq(len,a1,b2)&&eq(len,a2,b1))
		return true;
	if(eq(len,a1,b1)&&eq(len,a2,b2))
		return true;
	return false;
}
int main(void)
{
	cin>>a;
	cin>>b;
	bool p=true;
	int len=a.length();
	if(eq(len,a,b))
		printf("YES\n");
	else
		printf("NO\n");
}




LEAP模型—低排放分析平台 LEAP 正在迅速成为进行综合资源规划、温室气体 (GHG) 缓解评估和低排放发展战略 (LEDS) 的国家的事实标准,尤其是在发展中国家,许多国家也选择使用 LEAP 作为其承诺的一部分向联合国气候变化框架公约(UNFCCC)报告。至少有 32 个国家使用 LEAP 来创建能源和排放情景,这些情景是其国家自主气候变化贡献计划 (INDC) 的基础:具有历史意义的巴黎气候协议的基础旨在表明各国开始经济脱碳的意图和投资于气候适应力。 阅读详情

相关推荐

“傻瓜”stata入门——熟悉操作界面

小白开始学习stata和matlab,零基础上手

nnpersistent的博客 4468

Codeforces Round #313 D. Equivalent Strings(DFS)

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

叶孤心的专栏 1126

关于esp32蓝牙模块的使用——esp32学习笔记

关于esp32蓝牙模块的使用——esp32学习笔记 零、前言 esp32自带蓝牙模块可以让我们进行蓝牙连接并进行数据交换 一、经典蓝牙BT 首先来编写代码,经典蓝牙的使用非常简单,首先声明使用了BluetoothSerial这个库,然后使用SerialBT.begin函数设置蓝牙的名字,再然后就是设置配对码,由于这里没有用到配对码,所以我将注释掉。当配对成功我们就使用printf函数打印出蓝牙配对成功。 #include <Arduino.h> #include <BluetoothSer

qq_53965184的博客 5万+

Codeforces Round #313 (Div. 2) 560D Equivalent Strings(dos)

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

GKHack's Blog 1619

Ubuntu20.04配置PX4环境启动或编译jmavsim 出现的错误及解决办法

错误1:ant命令未找到

Iamsonice的博客 8863

UCD9081EVM电源时序管理:硬件配置与GUI操作全解析

电源时序管理是复杂电子系统设计的核心环节,它通过精确控制多路电源的上电/下电顺序,确保核心芯片免受浪涌电流或电压倒灌的损害。其原理基于状态机逻辑与电压监控,技术价值在于将硬连线时序转化为可编程配置,极大提升了系统可靠性与设计灵活性。在服务器、通信设备、工控系统等高可靠性应用场景中,时序控制器是实现稳定启动与故障保护的关键。本文以德州仪器UCD9081评估模块为例,深入剖析其硬件跳线配置与图形用户界面操作,涵盖I2C地址设置、电压监控分压计算、时序条件与故障响应策略等工程实践要点,帮助工程师快速掌握这一电源时

weixin_42696271的博客 307

Codeforces Round #313 (Div. 2)560D. Equivalent Strings

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

KeyboardPianist的博客 926

简单的服务器取证

记一次入门服务器取证——药品直销网,涵盖旧版本宝塔、静态IP的配置更改、代码的理解

m0_74559567的博客 3760

Codeforces Round #313 (Div. 2) D. Equivalent Strings 解题心得

原题: Description Today on a lecture about strings Gerald learned a new definition of string equivalency. Two stringsaandbof equal length are calledequivalentin one of the two cases: ...

advyne9986的博客 153

27、视网膜血管识别与分类的数据集和验证过程

本文介绍了视网膜血管自动识别与分类方法所使用的数据集及其验证过程。通过30张高分辨率的近红外反射视网膜图像,结合专业医生的手动标注结果,构建了包含597个血管段的基准数据集。研究采用准确率、召回率、F1分数和混淆矩阵等评估指标对模型进行验证,并提出了特征增强和分类器优化策略以提升性能。实验结果显示,该方法在复杂区域具有较强的鲁棒性和较高的准确性,为临床应用提供了可靠的依据。

i7j8k9l的博客 149

微信小程序 - 获取当前日期时间(函数封装)

效果图 前言 摘自微信小程序demo程序中utils.js方法。 普通newDate()出来的日期时间,并不是我们想要的格式,所以要进行格式整理。 解决方案 打开utils.js文件(随意),复制以下代码: /** *获取当前时间 *@description自定义日期分钟秒数 *@param{Object}date-newData()对象 *@returnString */ functionformatTime(date){ //年月日

🏆 前端领域优质创作者 2850

Codeforces Round #313 (Div. 2) D. Equivalent Strings

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings...

151

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Codeforces Round #313 (Div. 2)——D递归,stirng——Equivalent Strings

Today on a lecture about strings Gerald learned a new definition of string equivalency. Two stringsaandbof equal length are calledequivalentin one of the two cases: They are equal. If ...

dgjm4087的博客 152

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

Codeforces Round #313 (Div. 2) D Equivalent Strings

题意 划分字符串 a1 b1 a2 b2 若a1=b2&&a2=b1 || a1=b1&&a2=b2 输出YES 若为偶数则不断划分 到奇数的时候则判断 两个字符串每一位是否相等 不能用strcmp #include #include #include #include using namespace std; const int MAX = 200100; char str1[M

WORK HARD IN SILENCE LET SUCCESS MAKE THE NOISE 461

Codeforces Round #313 (Div. 2) D. Equivalent Strings 字符串处理

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

习惯与规则决定命运 1413

Equivalent Strings(Codeforces Round #313 (Div. 2) D)

此题链接单击这里=================#include <iostream> #include <string> #include <vector> using namespace std; string a,b; bool funt(int fa,int la,int fb,int lb) { int i,j; for(i=fa,j=fb;i<la;i++,j++)

Folieshell的博客 388

Codeforces Round #313 (Div. 2) Problem D - Equivalent Strings

CF 313 DIV2 D

Accepted丶 486

Codeforces Round #313 (Div. 2)D. Equivalent Strings(字符串)

D. Equivalent StringsToday on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases:They are e

龙崎的专栏 562

Codeforces Round #313 (Div. 2) D. Equivalent Strings

D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/problem/B Description Today on a lecture about strings Gerald learned a new definiti...

weixin_30610755的博客 75

Codeforces Round #313 (Div. 2) D Equivalent Strings(dfs)

这道题先用了笨办法,就是用中间数组复制字符串,再比较,这样不仅浪费时间,而且最后做了半天还wa了,爆栈了Orz。想一个好的方法确实是事半功倍啊~~

hi_just_do_it的博客 256

Codeforces Round #313 Equivalent Strings(递归)

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

把复杂的事情简单描述 476

Codeforces Round #313 (Div. 2) D. Equivalent Strings(字符串+递归)

题意: 给两个字符串,判断是否"相等"。 这里”相等“的定义是:1、字符串对应字符相同; 2、将第一个字符串对半分成c1和d1,第二个字符串对半分成c2和d2。 如果c1==c2 && d1==d2 或者c1==d2 && c2==d1则两个字符串相等。 当字符串长度为奇数时,只有两个字符串对应字符相同才相等。 分析: 结合题意和样例,可以看出这...

weixin_34071713的博客 103
上一篇: Codeforces Round #313 (Div. 2) C. Gerald's Hexagon(补大三角形)
下一篇: A Math game (DFS+剪枝)
雨狮子
博客等级 码龄12年 24粉丝 185原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值