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

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

#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. linux基础命令---tmpwatch

    tmpwatch 删除最近一段时间没有访问的文件,时间以小时为单位,节省磁盘空间.tmpwatch递归删除给定时间未被访问的文件.通常,它用于清理用于临时保存空间(如/tmp)的目录.当更改目录时,t ...

  2. 删除github上个人的repositories的操作步骤

  3. JDBC批量插入数据优化,使用addBatch和executeBatch

    JDBC批量插入数据优化,使用addBatch和executeBatch SQL的批量插入的问题,如果来个for循环,执行上万次,肯定会很慢,那么,如何去优化呢? 解决方案:用 preparedSta ...

  4. MySQL数据库 基本操作语句

    操作MySQL数据库 1.创建数据库 create database 数据库名: 2.查看数据库 show databases: 3.选择指定数据库 use 数据库名: 4.删除数据库 drop da ...

  5. Python3基础 list 查看filter()返回的对象

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  6. Python3基础 assert 断言 确保程序的正确运行条件

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  7. 51NOD 1066 Bash游戏

    1066 Bash游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题   有一堆石子共有N个.A B两个人轮流拿,A先拿.每次最少拿1颗,最多拿K颗,拿到最后1颗石子的 ...

  8. xshell5 Linux 上传下载文件

    1,先登录身份验证和文件传输ZMODEM 选择自动激活. 2,rpm -qa | grep lrzsz 利用此命令查看是否安装了lrzsz . 如果没有任何反应则是没有安装 若没有安装 yum ins ...

  9. Unity3D学习笔记(三):V3、运动、帧率、OnGUI

    盯着看:盯住一个点 transform.LookAt(Vector3 worldPosition); using System.Collections; using System.Collection ...

  10. 软件设计师真题试题&&答案

    软件设计师2013上半年上午试题及答案详解 下午试题 2013下半年上午答案 试题 下午答案 试题 2014上半年上午答案 2015上半年上午答案 2016上半年上午试题