暴力求解——Equivalent Strings
Description
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:
- They are equal.
- 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:
- a1 is equivalent to b1, and a2 is equivalent to b2
- 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 Input
aaba
abaa
YES
aabb
abab
NO 解题思路:给两个字符串,判断它们是否相等,相等有两种情况,一个是直接相等,一个是切成长度相同的两份以后两子串交叉相等,用DFS,按照题意搜就行了,如果当前长度为奇数,直接返回false,否则分两种情况搜
程序链接:http://paste.ubuntu.com/11953312/
暴力求解——Equivalent Strings的更多相关文章
- Codeforces Round #313 (Div. 1) B. Equivalent Strings DFS暴力
B. Equivalent Strings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559 ...
- Equivalent Strings (字符串相等?)
Equivalent Strings E - 暴力求解.DFS Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I ...
- Codeforces Round #313 (Div. 1) B. Equivalent Strings
Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...
- Codeforces Round #313 (Div. 2) D. Equivalent Strings
D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...
- Equivalent Strings
Equivalent Strings 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/E 题意: 给出 ...
- POJ 1562(L - 暴力求解、DFS)
油田问题(L - 暴力求解.DFS) Description The GeoSurvComp geologic survey company is responsible for detecting ...
- 逆向暴力求解 538.D Weird Chess
11.12.2018 逆向暴力求解 538.D Weird Chess New Point: 没有读好题 越界的情况无法判断,所以输出任何一种就可以 所以他给你的样例输出完全是误导 输出还搞错了~ 输 ...
- Codeforces 559B - Equivalent Strings
559B - Equivalent Strings 思路:字符串处理,分治 不要用substr(),会超时 AC代码: #include<bits/stdc++.h> #include&l ...
- 隐型马尔科夫模型(HMM)向前算法实例讲解(暴力求解+代码实现)---盒子模型
先来解释一下HMM的向前算法: 前向后向算法是前向算法和后向算法的统称,这两个算法都可以用来求HMM观测序列的概率.我们先来看看前向算法是如何求解这个问题的. 前向算法本质上属于动态规划的算法,也就是 ...
随机推荐
- dedecms 5.7文章编辑器附件上传图标不显示
我最近发现在使用dedecms 5.7文章编辑器附件上传图标不显示了,以前是没有问题的,这个更新系统就出来问题了,下面我来给大家分享此问题解决办法. 问题bug:在dedecms 5.7中发现了一 ...
- 关于c++中的引用
引用是个别名. 1.引用是否占用空间 引用是否占用空间,此处是指广义上的占用内存空间,即为该对象新开辟一块内存.这个需要分不同的情况. 首先看一下常引用(const 引用). 这里关于常引用在c++ ...
- 在vSphere5.0虚拟机里的Ubuntu Server 32位安装JDK
本机操作系统Win7 服务器用vSphere 5.0 虚拟机 在虚拟机安装了Ubuntu Server 12.04 1.首先到Oracle官网上下载jdk-7u51-linux-i586.tar.g ...
- Kettle 实现mysql数据库不同表之间数据同步——实验过程
下面是试验的主要步骤: 在上一篇文章中LZ已经介绍了,实验的环境和实验目的. 在本篇文章中主要介绍侧重于对Kettle ETL的相应使用方法, 在这里LZ需要说明一下,LZ成为了避免涉及索引和表连接等 ...
- ssh配置事务
http://blog.csdn.net/jianxin1009/article/details/9202907(不错)
- 用Ueditor存入数据库带HTML标签的文本,从数据库取出来后,anjular用ng-bind-html处理带HTML标签的文本
ng.module('index-filters', []) .filter('trustHtml', function ($sce) { return function (input) { retu ...
- SDWebImage 在多线程下载图片时防止错乱的策略
在我们使用sd的时候,对tableView 上cell得图片进行异步下载的时候会遇到这样一个问题: 由于cell的重用机制,在我们加载出一个cell的时候imageView数据源开启一个下载任务并返 ...
- Strut2 采用token机制防御CSRF同时也可以防止表单重复提交
一 未配置Struts2 token的情况下测试 1.从表单提交数据,可以从下图看出,快速点击保存按钮,请求提交了两次 2.检查post提交的数据中未含有token参数 3.查看数据列表,有重复数据 ...
- IOS DLNA PlatinumKit库的使用
前段时间进行了IOS DLNA的开发,使用的是PlatinumKit库.网上查了很多资料都未果,经过自己的摸索,遂将如何使用PlatinumKit进行DLNA的开发分享给大家. 1.PlatinumK ...
- maven 常用插件总结
maven-javadoc-plugin (1) 说明:该插件生成项目的javadoc.对于构建jar目标,javadoc会首先生成并打包放入jar文件中. (2) 默认用法: pom.xml配置 & ...