题意:定义了字符串的相等,问两串是否相等。

卡了时间,空间,不能新建字符串,否则会卡。

#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
using namespace std;
const int SZ=1e7+,INF=0x7FFFFFFF;
typedef long long lon;
string x,y; bool cmp(int bg1,int end1,int bg2,int end2)
{
for(int i=bg1,j=bg2;i<end1;++i,++j)
{
if(x[i]!=y[j])return ;
}
return ;
} bool equ(int bg1,int end1,int bg2,int end2,int d)
{
int len=end1-bg1;
//cout<<d<<"cmp: "<<bg1<<" "<<end1<<" "<<bg2<<" "<<end2<<" "<<cmp(bg1,end1,bg2,end2)<<endl;
if(cmp(bg1,end1,bg2,end2)==)return ;
else if((len)&)return ;
else
{
int half=len/;
return (equ(bg1,bg1+half,bg2,bg2+half,d+)&&equ(bg1+half,end1,bg2+half,end2,d+)||equ(bg1,bg1+half,bg2+half,end2,d+)&&equ(bg1+half,end1,bg2,bg2+half,d+));
}
} int main()
{
std::ios::sync_with_stdio();
cin>>x>>y;
if(equ(,x.size(),,y.size(),))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}

codeforces 559b//Equivalent Strings// Codeforces Round #313(Div. 1)的更多相关文章

  1. Codeforces 559B - Equivalent Strings

    559B - Equivalent Strings 思路:字符串处理,分治 不要用substr(),会超时 AC代码: #include<bits/stdc++.h> #include&l ...

  2. Codeforces - 559B - Equivalent Strings - 分治

    http://codeforces.com/problemset/problem/559/B 这个题目,分治就好了,每次偶数层可以多一种判断方式,判断它的时间就是logn的(吧),注意奇数层并不是直接 ...

  3. Codeforces 559B Equivalent Strings 等价串

    题意:给定两个等长串a,b.推断是否等价.等价的含义为:若长度为奇数,则必须是同样串.若长度是偶数,则将两串都均分成长度为原串一半的两个子串al,ar和bl,br,当中al和bl等价且ar和br等价, ...

  4. Codeforces Round #313 (Div. 1) B. Equivalent Strings

    Equivalent Strings Problem's Link: http://codeforces.com/contest/559/problem/B Mean: 给定两个等长串s1,s2,判断 ...

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

    D. Equivalent Strings Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/559/ ...

  6. 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 ...

  7. 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 standa ...

  8. Codeforces Round #313 (Div. 2)(A,B,C,D)

    A题: 题目地址:Currency System in Geraldion 题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值.若全部面值的都能表示,输出-1. 思路:水题,就 ...

  9. Codeforces Round #313 (Div. 2) 解题报告

    A. Currency System in Geraldion: 题意:有n中不同面额的纸币,问用这些纸币所不能加和到的值的最小值. 思路:显然假设这些纸币的最小钱为1的话,它就能够组成随意面额. 假 ...

随机推荐

  1. office word 2010 怎么把左侧的标题大纲调出来?

    有时候打开Word很希望出现左边的大纲,可是有时候就不出来,对word一些操作都忘得差不多了,这个小问题确实还是让我迷糊了一下~~ 网上的解决方案是: 打开Word2010文档窗口,切换到“视图”功能 ...

  2. Nginx启动SSL功能

    Nginx启动SSL功能,并进行功能优化,你看这个就足够了 一:开始Nginx的SSL模块 1.1 Nginx如果未开启SSL模块,配置Https时提示错误 nginx: [emerg] the &q ...

  3. oracle用户名和密码到期后如何处理

    原因:确定是由于Oracle11g中默认在default概要文件中设置了“PASSWORD_LIFE_TIME=180天”所导致. 影响: 1.密码过期后,业务进程连接数据库异常,影响业务使用. 2. ...

  4. linux常见命令ps的应用

    ps(Process Status)命令是linux中最常见的命令之一,它用来列出当前系统运行中的进程的状态信息.当然了,它只显示命令执行时的进程状态,如果想要动态列出状态信息,可以选择使用top命令 ...

  5. Linux中Postfix邮件发送配置(三)

    部署DNS服务器 postfix根据域名和地址做一个MX记录,A记录,PTR记录(一般在互联网上邮件服务器都要反解,没有PTR记录会认为是垃圾邮件) $ service iptables stop $ ...

  6. 怎么归档老日志的shell脚本

    本脚本来自有学习阿铭的博文学习:工作中,需要用到日志切割logrotate,按照各自的需要切割.定义保留日志.提示:本文中的S全部都$符,不要问为什么,马云爸爸的社区就这样. #用途:日志切割归档.按 ...

  7. web前端----html表单操作

    form表单 功能:表单用于向服务器传输数据,从而实现用户与Web服务器的交互 表单能够包含input系列标签,比如文本字段.复选框.单选框.提交按钮等等. 表单还可以包含textarea.selec ...

  8. linux环境下安装tomcat6

    1)下载apache-tomcat-6.0.10.tar.gz 2)#tar -zxvf apache-tomcat-6.0.10.tar.gz ://解压 3)#cp -R apache-tomca ...

  9. 由于防火墙限制无法访问linux服务器上的tomcat应用

    使用的是CentOS6.4系统. 问题重现: tomcat服务是启动的, 但无法访问服务器上的tomcat应用页面. 解决办法: 在防火墙配置中设置端口: 命令: # cd /etc/sysconfi ...

  10. TED #08# Learn to read Chinese ... with ease!

    ShaoLan: Learn to read Chinese ... with ease! Pre-requisites calligraphermy most treasured memoriesw ...